Refactor scenario builder #1557
guilpier-code
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
I think at this point we could try to answer two questions ?
Those two questions could help us know if Scenario Builder does what is supposed to do and if it does it well. Answering this should help us see the potential faults in the design. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What scenario builder is meant to do
A bit of vocabulary :
TS : time series. Contains a list of values for every time mark over the year. Time marks can be hour or day.
BC : binding constraint
RHS : Right Hand Side
Scenario subject : let's call Scenario subject a property of an element of the network that is subject to variations depending on the MC year.
The yearly variation of a scenario subject is what changes regarding a scenario subject when the year changes. The yearly variation can be a TS variation (meaning the TS changes at each year) or a single value variation. For example :
Note that every Scenario subject has a location in the network :
Scenario category : let's call Scenario category a set of scenario subject that belong together, whatever the location they have. Here is the full list of current scenario categories, with their specificity.
Scenario rule set : let's call scenario rule set the set of scenarii for every scenario category. Be aware that Antares simulator allows the user to define several scenario rule set, but the user must choose (or activate) one of them for a simulation run. Each scenario rule set has a name. When creating a study, a default rule set is created, wearing the name Default Ruleset. In the following, we focus on a single scenario rule set, the default one or not.
Scenario set : it is a list of scenario rule sets available. The user must select one of them for a run.
Scenario rule set... Scenario set... I know, vocabulary doesn't help, but that's how things are named in GUI and code.
Remarks from the previous definitions :
C++ class names
How scenario builder currently works
Currently, in Antares, setting the scenario of scenario categories is done by filling associated 2d-matrices, where a dimension is a location and the other is the year.
Example :
#1
is currently necessarily an area. To each area is associated a 2d-matrix : for a given cluster (location#2
) and a given year, a TS number must be supplied.If the scenario builder is not activated, all scenarii (meaning scenarii for all scenario categories) are filled with random numbers. These numbers lay inside bounds of course, bounds depending on the yearly variation kind (TS number or level value). In the code, this is the TimeSeriesNumbers::Generate step.
In case scenario builder is activated, user can define a scenario for any scenario category : she / he can fill some 2d-matrices.
Note that, in the code, the Generate step is run whether the scenario builder is activated or not, and that numbers are overridden by numbers chosen by user if the scenario builder is ON. In the code, this latter step is the currently named the apply step.
About 2d-matrices
It is important to note that each 2d-matrix has actually 2 different variations (or 2 sides) :
Let's call them the scenario builder 2d-matrices and the simulation 2d-matrices.
In the code, simulation 2d-matrices are called timeseriesNumbers most of the time (except for levels : scenarioHydroLevels). Search this keyword to trace them.
Scenario builder workflow during Antares solver execution :
Loading areas, links with their content (simulation 2d-matrices are not sized here)
Reading data from input file scenariobuilder.dat : each line of this file supplies a number in a scenario builder 2d-matrix. That's reason why a line is split into several element :
Resize all the simulation 2d-matrices (taken into account during simulation).
The TimeSeriesNumbers::Generate step : filling simulation 2d-matrices with random numbers.
The apply step : If the scenario builder is ON, then the scenario builder 2d-matrices content is copied into their counterparts, the simulation 2d-matrices, but only the read coefficients (the ones != 0).
scenario builder 2d-matrices content is copied into other structures (see for example function InitializeTimeSeriesNumbers_And_ThermalClusterProductionCost) in order to be taken into account in simulation.
Scenario builder and GUI
Any scenario category can be modified from the GUI. For any purpose, we indicate how it's done.
Any user change from GUI (here the content of a cell in a 2d-matrix) must be saved in order to be taken into account in the simulation. When saving the study, this change is saved into scenariobuilder.dat input file, and the study is ready to be run with the solver (see previous section)
It's unclear to me why the choice of save/load scenario builder data was made : I'm not sure this strategy is reaches its purpose or is the best way to fulfill this purpose. Furthermore, no instance of ScenarioBuilderUpdater is created when removing a link, or a cluster : it seems that this strategy was not fully implemented.
Code of scenario builder flaws or inconsistencies
As you know, Study is a god class, and in my opinion it should only be used to store raw data from input, and not contain objects built from the input data. And even for this mission, it should be split.
For now, we plan to keep the scenario builder in the study, because moving it would require more work and it goes out of the scope of our purpose here, but we eventually should try to extract it from the study.
Main obstacles to do this :
Once these obstacles away, we could create an instance of the scenario builder in the Application, before running the simulation. To do that, we would have to first extract the block regarding time series numbers (resize + ill with random + apply with scenario builder value) from the simulation (see ISimulation::run()) and move it to the Application. This avoid ISimulation to be dependent on the scenario builder.
What do we want
These are general purposes :
To discuss enhancements related to particular code flaws or inconsistency, please follow the links in the previous section.
Beta Was this translation helpful? Give feedback.
All reactions