From 30b8db541547c9bf250d542baffda2b3760b81a0 Mon Sep 17 00:00:00 2001 From: Guillaume PIERRE Date: Thu, 27 Jul 2023 11:15:16 +0200 Subject: [PATCH] End-to-end simple tests : replacing the scenario builder rule class for BC group with a more generic one --- .../test_binding_constraints.cpp | 31 +++++++++-------- src/tests/end-to-end/utils/utils.cpp | 34 +++++-------------- src/tests/end-to-end/utils/utils.h | 16 --------- 3 files changed, 26 insertions(+), 55 deletions(-) diff --git a/src/tests/end-to-end/binding_constraints/test_binding_constraints.cpp b/src/tests/end-to-end/binding_constraints/test_binding_constraints.cpp index dc5baa7f12..627b2ac73e 100644 --- a/src/tests/end-to-end/binding_constraints/test_binding_constraints.cpp +++ b/src/tests/end-to-end/binding_constraints/test_binding_constraints.cpp @@ -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); @@ -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); diff --git a/src/tests/end-to-end/utils/utils.cpp b/src/tests/end-to-end/utils/utils.cpp index e96e9373a4..7188139160 100644 --- a/src/tests/end-to-end/utils/utils.cpp +++ b/src/tests/end-to-end/utils/utils.cpp @@ -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"; + } + } // ===================== diff --git a/src/tests/end-to-end/utils/utils.h b/src/tests/end-to-end/utils/utils.h index 4d83313a7f..64d6725bb1 100644 --- a/src/tests/end-to-end/utils/utils.h +++ b/src/tests/end-to-end/utils/utils.h @@ -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 @@ -146,7 +131,6 @@ class ScenarioBuilderRule BindingConstraintsTSNumberData& bcGroup() { return rules_->binding_constraints; } private: - unsigned int nbYears_ = 0; Rules::Ptr rules_; };