diff --git a/src/expressions/visitors/EvalVisitor.cpp b/src/expressions/visitors/EvalVisitor.cpp index bdad7102a7..e3e36aa95c 100644 --- a/src/expressions/visitors/EvalVisitor.cpp +++ b/src/expressions/visitors/EvalVisitor.cpp @@ -109,11 +109,10 @@ EvaluationResult EvalVisitor::visit(const Nodes::ParameterNode* node) timeStep <= dataSeriesKeys_.fillContext.getLastTimeStep(); ++timeStep) { - params.emplace_back( - context_.getParameterValue(context_.getSystemParameterValue(node->value()), - dataSeriesKeys_.scenarioGroup, - dataSeriesKeys_.scenario, - timeStep)); + params.emplace_back(context_.getParameterValue(node->value(), + dataSeriesKeys_.scenarioGroup, + dataSeriesKeys_.scenario, + timeStep)); } return EvaluationResult{params}; } diff --git a/src/io/inputs/yml-system/converter.cpp b/src/io/inputs/yml-system/converter.cpp index ae860d1b70..cef0342fc0 100644 --- a/src/io/inputs/yml-system/converter.cpp +++ b/src/io/inputs/yml-system/converter.cpp @@ -103,14 +103,14 @@ static SystemModel::Component createComponent(const YmlSystem::Component& c, // TODO we need type std::map parameters; - for (const auto& [id, type, value]: c.parameters) + for (const auto& [id, time_dependent, scenario_dependent, value]: c.parameters) { parameters.try_emplace(id, Expressions::Visitors::ContextParameter{ .id = id, - .type = type == "constant" // TODO apply tolower ? - ? Expressions::Visitors::ParameterType::CONSTANT - : Expressions::Visitors::ParameterType::TIMESERIE, + .type = time_dependent + ? Expressions::Visitors::ParameterType::TIMESERIE + : Expressions::Visitors::ParameterType::CONSTANT, .value = value}); } diff --git a/src/io/inputs/yml-system/decoders.hxx b/src/io/inputs/yml-system/decoders.hxx index f999df7004..f116c3c894 100644 --- a/src/io/inputs/yml-system/decoders.hxx +++ b/src/io/inputs/yml-system/decoders.hxx @@ -55,7 +55,8 @@ struct convert return false; } rhs.id = node["id"].as(); - rhs.type = node["type"].as(); + rhs.time_dependent = node["time-dependent"].as(); + rhs.scenario_dependent = node["scenario-dependent"].as(); rhs.value = node["value"].as(); return true; } diff --git a/src/io/inputs/yml-system/include/antares/io/inputs/yml-system/system.h b/src/io/inputs/yml-system/include/antares/io/inputs/yml-system/system.h index d041326828..9c7b2d3cdf 100644 --- a/src/io/inputs/yml-system/include/antares/io/inputs/yml-system/system.h +++ b/src/io/inputs/yml-system/include/antares/io/inputs/yml-system/system.h @@ -30,7 +30,8 @@ namespace Antares::IO::Inputs::YmlSystem struct Parameter { std::string id; - std::string type; + bool time_dependent; + bool scenario_dependent; std::string value; }; diff --git a/src/solver/modeler/main.cpp b/src/solver/modeler/main.cpp index 87607385ee..968747b8a1 100644 --- a/src/solver/modeler/main.cpp +++ b/src/solver/modeler/main.cpp @@ -30,8 +30,6 @@ #include #include #include -#include "antares/optimisation/linear-problem-api/linearProblem.h" -#include "antares/optimisation/linear-problem-data-impl/timeSeriesSet.h" using namespace Antares::Optimisation::LinearProblemMpsolverImpl; using namespace Antares; @@ -67,13 +65,9 @@ class SystemLinearProblem LinearProblemBuilder linear_problem_builder(fillers_ptr); LinearProblemData data(dataSeriesRepo); - // const auto number_of_timeStep = parameters.lastTimeStep - parameters.firstTimeStep + 1; - // std::vector timeSteps(number_of_timeStep); - // std::ranges::generate(timeSteps, [i = parameters.firstTimeStep]() mutable { return i++; - // }); - FillContext dummy_time_scenario_ctx = {parameters.firstTimeStep, parameters.lastTimeStep}; linear_problem_builder.build(pb, data, dummy_time_scenario_ctx); + } private: diff --git a/src/tests/cucumber/features/modeler-features/epic2/us2.8.feature b/src/tests/cucumber/features/modeler-features/epic2/us2.8.feature new file mode 100644 index 0000000000..af0257f416 --- /dev/null +++ b/src/tests/cucumber/features/modeler-features/epic2/us2.8.feature @@ -0,0 +1,9 @@ +Feature: 2.8 + + Scenario: 2.8.1: One model with one load and two generators, one timestep + Given the study path is "modeler/1_1" + When I run antares modeler + Then the simulation succeeds + And the objective value is 160 + And the optimal value of variable node1.gen1_p_0 is 80 + And the optimal value of variable node1.gen2_p_0 is 20 \ No newline at end of file diff --git a/src/tests/resources/modeler/1_1/input/data-series/gen1_max_p_1_1.tsv b/src/tests/resources/modeler/1_1/input/data-series/gen1_max_p_1_1.tsv new file mode 100644 index 0000000000..d15a2cc44e --- /dev/null +++ b/src/tests/resources/modeler/1_1/input/data-series/gen1_max_p_1_1.tsv @@ -0,0 +1 @@ +80 diff --git a/src/tests/resources/modeler/1_1/input/data-series/gen1_prop_cost_1_1.tsv b/src/tests/resources/modeler/1_1/input/data-series/gen1_prop_cost_1_1.tsv new file mode 100644 index 0000000000..2eb3c4fe4e --- /dev/null +++ b/src/tests/resources/modeler/1_1/input/data-series/gen1_prop_cost_1_1.tsv @@ -0,0 +1 @@ +0.5 diff --git a/src/tests/resources/modeler/1_1/input/data-series/gen2_max_p_1_1.tsv b/src/tests/resources/modeler/1_1/input/data-series/gen2_max_p_1_1.tsv new file mode 100644 index 0000000000..08839f6bb2 --- /dev/null +++ b/src/tests/resources/modeler/1_1/input/data-series/gen2_max_p_1_1.tsv @@ -0,0 +1 @@ +200 diff --git a/src/tests/resources/modeler/1_1/input/data-series/gen2_prop_cost_1_1.tsv b/src/tests/resources/modeler/1_1/input/data-series/gen2_prop_cost_1_1.tsv new file mode 100644 index 0000000000..1e8b314962 --- /dev/null +++ b/src/tests/resources/modeler/1_1/input/data-series/gen2_prop_cost_1_1.tsv @@ -0,0 +1 @@ +6 diff --git a/src/tests/resources/modeler/1_1/input/data-series/load_1_1.tsv b/src/tests/resources/modeler/1_1/input/data-series/load_1_1.tsv new file mode 100644 index 0000000000..29d6383b52 --- /dev/null +++ b/src/tests/resources/modeler/1_1/input/data-series/load_1_1.tsv @@ -0,0 +1 @@ +100 diff --git a/src/tests/resources/modeler/1_1/input/model-libraries/lib_example_1_1.yml b/src/tests/resources/modeler/1_1/input/model-libraries/lib_example_1_1.yml new file mode 100644 index 0000000000..7394fbe2b1 --- /dev/null +++ b/src/tests/resources/modeler/1_1/input/model-libraries/lib_example_1_1.yml @@ -0,0 +1,36 @@ +library: + id: lib_example_1_1 + description: test model library + + models: + - id: node_2gen_1load + description: A simple node with two generators and one load + parameters: + - id: load + time-dependent: true + scenario-dependent: false + - id: gen1_max_p + time-dependent: true + scenario-dependent: false + - id: gen1_prop_cost + time-dependent: true + scenario-dependent: false + - id: gen2_max_p + time-dependent: true + scenario-dependent: false + - id: gen2_prop_cost + time-dependent: true + scenario-dependent: false + variables: + - id: gen1_p + lower-bound: 0 + upper-bound: gen1_max_p + variable-type: continuous + - id: gen2_p + lower-bound: 0 + upper-bound: gen2_max_p + variable-type: continuous + constraints: + - id: balance + expression: gen1_p + gen2_p - load = 0 + objective: gen1_p * gen1_prop_cost + gen2_p * gen2_prop_cost diff --git a/src/tests/resources/modeler/1_1/input/system.yml b/src/tests/resources/modeler/1_1/input/system.yml new file mode 100644 index 0000000000..cfc335f91d --- /dev/null +++ b/src/tests/resources/modeler/1_1/input/system.yml @@ -0,0 +1,30 @@ +system: + id: sys_example_1_1 + description: test system + model-libraries: lib_example_1_1 + + components: + - id: node1 + model: lib_example_1_1.node_2gen_1load + scenario-group: sg + parameters: + - id: load + time-dependent: true + scenario-dependent: false + value: load_1_1 + - id: gen1_max_p + time-dependent: true + scenario-dependent: false + value: gen1_max_p_1_1 + - id: gen1_prop_cost + time-dependent: true + scenario-dependent: false + value: gen1_prop_cost_1_1 + - id: gen2_max_p + time-dependent: true + scenario-dependent: false + value: gen2_max_p_1_1 + - id: gen2_prop_cost + time-dependent: true + scenario-dependent: false + value: gen2_prop_cost_1_1 diff --git a/src/tests/resources/modeler/1_1/parameters.yml b/src/tests/resources/modeler/1_1/parameters.yml new file mode 100644 index 0000000000..f18ec9b81c --- /dev/null +++ b/src/tests/resources/modeler/1_1/parameters.yml @@ -0,0 +1,6 @@ +solver: xpress +solver-logs: true +solver-parameters: THREADS 1 +no-output: false +first-time-step: 0 +last-time-step: 0 \ No newline at end of file diff --git a/src/tests/resources/modeler/epic2/us2.5/study_2.5.1/input/system.yml b/src/tests/resources/modeler/epic2/us2.5/study_2.5.1/input/system.yml index 59dd3cd791..6c85aaa3c1 100644 --- a/src/tests/resources/modeler/epic2/us2.5/study_2.5.1/input/system.yml +++ b/src/tests/resources/modeler/epic2/us2.5/study_2.5.1/input/system.yml @@ -10,17 +10,22 @@ system: scenario-group: sg parameters: - id: load - type: constant + time-dependent: false + scenario-dependent: false value: 100 - id: gen1_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 80 - id: gen1_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 0.5 - id: gen2_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 200 - id: gen2_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 6 diff --git a/src/tests/resources/modeler/epic2/us2.5/study_2.5.2/input/system.yml b/src/tests/resources/modeler/epic2/us2.5/study_2.5.2/input/system.yml index 20ae8fe82f..9aefadcf17 100644 --- a/src/tests/resources/modeler/epic2/us2.5/study_2.5.2/input/system.yml +++ b/src/tests/resources/modeler/epic2/us2.5/study_2.5.2/input/system.yml @@ -11,23 +11,30 @@ system: scenario-group: sg parameters: - id: load - type: constant + time-dependent: false + scenario-dependent: false value: 100 - id: gen1_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 80 - id: gen1_min_p - type: constant + time-dependent: false + scenario-dependent: false value: 1 - id: gen1_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 0.5 - id: gen2_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 200 - id: gen2_min_p - type: constant + time-dependent: false + scenario-dependent: false value: 40 - id: gen2_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 6 diff --git a/src/tests/resources/modeler/epic2/us2.5/study_2.5.3/input/system.yml b/src/tests/resources/modeler/epic2/us2.5/study_2.5.3/input/system.yml index aed39a3a05..31b512bcca 100644 --- a/src/tests/resources/modeler/epic2/us2.5/study_2.5.3/input/system.yml +++ b/src/tests/resources/modeler/epic2/us2.5/study_2.5.3/input/system.yml @@ -14,19 +14,24 @@ system: scenario-group: sg parameters: - id: load - type: constant + time-dependent: false + scenario-dependent: false value: 100 - id: gen1_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 80 - id: gen1_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 60 - id: gen2_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 200 - id: gen2_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 6 - id: node2 @@ -34,23 +39,30 @@ system: scenario-group: sg parameters: - id: load - type: constant + time-dependent: false + scenario-dependent: false value: 1000 - id: gen1_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 650 - id: gen1_min_p - type: constant + time-dependent: false + scenario-dependent: false value: 200 - id: gen1_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 10 - id: gen2_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 1000 - id: gen2_min_p - type: constant + time-dependent: false + scenario-dependent: false value: 500 - id: gen2_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 20 diff --git a/src/tests/resources/modeler/epic2/us2.5/study_2.5.4/input/system.yml b/src/tests/resources/modeler/epic2/us2.5/study_2.5.4/input/system.yml index ff4210e6fe..06f40ea0ff 100644 --- a/src/tests/resources/modeler/epic2/us2.5/study_2.5.4/input/system.yml +++ b/src/tests/resources/modeler/epic2/us2.5/study_2.5.4/input/system.yml @@ -10,20 +10,26 @@ system: scenario-group: sg parameters: - id: load - type: constant + time-dependent: false + scenario-dependent: false value: 1000 - id: gen_min_p - type: constant + time-dependent: false + scenario-dependent: false value: 150 - id: gen_max_p - type: constant + time-dependent: false + scenario-dependent: false value: 300 - id: gen_cluster_size - type: constant + time-dependent: false + scenario-dependent: false value: 10 - id: gen_prop_cost - type: constant + time-dependent: false + scenario-dependent: false value: 0.5 - id: gen_fixed_cost - type: constant + time-dependent: false + scenario-dependent: false value: 10 diff --git a/src/tests/src/io/yml-importers/testSystemConverter.cpp b/src/tests/src/io/yml-importers/testSystemConverter.cpp index 373163d167..fbae00b457 100644 --- a/src/tests/src/io/yml-importers/testSystemConverter.cpp +++ b/src/tests/src/io/yml-importers/testSystemConverter.cpp @@ -72,7 +72,8 @@ BOOST_FIXTURE_TEST_CASE(full_model_system, LibraryObjects) scenario-group: group-234 parameters: - id: cost - type: constant + time-dependent: false + scenario-dependent: false value: 30 )"s; @@ -99,7 +100,8 @@ BOOST_FIXTURE_TEST_CASE(bad_param_name_in_component, LibraryObjects) scenario-group: group-234 parameters: - id: param_not_in_model - type: constant + time-dependent: false + scenario-dependent: false value: 30 )"s; @@ -154,7 +156,8 @@ BOOST_FIXTURE_TEST_CASE(bad_library_model_format, LibraryObjects) scenario-group: group-234 parameters: - id: cost - type: constant + time-dependent: false + scenario-dependent: false value: 30 )"s; @@ -242,10 +245,12 @@ BOOST_AUTO_TEST_CASE(Full_system_test) scenario-group: group-234 parameters: - id: cost - type: constant + time-dependent: false + scenario-dependent: false value: 30 - id: p_max - type: constant + time-dependent: false + scenario-dependent: false value: 100 - id: D @@ -253,7 +258,8 @@ BOOST_AUTO_TEST_CASE(Full_system_test) scenario-group: group-qsf parameters: - id: demand - type: constant + time-dependent: false + scenario-dependent: false value: 100 )"s; diff --git a/src/tests/src/io/yml-importers/testYmlSystem.cpp b/src/tests/src/io/yml-importers/testYmlSystem.cpp index 38424e9cde..de56f5e387 100644 --- a/src/tests/src/io/yml-importers/testYmlSystem.cpp +++ b/src/tests/src/io/yml-importers/testYmlSystem.cpp @@ -149,7 +149,8 @@ BOOST_AUTO_TEST_CASE(component_parameter) YmlSystem::System systemObj = parser.parse(system); const auto& param = systemObj.components[0].parameters[0]; BOOST_CHECK_EQUAL(param.id, "cost"); - BOOST_CHECK_EQUAL(param.type, "constant"); + BOOST_CHECK_EQUAL(param.time_dependent, false); + BOOST_CHECK_EQUAL(param.scenario_dependent, false); BOOST_CHECK_EQUAL(std::stod(param.value), 30); } @@ -166,19 +167,23 @@ BOOST_AUTO_TEST_CASE(component_two_parameters) scenario-group: group-234 parameters: - id: cost - type: constant + time-dependent: false + scenario-dependent: false value: 30 - id: p_max - type: constant + time-dependent: false + scenario-dependent: false value: 100 )"s; YmlSystem::System systemObj = parser.parse(system); const auto& param = systemObj.components[0].parameters[0]; const auto& param2 = systemObj.components[0].parameters[1]; BOOST_CHECK_EQUAL(param.id, "cost"); - BOOST_CHECK_EQUAL(param.type, "constant"); + BOOST_CHECK_EQUAL(param.time_dependent, false); + BOOST_CHECK_EQUAL(param.scenario_dependent, false); BOOST_CHECK_EQUAL(std::stod(param.value), 30); BOOST_CHECK_EQUAL(param2.id, "p_max"); - BOOST_CHECK_EQUAL(param2.type, "constant"); + BOOST_CHECK_EQUAL(param2.time_dependent, false); + BOOST_CHECK_EQUAL(param2.scenario_dependent, false); BOOST_CHECK_EQUAL(std::stod(param2.value), 100); }