Commit 97303eb6 authored by Juha Kiviluoma's avatar Juha Kiviluoma
Browse files

Merge branch 'Fix_ramp_constraints' of https://gitlab.vtt.fi/backbone/backbone...

Merge branch 'Fix_ramp_constraints' of https://gitlab.vtt.fi/backbone/backbone into Fix_ramp_constraints
parents 4a045713 79218b9e
......@@ -30,9 +30,9 @@ Sets
unit_flow(unit) "Unit that depend directly on variable energy flows (RoR, solar PV, etc.)"
unit_fuel(unit) "Units using a commercial fuel"
unit_minLoad(unit) "Units that have unit commitment restrictions (e.g. minimum power level)"
unit_online(unit) "Units that have an online variable in the first effLevel level1"
unit_online_LP(unit) "Units that have an LP online variable in the first effLevel level1"
unit_online_MIP(unit) "Units that have an MIP online variable in the first effLevel level1"
unit_online(unit) "Units that have an online variable in the first active effLevel"
unit_online_LP(unit) "Units that have an LP online variable in the first active effLevel"
unit_online_MIP(unit) "Units that have an MIP online variable in the first active effLevel"
unit_aggregator(unit) "Aggregator units aggragating several units"
unit_aggregated(unit) "Units that are aggregated"
unit_noAggregate(unit) "Units that are not aggregated and are not aggregators"
......
......@@ -146,13 +146,6 @@ unit_minload(unit)${ p_unit(unit, 'op00') > 0 // If the first defined operati
}
= yes;
// Units with online variables in the effLevel 'level1'
unit_online(unit)${ sum(effSelector$effOnline(effSelector), effLevelGroupUnit('level1', effSelector, unit)) }
= yes;
unit_online_LP(unit)${ sum(effSelector, effLevelGroupUnit('level1', 'directOnLP', unit)) }
= yes;
unit_online_MIP(unit) = unit_online(unit) - unit_online_LP(unit);
// Units with flows/fuels
unit_flow(unit)${ sum(flow, flowUnit(flow, unit)) }
= yes;
......
......@@ -121,45 +121,75 @@ dt_circular(t_full(t))${ ord(t) > ts_length }
* --- Initialize Unit Efficiency Approximations -------------------------------
* =============================================================================
* --- Calculate 'lastStepNotAggregated' for aggregated units and aggregator units (needs to be done before mSettingsEff(m, effLevel) is cleaned up)
* --- Calculate 'lastStepNotAggregated' for aggregated units and aggregator units
loop(m,
p_unit(unit_aggregated(unit), 'lastStepNotAggregated')
= sum{(unit_, effLevel)$unitUnitEffLevel(unit_, unit, effLevel), mSettingsEff(m, effLevel - 1) };
p_unit(unit_aggregator(unit), 'lastStepNotAggregated')
= smax{(unit_, effLevel)$unitUnitEffLevel(unit, unit_, effLevel), mSettingsEff(m, effLevel - 1) };
loop(effLevel$mSettingsEff(m, effLevel),
loop(effLevel_${mSettingsEff(m, effLevel_) and ord(effLevel_) < ord(effLevel)},
p_unit(unit_aggregated(unit), 'lastStepNotAggregated')${ sum(unit_,unitUnitEffLevel(unit_, unit, effLevel)) }
= mSettingsEff(m, effLevel_);
p_unit(unit_aggregator(unit), 'lastStepNotAggregated')${ sum(unit_,unitUnitEffLevel(unit, unit_, effLevel)) }
= mSettingsEff(m, effLevel_);
);
);
);
* --- Ensure that efficiency levels extend to the end of the model horizon and do not go beyond ----
loop(m,
continueLoop = 0;
// First check how many efficiency levels there are and cut levels going beyond the t_horizon
tmp = 0;
loop(effLevel$mSettingsEff(m, effLevel),
continueLoop = continueLoop + 1;
continueLoop = ord(effLevel);
// Check if the level extends to the end of the t_horizon
if (mSettingsEff(m, effLevel) = mSettings(m, 't_horizon'),
tmp = 1;
);
if (mSettingsEff(m, effLevel) > mSettings(m, 't_horizon'),
mSettingsEff(m, effLevel) = mSettings(m, 't_horizon');
put log '!!! Set mSettingsEff(', m.tl:0, ', ', effLevel.tl:0, ') to ', mSettings(m, 't_horizon'):0:0 /;
// Cut the first level going beyond the t_horizon (if the previous levels did not extend to the t_horizon)
if (tmp = 0,
mSettingsEff(m, effLevel) = mSettings(m, 't_horizon');
tmp = 1;
put log '!!! Set mSettingsEff(', m.tl:0, ', ', effLevel.tl:0, ') to ', mSettings(m, 't_horizon'):0:0 /;
// Remove other levels going beyond the t_horizon
else
mSettingsEff(m, effLevel) = no;
put log '!!! Removed mSettingsEff(', m.tl:0, ', ', effLevel.tl:0, ')' /;
);
);
);
// Set last effLevel to equal to the t_horizon
loop(effLevel$(ord(effLevel) = continueLoop),
if (mSettingsEff(m, effLevel) < mSettings(m, 't_horizon'),
mSettingsEff(m, effLevel) = mSettings(m, 't_horizon');
put log '!!! Set mSettingsEff(', m.tl:0, ', ', effLevel.tl:0, ') to ', mSettings(m, 't_horizon'):0:0 /;
);
// Ensure that that the last active level extends to the end of the t_horizon
if ( tmp = 0,
mSettingsEff(m, effLevel)${ord(effLevel) = continueLoop} = mSettings(m, 't_horizon');
put log '!!! Set mSettingsEff(', m.tl:0, ', level', continueLoop, ') to ', mSettings(m, 't_horizon'):0:0 /;
);
// Remove effLevels with same end time step
// Remove effLevels with same end time step (keep the last one)
loop(effLevel$mSettingsEff(m, effLevel),
loop(effLevel_${mSettingsEff(m, effLevel_) and ord(effLevel) <> ord(effLevel_)},
if (mSettingsEff(m, effLevel_) = mSettingsEff(m, effLevel),
mSettingsEff(m, effLevel_) = no;
put log '!!! Removed mSettingsEff(', m.tl:0, ', ', effLevel_.tl:0, ')' /;
mSettingsEff(m, effLevel) = no;
put log '!!! Removed mSettingsEff(', m.tl:0, ', ', effLevel.tl:0, ')' /;
);
);
);
);
* --- Units with online variables in the first active effLevel ---------------
loop(m,
continueLoop = 0;
loop(effLevel$mSettingsEff(m, effLevel),
continueLoop = continueLoop + 1;
if (continueLoop = 1,
unit_online(unit)${ sum(effSelector$effOnline(effSelector), effLevelGroupUnit(effLevel, effSelector, unit)) }
= yes;
unit_online_LP(unit)${ sum(effSelector, effLevelGroupUnit(effLevel, 'directOnLP', unit)) }
= yes;
unit_online_MIP(unit) = unit_online(unit) - unit_online_LP(unit);
);
);
);
* --- Parse through effLevelGroupUnit and convert selected effSelectors into sets representing those selections
// Loop over effLevelGroupUnit
......
......@@ -507,9 +507,9 @@ uft_onlineLP_withPrevious(uft_onlineLP(unit, f, t)) = yes;
uft_onlineMIP_withPrevious(uft_onlineMIP(unit, f, t)) = yes;
// Units with online variables on each ft starting at t0, depending on setting for effSelector on level1
uft_onlineLP_withPrevious(unit,f,t)${ord(t)=tSolveFirst and mf_realization(mSolve,f) and unit_online_LP(unit)} //set equals uft_onlineLP if units do not have an LP online variable on level1
uft_onlineLP_withPrevious(unit,f,t)${ord(t)=tSolveFirst and mf_realization(mSolve,f) and unit_online_LP(unit)} //set equals uft_onlineLP if units do not have an LP online variable on the first active efficiency level
= yes;
uft_onlineMIP_withPrevious(unit,f,t)${ord(t)=tSolveFirst and mf_realization(mSolve,f) and unit_online_MIP(unit)} //set equals uft_onlineMIP if units do not have an MIP online variable on level1
uft_onlineMIP_withPrevious(unit,f,t)${ord(t)=tSolveFirst and mf_realization(mSolve,f) and unit_online_MIP(unit)} //set equals uft_onlineMIP if units do not have an MIP online variable on the first active efficiency level
= yes;
// Calculate time series form parameters for units using direct input output conversion without online variable
......
......@@ -194,6 +194,20 @@ if (mSolve('schedule'),
r_solveStatus(tSolve,'objEst')=schedule.objEst;
r_solveStatus(tSolve,'objVal')=schedule.objVal;
);
if (mSolve('invest'),
r_solveStatus(tSolve,'modelStat')=invest.modelStat;
r_solveStatus(tSolve,'solveStat')=invest.solveStat;
r_solveStatus(tSolve,'totalTime')=invest.etSolve;
r_solveStatus(tSolve,'iterations')=invest.iterUsd;
r_solveStatus(tSolve,'nodes')=invest.nodUsd;
r_solveStatus(tSolve,'numEqu')=invest.numEqu;
r_solveStatus(tSolve,'numDVar')=invest.numDVar;
r_solveStatus(tSolve,'numVar')=invest.numVar;
r_solveStatus(tSolve,'numNZ')=invest.numNZ;
r_solveStatus(tSolve,'sumInfes')=invest.sumInfes;
r_solveStatus(tSolve,'objEst')=invest.objEst;
r_solveStatus(tSolve,'objVal')=invest.objVal;
);
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