Commit 851f0726 authored by Erkka Rinne's avatar Erkka Rinne
Browse files

Fixup to 1b86ad60

Scenario reduction and scenario smoothing can be done only after data is loaded, and this code must now be in file 3c_inputsLoop.gms.
parent 563d5a1c
......@@ -433,83 +433,6 @@ loop(ms(mSolve, s),
= ds(s, t);
);
* --- Scenario reduction ------------------------------------------------------
s_active(s) = ms(mSolve, s);
if(active(mSolve, 'scenred'),
$$include 'inc/scenred.gms'
);
* --- Smooting of stochastic scenarios ----------------------------------------
$ontext
First calculate standard deviation for over all samples, then smoothen the scenarios
following the methodology presented in [1, p. 443]. This avoids a discontinuity
`jump' after the initial sample.
[1] A. Helseth, B. Mo, A. Lote Henden, and G. Warland, "Detailed long-term hydro-
thermal scheduling for expansion planning in the Nordic power system," IET Gener.
Transm. Distrib., vol. 12, no. 2, pp. 441 - 447, 2018.
$offtext
* Influx
loop(gn(grid, node)$p_autocorrelation(grid, node, 'ts_influx'),
ts_influx_mean(grid, node, ft(f, t))$mf_central(mSolve, f)
= sum(s_parallel(s_active), ts_influx_(grid, node, f, t, s_active))
/ sum(s_parallel(s_active), 1);
ts_influx_std(grid, node, ft(f, t))$mf_central(mSolve, f)
= sqrt(sum(s_parallel(s_active), sqr(ts_influx_(grid, node, f, t, s_active)
- ts_influx_mean(grid, node, f, t)))
/ sum(s_parallel(s_active), 1)
);
// Do smoothing
loop(mst_end(ms_initial(mSolve, s_), t_),
ts_influx_(grid, node, ft(f, t), s)$(ts_influx_std(grid, node, f, t_+dt_circular(t_))
and sft(s, f, t)
and not ms_initial(mSolve, s))
= min(p_tsMaxValue(node, 'ts_influx'), max(p_tsMinValue(node, 'ts_influx'),
ts_influx_(grid, node, f, t, s)
+ (ts_influx_(grid, node, f, t_, s_)
- ts_influx_(grid, node, f, t_, s))
* (ts_influx_std(grid, node, f, t+dt_circular(t))
/ ts_influx_std(grid, node, f, t_+dt_circular(t_)))
* power(p_autocorrelation(grid, node, 'ts_influx'), abs(ord(t) - ord(t_)))
));
);
);
* CF
loop(flowNode(flow, node)$p_autocorrelation(flow, node, 'ts_cf'),
ts_cf_mean(flow, node, ft(f, t))$mf_central(mSolve, f)
= sum(s_parallel(s_active), ts_cf_(flow, node, f, t, s_active))
/ sum(s_parallel(s_active), 1);
ts_cf_std(flow, node, ft(f, t))$mf_central(mSolve, f)
= sqrt(sum(s_parallel(s_active), sqr(ts_cf_(flow, node, f, t, s_active)
- ts_cf_mean(flow, node, f, t)))
/ sum(s_parallel(s_active), 1)
);
// Do smoothing
loop(mst_end(ms_initial(mSolve, s_), t_),
ts_cf_(flow, node, ft(f, t), s)$(ts_cf_std(flow, node, f, t_+dt_circular(t_))
and sft(s, f, t)
and not ms_initial(mSolve, s))
= min(p_tsMaxValue(node, 'ts_cf'), max(p_tsMinValue(node, 'ts_cf'),
ts_cf_(flow, node, f, t, s)
+ (ts_cf_(flow, node, f, t_, s_)
- ts_cf_(flow, node, f, t_, s))
* (ts_cf_std(flow, node, f, t+dt_circular(t))
/ ts_cf_std(flow, node, f, t_+dt_circular(t_)))
* power(p_autocorrelation(flow, node, 'ts_cf'), abs(ord(t) - ord(t_)))
));
);
);
* =============================================================================
* --- Defining unit aggregations and ramps ------------------------------------
* =============================================================================
......
......@@ -211,6 +211,84 @@ loop(cc(counter),
); // END if(stepsPerInterval)
); // END loop(counter)
* =============================================================================
* --- Input data processing ---------------------------------------------------
* =============================================================================
* --- Scenario reduction ------------------------------------------------------
s_active(s) = ms(mSolve, s);
if(active(mSolve, 'scenred'),
$$include 'inc/scenred.gms'
);
* --- Smooting of stochastic scenarios ----------------------------------------
$ontext
First calculate standard deviation for over all samples, then smoothen the scenarios
following the methodology presented in [1, p. 443]. This avoids a discontinuity
`jump' after the initial sample.
[1] A. Helseth, B. Mo, A. Lote Henden, and G. Warland, "Detailed long-term hydro-
thermal scheduling for expansion planning in the Nordic power system," IET Gener.
Transm. Distrib., vol. 12, no. 2, pp. 441 - 447, 2018.
$offtext
* Influx
loop(gn(grid, node)$p_autocorrelation(grid, node, 'ts_influx'),
ts_influx_mean(grid, node, ft(f, t))$mf_central(mSolve, f)
= sum(s_parallel(s_active), ts_influx_(grid, node, f, t, s_active))
/ sum(s_parallel(s_active), 1);
ts_influx_std(grid, node, ft(f, t))$mf_central(mSolve, f)
= sqrt(sum(s_parallel(s_active), sqr(ts_influx_(grid, node, f, t, s_active)
- ts_influx_mean(grid, node, f, t)))
/ sum(s_parallel(s_active), 1)
);
// Do smoothing
loop(mst_end(ms_initial(mSolve, s_), t_),
ts_influx_(grid, node, ft(f, t), s)$(ts_influx_std(grid, node, f, t_+dt_circular(t_))
and sft(s, f, t)
and not ms_initial(mSolve, s))
= min(p_tsMaxValue(node, 'ts_influx'), max(p_tsMinValue(node, 'ts_influx'),
ts_influx_(grid, node, f, t, s)
+ (ts_influx_(grid, node, f, t_, s_)
- ts_influx_(grid, node, f, t_, s))
* (ts_influx_std(grid, node, f, t+dt_circular(t))
/ ts_influx_std(grid, node, f, t_+dt_circular(t_)))
* power(p_autocorrelation(grid, node, 'ts_influx'), abs(ord(t) - ord(t_)))
));
);
);
* CF
loop(flowNode(flow, node)$p_autocorrelation(flow, node, 'ts_cf'),
ts_cf_mean(flow, node, ft(f, t))$mf_central(mSolve, f)
= sum(s_parallel(s_active), ts_cf_(flow, node, f, t, s_active))
/ sum(s_parallel(s_active), 1);
ts_cf_std(flow, node, ft(f, t))$mf_central(mSolve, f)
= sqrt(sum(s_parallel(s_active), sqr(ts_cf_(flow, node, f, t, s_active)
- ts_cf_mean(flow, node, f, t)))
/ sum(s_parallel(s_active), 1)
);
// Do smoothing
loop(mst_end(ms_initial(mSolve, s_), t_),
ts_cf_(flow, node, ft(f, t), s)$(ts_cf_std(flow, node, f, t_+dt_circular(t_))
and sft(s, f, t)
and not ms_initial(mSolve, s))
= min(p_tsMaxValue(node, 'ts_cf'), max(p_tsMinValue(node, 'ts_cf'),
ts_cf_(flow, node, f, t, s)
+ (ts_cf_(flow, node, f, t_, s_)
- ts_cf_(flow, node, f, t_, s))
* (ts_cf_std(flow, node, f, t+dt_circular(t))
/ ts_cf_std(flow, node, f, t_+dt_circular(t_)))
* power(p_autocorrelation(flow, node, 'ts_cf'), abs(ord(t) - ord(t_)))
));
);
);
* =============================================================================
* --- Old code, potentially still helpful? ------------------------------------
* =============================================================================
......
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