Relax soc-targets along with the other SoC constraints - #2390
Open
Flix6x wants to merge 1 commit into
Open
Conversation
An unreachable soc-target made the whole scheduling problem infeasible, so a single bad target cost the user their entire schedule. Targets were the last SoC constraint that constraint relaxation did not cover. A target is a two-sided constraint, so relax it as a stock commitment priced in both directions: falling short is a shortage, priced like a soc-minima breach, and overshooting is a surplus, priced like a soc-maxima breach. Reusing the two existing breach prices means targets need no new flex-context field and follow relax-soc-constraints/relax-constraints automatically. Targets are relaxed only when both prices are available, which is the case whenever SoC relaxation is on, since the defaults are filled in as a pair. Missed targets are now reported among the unresolved constraints, as the absolute deviation in either direction. Since a met target leaves no headroom, targets never produce a "resolved" entry. Tests that relied on targets being hard now opt out of relaxation explicitly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014qPe5bv41RDTuBVtpdxjWH Signed-off-by: F.N. Claessen <claessen@seita.nl>
Documentation build overview
6 files changed ·
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
soc-targetsas a two-sided stock commitment instead of always enforcing them as hardequalsconstraintssoc-minimabreach), overshooting is a surplus (priced like asoc-maximabreach)Context
soc-targetswas the last SoC constraint that constraint relaxation did not cover. An unreachable target made the whole scheduling problem infeasible, so one bad target cost the user their entire schedule — the outcomerelax-constraintsexists to prevent, and the same failure mode #2252 addresses by retiring the fallback scheduler.Reusing
soc-minima-breach-priceandsoc-maxima-breach-pricemeans targets need no new flex-context field and followrelax-soc-constraints/relax-constraintsautomatically. Targets are relaxed only when both prices are available, which is the case whenever SoC relaxation is on, since the two defaults are filled in as a pair.This is a piece of the wider physics-vs-preference discussion (a target is a preference, not a physical bound); by that reading it should never have been the one unconditionally hard constraint in the flex-model.
Impact
Breaking behaviour change. Under the default
relax-constraints: True, an unreachablesoc-targetsentry now yields a schedule that gets as close as the hard constraints allow and pays the breach, instead of failing the job with"The input data yields an infeasible problem.".To keep targets hard, set
relax-constraints: False— and note thatrelax-soc-constraints: Falsealone does not achieve this, becauserelax-constraintsdefaults toTrueand still fills in the default SoC breach prices (see "Discovered along the way" below).Three existing tests encoded the old behaviour and were updated to opt out of relaxation explicitly, rather than being weakened:
test_infeasible_problem_error— now runs withrelax-constraints: False, and gains a siblingtest_unreachable_soc_target_is_relaxed_by_defaultasserting the new pathtest_numerical_errors— is about numerical error in the hardequalsconstraint, so it opts outtest_add_storage_constraint_from_sensor— inspects theequalscolumn directly, so it opts outtest_get_job_status_failed_infeasible_schedule_includes_exc_info— used an unreachable target as its infeasibility source, so it opts outtest_off_tick_soc_target_extends_schedule_end_to_next_tick— needs both flags off; see belowDiscovered along the way (not fixed here)
relax-soc-constraints: Falsedoes not actually keep SoC constraints hard whilerelax-constraintsisTrue. Inflexmeasures/data/schemas/scheduling/__init__.py, the guard readswhich parses as
A or (B and C and D), so thenot ... already setconditions only guard therelax_constraintsbranch. Two consequences, both pre-existing:relax-soc-constraints: False+ defaultrelax-constraintsstill fills in the default SoC breach prices.relax-soc-constraints: Trueoverwrites explicitly-provided breach prices with the defaults, sinceset_default_breach_pricesassigns unconditionally.The same shape appears in the capacity and site-capacity blocks. This PR does not change it — fixing it would alter behaviour for
soc-minima/soc-maximaand the capacity constraints too, which deserves its own PR. It is called out because this PR makes consequence 1 more visible: targets were previously the one constraint that stayed hard regardless.How to test
Related Items
Sign-off
documentation/changelog.rst🤖 Generated with Claude Code
https://claude.ai/code/session_014qPe5bv41RDTuBVtpdxjWH