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

Maintain the original scenario labels after reduction

(cherry picked from commit bf021b2e)
parent ec74d221
...@@ -45,32 +45,34 @@ else ...@@ -45,32 +45,34 @@ else
// Update probabilities // Update probabilities
p_msProbability(mSolve, s) = p_sProbability(s); p_msProbability(mSolve, s) = p_sProbability(s);
// Update sets
ms(mSolve, s)$ms(mSolve, s) = yes$p_msProbability(mSolve, s);
msf(mSolve, s, f)$msf(mSolve, s, f) = ms(mSolve, s);
msft(mSolve, s, f, t)$msft(mSolve, s, f, t) = msf(mSolve, s, f);
sft(s, f, t)$sft(s, f, t) = yes$p_msProbability(mSolve, s);
fts(f, t, s)$fts(f, t, s) = sft(s, f, t);
// Update scenarios // Update scenarios
Option clear = s_scenario; loop(mft_lastSteps(mSolve, f, t), // Select last time step
count = 1; // Select each scenario and the leaf sample of the scenario (using non-reduced msft)
loop((mft_lastSteps(mSolve, f, t), msft(mSolve, s_, f, t)), // Select each leaf sample loop((scenario, msft(mSolve, s_, f, t))$s_scenario(s_, scenario),
Option clear = s_prev; s_prev(s_) = yes; // Set scen. probability to the prob. of leaf sample
loop(scenario$(ord(scenario) = count), p_scenProbability(scenario) = p_msProbability(mSolve, s_);
s_scenario(s_, scenario) = yes; // Drop scenarios with zero probability
s_scenario(s, scenario)$(not p_scenProbability(scenario)) = no;
// Build scenarios starting from the leaf samples
Option clear = s_prev; s_prev(s_) = yes;
tmp = 0; tmp = 0;
repeat( while(not tmp and p_scenProbability(scenario),
loop(ss(s__, s)$s_prev(s__), loop(ss(s__, s)$s_prev(s__),
s_scenario(s, scenario) = yes; s_scenario(s, scenario) = yes$p_msProbability(mSolve, s);
Option clear = s_prev; s_prev(s) = yes; Option clear = s_prev; s_prev(s) = yes;
tmp = ms_initial(mSolve, s); tmp = ms_initial(mSolve, s);
); );
until tmp); );
); );
count = count + 1;
); );
// Update sets
ms(mSolve, s)$ms(mSolve, s) = yes$p_msProbability(mSolve, s);
msf(mSolve, s, f)$msf(mSolve, s, f) = ms(mSolve, s);
msft(mSolve, s, f, t)$msft(mSolve, s, f, t) = msf(mSolve, s, f);
sft(s, f, t)$sft(s, f, t) = yes$p_msProbability(mSolve, s);
fts(f, t, s)$fts(f, t, s) = sft(s, f, t);
// Clear data from removed samples // Clear data from removed samples
ts_influx_(gn, ft, s_active(s))$(not p_sProbability(s)) = 0; ts_influx_(gn, ft, s_active(s))$(not p_sProbability(s)) = 0;
ts_cf_(flowNode, ft, s_active(s))$(not p_sProbability(s)) = 0; ts_cf_(flowNode, ft, s_active(s))$(not p_sProbability(s)) = 0;
......
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