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

Fixed a serious bug with fixing online and other state variables

Set 'sft' does not contain 'ft_realized' which caused some important variable fixes not being made. Fixed by adding new sets 'sft_realized' and 'sft_realizedNoRseset' which include the realised t's.
parent e6fb2ae6
......@@ -102,6 +102,8 @@ Sets
msf(mType, s, f) "Combination of samples and forecasts in the models"
msft(mType, s, f, t) "Combination of models, samples, forecasts and t's"
sft(s, f, t) "Combination of samples, forecasts and t's in the current model solve"
sft_realized(s, f, t) "Realized sft"
sft_realizedNoReset(s, f, t) "Full set of realized sft, facilitates calculation of results"
msft_realizedNoReset(mType, s, f, t) "Combination of realized samples, forecasts and t:s in the current model solve and previously realized t:s"
mft_start(mType, f, t) "Start point of the current model solve"
mf_realization(mType, f) "fRealization of the forecasts"
......
......@@ -92,8 +92,7 @@ q_balance(gn(grid, node), msft(m, s, f, t))${ not p_gn(grid, node, 'boundAll')
q_resDemand(restypeDirectionNode(restype, up_down, node), sft(s, f, t))
${ ord(t) < tSolveFirst + p_nReserves(node, restype, 'reserve_length')
and not [ restypeReleasedForRealization(restype)
and ft_realized(f, t)
]
and sft_realized(s, f, t)]
} ..
// Reserve provision by capable units on this node
+ sum(nuft(node, unit, f, t)${nuRescapable(restype, up_down, node, unit)},
......@@ -399,8 +398,8 @@ q_reserveProvision(nuRescapable(restypeDirectionNode(restype, up_down, node), un
+ 1${not unit_flow(unit)}
]
* [
+ 1${ft_realized(f+df_reserves(node, restype, f, t), t)} // reserveReliability limits the reliability of reserves locked ahead of time.
+ p_nuReserves(node, unit, restype, 'reserveReliability')${not ft_realized(f+df_reserves(node, restype, f, t), t)}
+ 1${sft_realized(s, f+df_reserves(node, restype, f, t), t)} // reserveReliability limits the reliability of reserves locked ahead of time.
+ p_nuReserves(node, unit, restype, 'reserveReliability')${not sft_realized(s, f+df_reserves(node, restype, f, t), t)}
] // How to consider reserveReliability in the case of investments when we typically only have "realized" time steps?
;
......
......@@ -421,8 +421,16 @@ Option clear = ft_realized;
ft_realized(f_solve, t)${ mf_realization(mSolve, f_solve) and ord(t) <= tSolveFirst + mSettings(mSolve, 't_jump') }
= ft(f_solve, t);
ft_realizedNoReset(ft_realized(f, t)) = yes;
Option clear = sft_realized;
sft_realized(s, f_solve, t)${msf(mSolve, s, f_solve)
and mf_realization(mSolve, f_solve)
and ord(t) <= tSolveFirst + mSettings(mSolve, 't_jump') }
= sft(s, f_solve, t);
sft_realizedNoReset(sft_realized(s, f, t)) = yes;
// Set of realized intervals in the whole simulation so far, including model and sample dimensions
msft_realizedNoReset(msft(mSolve, s, ft_realized(f, t))) = yes;
msft_realizedNoReset(msft(mSolve, sft_realized(s, f, t))) = yes;
// Forecast index displacement between realized and forecasted intervals
// NOTE! This set cannot be reset without references to previously solved time steps in the stochastic tree becoming ill-defined!
......
......@@ -298,8 +298,8 @@ loop((restypeDirectionNode(restype, up_down, node), sft(s, f, t))${ ord(t) <= tS
v_gen.up('elec', node, unit, s, f, t) - v_gen.lo('elec', node, unit, s, f, t) // Generator + consuming unit available unit_elec. output delta
) // END min
* [
+ 1${ft_realized(f+df_reserves(node, restype, f, t), t)} // reserveReliability limits the reliability of reserves locked ahead of time.
+ p_nuReserves(node, unit, restype, 'reserveReliability')${not ft_realized(f+df_reserves(node, restype, f, t), t)}
+ 1${sft_realized(s, f+df_reserves(node, restype, f, t), t)} // reserveReliability limits the reliability of reserves locked ahead of time.
+ p_nuReserves(node, unit, restype, 'reserveReliability')${not sft_realized(s, f+df_reserves(node, restype, f, t), t)}
]; // END * min
// Reserve transfer upper bounds based on input p_nnReserves data, if investments are disabled
......@@ -454,27 +454,27 @@ loop((mft_start(mSolve, f, t), ms_initial(mSolve, s)),
* =============================================================================
// Needed for modelling hot and warm start-ups, minimum uptimes and downtimes, and run-up and shutdown phases.
v_startup.fx(unitStarttype(unit, starttype), sft(s, ft_realizedNoReset(f, t_active(t))))
v_startup.fx(unitStarttype(unit, starttype), sft_realizedNoReset(s, f, t_active(t)))
${ ord(t) <= tSolveFirst
and sum[ft(f_,t_), uft_online(unit,f_,t_)]
}
= r_startup(unit, starttype, f, t)
;
v_shutdown.fx(unit, sft(s, ft_realizedNoReset(f, t_active(t))))
v_shutdown.fx(unit, sft_realizedNoReset(s, f, t_active(t)))
${ ord(t) <= tSolveFirst
and sum[ft(f_,t_), uft_online(unit,f_,t_)]
}
= r_shutdown(unit, f, t)
;
v_online_MIP.fx(unit, sft(s, ft_realizedNoReset(f, t_active(t))))
v_online_MIP.fx(unit, sft_realizedNoReset(s, f, t_active(t)))
${ ord(t) <= tSolveFirst
and sum[ft(f_,t_), uft_onlineMIP(unit,f_,t_)]
}
= round(r_online(unit, f, t));
v_online_LP.fx(unit, sft(s, ft_realizedNoReset(f, t_active(t))))
v_online_LP.fx(unit, sft_realizedNoReset(s, f, t_active(t)))
${ ord(t) <= tSolveFirst
and sum[ft(f_,t_), uft_onlineLP(unit,f_,t_)]
}
......
......@@ -31,28 +31,28 @@ loop(msft(mSolve, s, f_solve, t),
);
);
// Realized state history
loop(msft(mSolve, s, ft_realized(f, t)),
r_state(gn_state(grid, node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_state.l(grid, node, s, f, t);
// Realized state history - initial state values in samples
r_state(gn_state(grid, node), f_solve(f), t+dt(t))${ ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')
and sum(ms(mSolve, s), mst_start(mSolve, s, t))
}
= v_state.l(grid, node, s, f, t+dt(t))
;
// Realized unit online history
r_online(uft_online(unit, f, t))$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_online_LP.l(unit, s, f, t)${ uft_onlineLP(unit, f, t) }
+ v_online_MIP.l(unit, s, f, t)${ uft_onlineMIP(unit, f, t) }
;
// Unit startup and shutdown history
r_startup(unit, starttype, f, t)${ uft_online(unit, f, t) and [ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')] }
= v_startup.l(unit, starttype, s, f, t)
;
r_shutdown(uft_online(unit, f, t))$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_shutdown.l(unit, s, f, t)
;
loop(sft_realized(s, f, t),
r_state(gn_state(grid, node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_state.l(grid, node, s, f, t);
// Realized state history - initial state values in samples
r_state(gn_state(grid, node), f_solve(f), t+dt(t))${ ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')
and sum(ms(mSolve, s), mst_start(mSolve, s, t))
}
= v_state.l(grid, node, s, f, t+dt(t))
;
// Realized unit online history
r_online(uft_online(unit, f, t))$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_online_LP.l(unit, s, f, t)${ uft_onlineLP(unit, f, t) }
+ v_online_MIP.l(unit, s, f, t)${ uft_onlineMIP(unit, f, t) }
;
// Unit startup and shutdown history
r_startup(unit, starttype, f, t)${ uft_online(unit, f, t) and [ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')] }
= v_startup.l(unit, starttype, s, f, t)
;
r_shutdown(uft_online(unit, f, t))$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_shutdown.l(unit, s, f, t)
;
);
* --- Reserve results ---------------------------------------------------------
......@@ -67,7 +67,7 @@ loop((restypeDirectionNode(restype, up_down, node), sft(s, f, t))
// Reserve provisions of units
r_reserve(nuRescapable(restype, up_down, node, unit), f+df_reserves(node, restype, f, t), t)
${ not [ restypeReleasedForRealization(restype)
and ft_realized(f+df_reserves(node, restype, f, t), t)
and sft_realized(s, f+df_reserves(node, restype, f, t), t)
]
}
= v_reserve.l(restype, up_down, node, unit, s, f+df_reserves(node, restype, f, t), t);
......@@ -94,23 +94,23 @@ loop((restypeDirectionNode(restype, up_down, node), sft(s, f, t))
* --- Interesting results -----------------------------------------------------
loop(msft(mSolve, s, ft_realized(f, t)),
// Unit generation and consumption
r_gen(gnuft(grid, node, unit, f, t))$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_gen.l(grid, node, unit, s, f, t)
;
// Fuel use of units
r_fuelUse(fuel, uft(unit_fuel, f, t))$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_fuelUse.l(fuel, unit_fuel, s, f, t)
;
// Transfer of energy between nodes
r_transfer(gn2n(grid, from_node, to_node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_transfer.l(grid, from_node, to_node, s, f, t)
;
// Energy spilled from nodes
r_spill(gn(grid, node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_spill.l(grid, node, s, f, t)
;
loop(sft_realized(s, f, t),
// Unit generation and consumption
r_gen(gnuft(grid, node, unit, f, t))$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_gen.l(grid, node, unit, s, f, t)
;
// Fuel use of units
r_fuelUse(fuel, uft(unit_fuel, f, t))$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_fuelUse.l(fuel, unit_fuel, s, f, t)
;
// Transfer of energy between nodes
r_transfer(gn2n(grid, from_node, to_node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_transfer.l(grid, from_node, to_node, s, f, t)
;
// Energy spilled from nodes
r_spill(gn(grid, node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_spill.l(grid, node, s, f, t)
;
);
// Total Objective function
......@@ -119,18 +119,18 @@ r_totalObj
;
// q_balance marginal values
loop(msft(mSolve, s, ft_realized(f, t)),
loop(sft_realized(s, f, t),
r_balanceMarginal(gn(grid, node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= q_balance.m(grid, node, mSolve, s, f, t)
;
// q_resDemand marginal values
r_resDemandMarginal(restypeDirectionNode(restype, up_down, node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= q_resDemand.m(restype, up_down, node, s, f, t)
;
// v_stateSlack values for calculation of realized costs later on
r_stateSlack(gn_stateSlack(grid, node), slack, f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_stateSlack.l(grid, node, slack, s, f, t)
;
;
// q_resDemand marginal values
r_resDemandMarginal(restypeDirectionNode(restype, up_down, node), f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= q_resDemand.m(restype, up_down, node, s, f, t)
;
// v_stateSlack values for calculation of realized costs later on
r_stateSlack(gn_stateSlack(grid, node), slack, f, t)$[ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')]
= v_stateSlack.l(grid, node, slack, s, f, t)
;
);
// Unit investments
r_invest(unit)${unit_investLP(unit) or unit_investMIP(unit)}
......@@ -146,7 +146,7 @@ r_investTransfer(grid, node, node_, t_invest(t))${ p_gnn(grid, node, node_, 'tra
;
* --- Feasibility results -----------------------------------------------------
loop(msft(mSolve, s, ft_realized(f, t)),
loop(sft_realized(s, f, t),
// Dummy generation & consumption
r_qGen(inc_dec, gn(grid, node), f, t)
${ ord(t) > mSettings(mSolve, 't_start') + mSettings(mSolve, 't_initializationPeriod')
......
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