Commit a6ac1136 authored by Erkka Rinne's avatar Erkka Rinne
Browse files

Added checks to see if set `scenario` is defined

parent 649b1d88
......@@ -125,6 +125,7 @@ Sets
s_active(s) "Samples with non-zero probability in the current model solve"
ss(s, s) "Previous sample of sample"
s_prev(s) "Temporary set for previous sample"
$if defined scenario
s_scenario(s, scenario) "Which samples belong to which scenarios"
gn_scenarios(*, node, *) "Which grid/flow, node and timeseries/param have data for long-term scenarios"
......
......@@ -95,9 +95,11 @@ Parameters
p_mfProbability(mType, f) "Probability of forecast"
p_msft_probability(mType, s, f, t) "Probability of forecast"
p_sProbability(s) "Probability of sample"
$if defined scenario
p_scenProbability(scenario) "Probability of scenarios"
;
$if declared p_scenProbability
Option clear = p_scenProbability; // Initialize with empty data
Scalar p_sWeightSum "Sum of sample weights";
......
......@@ -147,9 +147,11 @@ Option clear = mft;
Option clear = ft;
Option clear = sft;
Option clear = mst_start, clear = mst_end;
$ifthen declared scenario
if(mSettings(mSolve, 'scenarios'), // Only clear these if using long-term scenarios
Options clear = s_active, clear = s_scenario, clear = ss;
);
$endif
// Initialize the set of active t:s, counters and interval time steps
......@@ -259,6 +261,7 @@ loop(cc(counter),
and ord(t) < msEnd(mSolve, s) + tSolveFirst // Move the samples along with the dispatch
} = mft(mSolve, f_solve, t);
$ifthen defined scenario
// Create stochastic programming scenarios
if(mSettings(mSolve, 'scenarios'),
// Select root sample and central forecast
......@@ -286,6 +289,8 @@ loop(cc(counter),
);
ms(mSolve, s) = s_active(s);
);
$endif
// Reduce the model dimension
ft(f_solve, tt_interval(t)) = mft(mSolve, f_solve, t);
......@@ -299,6 +304,7 @@ loop(cc(counter),
); // END loop(counter)
* Build stochastic tree by definfing previous samples
$ifthen defined scenario
Option clear = s_prev;
loop(scenario$(ord(scenario) <= mSettings(mSolve, 'scenarios')),
loop(s_scenario(s, scenario),
......@@ -306,11 +312,14 @@ loop(scenario$(ord(scenario) <= mSettings(mSolve, 'scenarios')),
Option clear = s_prev; s_prev(s) = yes;
);
);
$endif
* --- Define sample offsets for creating stochastic scenarios -----------------
Option clear = dt_scenarioOffset;
$ifthen defined scenario
loop(s_scenario(s, scenario)$(ord(s) > 1 and ord(scenario) > 1),
loop(gn_scenarios(grid, node, timeseries),
dt_scenarioOffset(grid, node, timeseries, s)
......@@ -327,6 +336,7 @@ loop(s_scenario(s, scenario)$(ord(s) > 1 and ord(scenario) > 1),
= (ord(scenario) - 1) * mSettings(mSolve, 'scenarioLength');
);
);
$endif
* --- Determine various other forecast-time sets required for the model -------
......
......@@ -450,10 +450,12 @@ loop(effLevelGroupUnit(effLevel, effGroup, unit)${ mSettingsEff(mSolve, effLeve
* --- Input data processing ---------------------------------------------------
* =============================================================================
$ifthen defined scenario
* --- Scenario reduction ------------------------------------------------------
if(active(mSolve, 'scenred'),
$$include 'inc/scenred.gms'
);
$endif
* --- Update probabilities ----------------------------------------------------
Option clear = p_msft_probability;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment