Scenario builder 1 : interface is not handy #1576
guilpier-code
started this conversation in
Ideas
Replies: 1 comment
-
How scenario builder could be created and usedA new design of scenario builder will have consequences on end-to-end tests and on the production code. So we suggest changes in the scenario builder use for both.
End-to-end tests // From tests
...
ScenarioBuilder::Rules rules("Custom rules", study);
rules.category("BCgroups")
.location(BC->group()) // Group name
.year(0)
.setValue(1);
// In case we want choose a TS number for a cluster
rules.category("Thermal")
.location("Area 1")
.location("my cluster") // Location has 2 coordinates in such a case
.year(2)
.setValue(5);
// NTC
rules.category("NTC")
.location("Area 1")
.location("Area 2") // For a link, location has 2 coordinates in such a case
.year(2)
.setValue(5);
rules.apply(); Remarks :
In production code
// rules.cpp
bool Rules::readSolar(const AreaName::Vector& splitKey, String value, bool updaterMode)
{
const uint year = splitKey[2].to<uint>();
const AreaName& areaname = splitKey[1];
const Data::Area* area = getArea(areaname, updaterMode);
...
uint val = fromStringToTSnumber(value);
category("Solar").location(area->name).year(2).setValue(val); // <-- change here
return true;
}
study.resizeAllTimeseriesNumbers(1 + study.runtime->rangeLimits.year[Data::rangeEnd]);
if (not TimeSeriesNumbers::Generate(study))
{
throw FatalError("An unrecoverable error has occured. Can not continue.");
}
if (parameters.useCustomScenario)
ApplyCustomScenario(study); The last block if could merely be replaced with : study.scenarioRules.apply(); Remarks :
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This page discusses a particular aspect of this more general discussion
Please refer to this general discussion for definitions or elements of context.
How scenario builder is currently created and used in tests
Currently, here is how we create and use the scenario builder from end-to-end tests or from Antares itself (see comments on code excerpts right after) :
Comments on previous code
Possible flaws in this code
study.scenarioRulesCreate();
:ScenarioBuilder::Sets* sets = study.scenarioRules;
: the consequence of the study containing the list of rules is this line, which could be avoided.rules_ = sets->createNew("Custom");
: here we call a create method on class Sets to create a rule. We should first create a rule with a class Rules constructor and add it to an instance of Sets (as recommended in this discussion on new APIstudy.parameters.activeRulesScenario
. It seems to me that the piece of information about which rule is active should be contained inside the list of rules, rather than in the study.study.parameters.useCustomScenario
Beta Was this translation helpful? Give feedback.
All reactions