Skip to content

Add getGain() and getBias() for the average reward criterion - #17

Merged
areenberg merged 2 commits into
masterfrom
additional_output
Nov 14, 2026
Merged

areenberg merged 2 commits into
masterfrom
additional_output

Conversation

@areenberg

Copy link
Copy Markdown
Owner

Summary

  • getGain(bound=None): the gain after solve(criterion="average"). The smallest and largest change of the values in the last iteration of solve() bound the gain: the gain of the optimized policy and the optimal gain both lie between them, and they are less than the tolerance apart when solve() has converged. By default it returns their midpoint; bound="lower" or "upper" returns a bound. The bounds are kept in C++ (ModifiedPolicyIteration, ModuleInterface::getGainBounds()), at no extra cost to solve().
  • getBias(stateIndex, referenceIndex=0): the bias of a state with the bias of the reference state set to 0, i.e. the value of the state minus the value of the reference state. Only these two values are read from the solver.
  • Both raise a RuntimeError after a run under the discounted criterion.

Tests

  • New test_average.py (added to CI) checks:
    • the gain bounds against exact gains: the hub-and-spoke problem, random unichain models, and a periodic model that stops at the iteration limit;
    • the bias against known biases, for every state and reference state;
    • the errors.
  • test_order.py covers the two new output methods.
  • All 13 tests pass locally.

The wiki is updated in the local clone (Classes-and-methods, Validating-MDPSolver, Contribution-guidelines) but not pushed yet.

@areenberg
areenberg merged commit 113e254 into master Nov 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant