Skip to content

Weight Separately Solved Scenarios by Their Probability in the Results - #242

Merged
erikfilias merged 1 commit into
masterfrom
fix/scenario-probability-in-cost-summary
Nov 26, 2026
Merged

erikfilias merged 1 commit into
masterfrom
fix/scenario-probability-in-cost-summary

Conversation

@erikfilias

Copy link
Copy Markdown
Contributor

Problem

Without investment decisions and without a RES or emission target, StageIterativeSolving solves each period and scenario separately. Before each solve it sets pScenProb of that scenario to 1.0, and after the solve to 0.0. However, the objective does not read pScenProb at solve time: TotalObjectiveFunction evaluates the scenario weights once, with the input probabilities, when the objective is built. The changes of pScenProb therefore affect only the console summary, and every solve still weights its scenario by the input probability. After the loop, pScenProb is reset to 1.0 for every scenario, so the cost summary sums the scenarios instead of weighting them. In contrast, the objective, total_cost_meur and the marginal prices, which divide the duals by pPeriodProb, all use the input probabilities.

None of the shipped cases has more than one scenario per period, so neither the cases nor the tests reach this path.

Observed behaviour

Case 9n7y, each period reduced to 24 h in one stage, with a second scenario sc02 (demand 10 % higher), each scenario with probability 0.5; solved with HiGHS on master after #240:

One solve per period, one scenario One solve per period, two scenarios Joint solve, two scenarios
Objective (vTotalSCost) and total_cost_meur (MEUR) 9373.30 10 487.97 9943.48
Cost summary, sum of rows (MEUR) 9373.30 20 975.95 9943.48
Mean marginal price of sc01 (EUR/MWh) 59.8651 59.8651 51.1013

With two scenarios solved separately, the cost summary is 2.0 times the expected cost, whereas the marginal price of sc01 equals that of the single-scenario case. Hence, the solves and the duals are correct, and only the reporting is affected.

Solution

The changes of pScenProb around each solve and the reset after the loop are removed. The scenario probabilities keep their input values throughout, so every writer weights the scenarios as the objective does. The joint solve already kept the input probabilities, so both solve paths now follow one convention. The map, which selects the scenario of probability 1.0, already falls back to the first scenario when none has probability 1.0.

After the change

The same cases:

One solve per period, one scenario One solve per period, two scenarios Joint solve, two scenarios
Objective and total_cost_meur (MEUR) 9373.30 10 487.97 9943.48
Cost summary, sum of rows (MEUR) 9373.30 10 487.97 9943.48
Mean marginal price of sc01 (EUR/MWh) 59.8651 59.8651 51.1013

Notes

  • tests/test_stage_costs.py gains a third solve test with the two scenarios above (about 15 s in total). It fails on master, where the probabilities are reset to 1.0.
  • The per-scenario rows of the result files (for example, the generation cost per period and scenario) are now weighted by the scenario probability, as they already were in a joint solve. With one scenario per period, the probability is 1.0 and nothing changes.
  • The console summary after each separate solve now reports the cost of that solve weighted by the probability of its scenario.
  • The convention of 9 May 2026 (e8fbf80) summed the scenarios on the premise that each separate solve used probability 1.0; the measurement above shows that the solves used the input probabilities.

The objective weights each scenario by its input probability, also when
the scenarios are solved one at a time, since the weights are fixed when the
objective is built. The probabilities were set to 1.0 around each solve and
after the loop, which changed only the console output and made the cost
summary sum the scenarios. They now keep their input values, so the cost
summary reports the expected cost, as the objective and the run status do.
@erikfilias
erikfilias merged commit fc18438 into master Nov 26, 2026
14 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