Skip to content

Commit

Permalink
End-to-end simple tests : replacing the scenario builder rule class f…
Browse files Browse the repository at this point in the history
…or BC group with a more generic one
  • Loading branch information
guilpier-code committed Jul 27, 2023
1 parent 42afd35 commit 30b8db5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ BOOST_AUTO_TEST_CASE(On_year_2__RHS_TS_number_2_is_taken_into_account)
bcRHStsConfig.fillColumnWith(0, bcGroupRHS1);
bcRHStsConfig.fillColumnWith(1, bcGroupRHS2);

ScenarioBuilderRule scenarioBuilderRule(study);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 0, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 1, 2);

BCgroupScenarioBuilder bcGroupScenarioBuilder(study);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 0, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 1, 1);

simulation->create();
playOnlyYear(1);
Expand All @@ -258,17 +258,20 @@ BOOST_AUTO_TEST_CASE(On_year_9__RHS_TS_number_4_is_taken_into_account)
bcRHStsConfig.fillColumnWith(5, 60.);
bcRHStsConfig.fillColumnWith(6, 70.);

BCgroupScenarioBuilder bcGroupScenarioBuilder(study);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 0, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 1, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 2, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 3, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 4, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 5, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 6, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 7, 0);
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 8, 3); // Here year 9
bcGroupScenarioBuilder.yearGetsTSnumber(BC->group(), 9, 0);
ScenarioBuilderRule scenarioBuilderRule(study);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 0, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 1, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 2, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 3, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 4, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 5, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 6, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 7, 1);
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 8, 4); // Here year 9
scenarioBuilderRule.bcGroup().setTSnumber(BC->group(), 9, 1);




simulation->create();
playOnlyYear(8);
Expand Down
34 changes: 9 additions & 25 deletions src/tests/end-to-end/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,34 +88,18 @@ averageResults OutputRetriever::thermalGeneration(ThermalCluster* cluster)
return averageResults((*result)[cluster->areaWideIndex].avgdata);
}

// --------------------------------------
// BC group TS number configuration
// --------------------------------------
BCgroupScenarioBuilder::BCgroupScenarioBuilder(Study::Ptr study)
: nbYears_(study->parameters.nbYears)
ScenarioBuilderRule::ScenarioBuilderRule(Study::Ptr study)
{
rules_ = createScenarioRules(study);
}

void BCgroupScenarioBuilder::yearGetsTSnumber(std::string groupName, unsigned int year, unsigned int TSnumber)
{
if (year >= nbYears_)
study->scenarioRulesCreate();
ScenarioBuilder::Sets* sets = study->scenarioRules;
if (sets && !sets->empty())
{
logs.fatal() << "BCgroupScenarioBuilder : year number must be < Nb of MC years";
AntaresSolverEmergencyShutdown();
}
rules_ = sets->createNew("Custom");

rules_->binding_constraints.setTSnumber(groupName, year, TSnumber + 1);
}


ScenarioBuilderRule::ScenarioBuilderRule(Study::Ptr study) :
nbYears_(study->parameters.nbYears)
{
rules_= createScenarioRules(study);
// load_(rules_->load),
// bcGroup_(rules_->binding_constraints)
}
study->parameters.useCustomScenario = true;
study->parameters.activeRulesScenario = "Custom";
}
}


// =====================
Expand Down
16 changes: 0 additions & 16 deletions src/tests/end-to-end/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,6 @@ OutputRetriever::retrieveResultsForThermalCluster(ThermalCluster* cluster)
return result;
}

// --------------------------------------
// BC group TS number configuration
// --------------------------------------
class BCgroupScenarioBuilder
{
public:
BCgroupScenarioBuilder() = delete;
BCgroupScenarioBuilder(Study::Ptr study);
void yearGetsTSnumber(std::string groupName, unsigned int year, unsigned int TSnumber);

private:
unsigned int nbYears_ = 0;
ScenarioBuilder::Rules::Ptr rules_;
};

ScenarioBuilder::Rules::Ptr createScenarioRules(Study::Ptr pStudy);

class ScenarioBuilderRule
Expand All @@ -146,7 +131,6 @@ class ScenarioBuilderRule
BindingConstraintsTSNumberData& bcGroup() { return rules_->binding_constraints; }

private:
unsigned int nbYears_ = 0;
Rules::Ptr rules_;
};

Expand Down

0 comments on commit 30b8db5

Please sign in to comment.