From 237940eac3151b1bf870ac64ceea9f44e55ac60f Mon Sep 17 00:00:00 2001 From: Guillaume PIERRE Date: Mon, 6 Jan 2025 15:02:11 +0100 Subject: [PATCH] New hydro remix : unit tests - renaming algorithm input data (part 2) --- .../solver/simulation/test-hydro-remix.cpp | 600 +++++++++--------- 1 file changed, 302 insertions(+), 298 deletions(-) diff --git a/src/tests/src/solver/simulation/test-hydro-remix.cpp b/src/tests/src/solver/simulation/test-hydro-remix.cpp index 43864313fc..43cc6c1a33 100644 --- a/src/tests/src/solver/simulation/test-hydro-remix.cpp +++ b/src/tests/src/solver/simulation/test-hydro-remix.cpp @@ -98,7 +98,7 @@ BOOST_FIXTURE_TEST_CASE(all_input_arrays_of_size_0__exception_raised, InputFixtu checkMessage("Remix hydro input : all arrays of sizes 0")); } -BOOST_FIXTURE_TEST_CASE(H_not_smaller_than_pmax__exception_raised, InputFixture<5>) +BOOST_FIXTURE_TEST_CASE(Hydro_gen_not_smaller_than_pmax__exception_raised, InputFixture<5>) { HydroGen = {1., 2., 3., 4., 5.}; HydroPmax = {2., 2., 2., 4., 5.}; @@ -122,7 +122,7 @@ BOOST_FIXTURE_TEST_CASE(H_not_smaller_than_pmax__exception_raised, InputFixture< checkMessage("Remix hydro input : Hydro generation not smaller than Pmax everywhere")); } -BOOST_FIXTURE_TEST_CASE(H_not_greater_than_pmin__exception_raised, InputFixture<5>) +BOOST_FIXTURE_TEST_CASE(Hydro_gen_not_greater_than_pmin__exception_raised, InputFixture<5>) { HydroGen = {1., 2., 3., 4., 5.}; HydroPmin = {0., 0., 4., 0., 0.}; @@ -165,8 +165,9 @@ BOOST_FIXTURE_TEST_CASE(input_is_acceptable__no_exception_raised, InputFixture<1 DTG_MRG)); } -BOOST_FIXTURE_TEST_CASE(hydro_increases_and_pmax_40mwh___H_is_flattened_to_mean_H_20mwh, - InputFixture<5>) +BOOST_FIXTURE_TEST_CASE( + hydro_increases_and_pmax_40mwh___Hydro_gen_is_flattened_to_mean_Hydro_gen_20mwh, + InputFixture<5>) { std::ranges::fill(HydroPmax, 40.); std::ranges::fill(ThermalGen, 100.); @@ -175,24 +176,24 @@ BOOST_FIXTURE_TEST_CASE(hydro_increases_and_pmax_40mwh___H_is_flattened_to_mean_ init_level = 500.; capacity = 1000.; - auto [new_H, new_D, _] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H = {20., 20., 20., 20., 20.}; + auto [OutHydroGen, OutUnsupE, _] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + std::vector expected_HydroGen = {20., 20., 20., 20., 20.}; // UnsupE such as ThermalGen + HydroGen + UnsupE remains flat - std::vector expected_D = {60., 50., 40., 30., 20.}; - BOOST_CHECK(new_H == expected_H); - BOOST_CHECK(new_D == expected_D); + std::vector expected_UnsupE = {60., 50., 40., 30., 20.}; + BOOST_CHECK(OutHydroGen == expected_HydroGen); + BOOST_CHECK(OutUnsupE == expected_UnsupE); } BOOST_FIXTURE_TEST_CASE(Pmax_does_not_impact_results_when_greater_than_40mwh, InputFixture<5>) @@ -204,28 +205,29 @@ BOOST_FIXTURE_TEST_CASE(Pmax_does_not_impact_results_when_greater_than_40mwh, In init_level = 500.; capacity = 1000.; - auto [new_H, new_D, _] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H = {20., 20., 20., 20., 20.}; + auto [OutHydroGen, OutUnsupE, _] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + std::vector expected_HydroGen = {20., 20., 20., 20., 20.}; // UnsupE such as ThermalGen + HydroGen + UnsupE remains constant at each hour - std::vector expected_D = {60., 50., 40., 30., 20.}; - BOOST_CHECK(new_H == expected_H); - BOOST_CHECK(new_D == expected_D); + std::vector expected_UnsupE = {60., 50., 40., 30., 20.}; + BOOST_CHECK(OutHydroGen == expected_HydroGen); + BOOST_CHECK(OutUnsupE == expected_UnsupE); } -BOOST_FIXTURE_TEST_CASE(hydro_decreases_and_pmax_40mwh___H_is_flattened_to_mean_H_20mwh, - InputFixture<5>) +BOOST_FIXTURE_TEST_CASE( + hydro_decreases_and_pmax_40mwh___Hydro_gen_is_flattened_to_mean_Hydro_gen_20mwh, + InputFixture<5>) { std::ranges::fill(HydroPmax, 40.); std::ranges::fill(ThermalGen, 100.); @@ -234,24 +236,24 @@ BOOST_FIXTURE_TEST_CASE(hydro_decreases_and_pmax_40mwh___H_is_flattened_to_mean_ init_level = 500.; capacity = 1000.; - auto [new_H, new_D, _] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H = {20., 20., 20., 20., 20.}; + auto [OutHydroGen, OutUnsupE, _] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + std::vector expected_HydroGen = {20., 20., 20., 20., 20.}; // UnsupE such as ThermalGen + HydroGen + UnsupE remains constant at each hour - std::vector expected_D = {20., 30., 40., 50., 60.}; - BOOST_CHECK(new_H == expected_H); - BOOST_CHECK(new_D == expected_D); + std::vector expected_UnsupE = {20., 30., 40., 50., 60.}; + BOOST_CHECK(OutHydroGen == expected_HydroGen); + BOOST_CHECK(OutUnsupE == expected_UnsupE); } BOOST_FIXTURE_TEST_CASE(influence_of_pmax, InputFixture<5>, *boost::unit_test::tolerance(0.01)) @@ -267,42 +269,42 @@ BOOST_FIXTURE_TEST_CASE(influence_of_pmax, InputFixture<5>, *boost::unit_test::t // 1. Algorithm tends to flatten ThermalGen + HydroGen, so it would require HydroGen to // increase. Proof : - auto [new_H1, new_D1, L] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H1 = {0., 0., 13.33, 33.33, 53.33}; - BOOST_TEST(new_H1 == expected_H1, boost::test_tools::per_element()); + auto [OutHydroGen_1, new_D1, L] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + std::vector expected_HydroGen_1 = {0., 0., 13.33, 33.33, 53.33}; + BOOST_TEST(OutHydroGen_1 == expected_HydroGen_1, boost::test_tools::per_element()); // 2. But HydroGen is limited by HydroPmax. So Algo does nothing in the end. // Proof : HydroPmax = {20., 20., 20., 20., 20.}; - auto [new_H2, new_D2, _] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H2 = {20., 20., 20., 20., 20.}; - std::vector expected_D2 = {50., 50., 50., 50., 50.}; - BOOST_CHECK(new_H2 == expected_H2); - BOOST_CHECK(new_D2 == expected_D2); + auto [OutHydroGen_2, OutUnsupE_2, _] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + std::vector expected_HydroGen_2 = {20., 20., 20., 20., 20.}; + std::vector expected_UnsupE_2 = {50., 50., 50., 50., 50.}; + BOOST_CHECK(OutHydroGen_2 == expected_HydroGen_2); + BOOST_CHECK(OutUnsupE_2 == expected_UnsupE_2); } BOOST_FIXTURE_TEST_CASE(influence_of_pmin, InputFixture<5>, *boost::unit_test::tolerance(0.01)) @@ -318,43 +320,43 @@ BOOST_FIXTURE_TEST_CASE(influence_of_pmin, InputFixture<5>, *boost::unit_test::t // 1. Algorithm tends to flatten ThermalGen + HydroGen, so it would require HydroGen to // increase. - auto [new_H1, new_D1, L] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - std::vector expected_H1 = {0., 0., 13.33, 33.33, 53.33}; - BOOST_TEST(new_H1 == expected_H1, boost::test_tools::per_element()); + auto [OutHydroGen_1, new_D1, L] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + std::vector expected_HydroGen_1 = {0., 0., 13.33, 33.33, 53.33}; + BOOST_TEST(OutHydroGen_1 == expected_HydroGen_1, boost::test_tools::per_element()); // 2. But HydroGen is low bounded by HydroPmin. So Algo does nothing in the end. HydroPmin = {20., 20., 20., 20., 20.}; - auto [new_H2, new_D2, _] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H2 = {20., 20., 20., 20., 20.}; - std::vector expected_D2 = {50., 50., 50., 50., 50.}; - BOOST_CHECK(new_H2 == expected_H2); - BOOST_CHECK(new_D2 == expected_D2); + auto [OutHydroGen_2, OutUnsupE_2, _] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + std::vector expected_HydroGen_2 = {20., 20., 20., 20., 20.}; + std::vector expected_UnsupE_2 = {50., 50., 50., 50., 50.}; + BOOST_CHECK(OutHydroGen_2 == expected_HydroGen_2); + BOOST_CHECK(OutUnsupE_2 == expected_UnsupE_2); } -BOOST_FIXTURE_TEST_CASE(H_is_already_flat___remix_is_useless__level_easily_computed, +BOOST_FIXTURE_TEST_CASE(Hydro_gen_is_already_flat___remix_is_useless__level_easily_computed, InputFixture<5>) { init_level = 500.; @@ -363,18 +365,18 @@ BOOST_FIXTURE_TEST_CASE(H_is_already_flat___remix_is_useless__level_easily_compu std::ranges::fill(inflows, 15.); // Cause levels to increase std::ranges::fill(pump, 10.); // Cause levels to increase - auto [new_H, new_D, levels] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); + auto [OutHydroGen, OutUnsupE, levels] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); std::vector expected_levels = {480., 460., 440., 420., 400.}; BOOST_TEST(levels == expected_levels, boost::test_tools::per_element()); @@ -446,48 +448,49 @@ BOOST_FIXTURE_TEST_CASE(influence_of_capacity_on_algorithm___case_where_no_influ inflows = {25., 25., 25., 25., 25., 5., 5., 5., 5., 5.}; init_level = 100.; // HydroGen and inflows result in : input_levels = {115, 120, 135, 140, 155, 140, 135, 120, 115, - // 100} Note sup(input_levels) = 155 + // 100} + // Note that : sup(input_levels) = 155 // Case 1 : capacity relaxed (infinite by default) ==> leads to optimal solution (HydroGen is // flat) - auto [new_H, new_D, L] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H(10, - 15.); // HydroGen is flat and is 15. (means of initial HydroGen) + auto [OutHydroGen, OutUnsupE, L] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + // HydroGen is flat and is 15. (means of initial HydroGen) + std::vector expected_HydroGen(10, 15.); // Levels associated to new HydroGen are such as sup(L) = 150. < sup(input_levels) = 155 std::vector expected_L = {110., 120., 130., 140., 150., 140., 130., 120., 110., 100.}; - BOOST_TEST(new_H == expected_H, boost::test_tools::per_element()); + BOOST_TEST(OutHydroGen == expected_HydroGen, boost::test_tools::per_element()); BOOST_TEST(L == expected_L, boost::test_tools::per_element()); // Case 2 : now, if we lower capacity to sup(input_levels) = 155, we should // have HydroGen and L identical to previously : this value of capacity should // not have an influence on HydroGen and levels as results of the algorithm. capacity = 155.; - auto [new_H2, new_D2, L2] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - BOOST_TEST(new_H2 == expected_H, boost::test_tools::per_element()); + auto [OutHydroGen_2, OutUnsupE_2, L2] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + BOOST_TEST(OutHydroGen_2 == expected_HydroGen, boost::test_tools::per_element()); BOOST_TEST(L2 == expected_L, boost::test_tools::per_element()); } @@ -509,24 +512,24 @@ BOOST_FIXTURE_TEST_CASE(lowering_capacity_too_low_leads_to_suboptimal_solution_f // Case 1 : capacity relaxed (infinite by default) ==> leads to optimal solution (HydroGen is // flat) - auto [new_H, new_D, L] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H(10, - 15.); // HydroGen is flat and is 15. (means of initial HydroGen) + auto [OutHydroGen, OutUnsupE, L] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + // HydroGen is flat and is 15. (means of initial HydroGen) + std::vector expected_HydroGen(10, 15.); // Levels associated to new HydroGen are such as sup(L) = 150. > sup(input_levels) = 145 std::vector expected_L = {110., 120., 130., 140., 150., 140., 130., 120., 110., 100.}; - BOOST_TEST(new_H == expected_H, boost::test_tools::per_element()); + BOOST_TEST(OutHydroGen == expected_HydroGen, boost::test_tools::per_element()); BOOST_TEST(L == expected_L, boost::test_tools::per_element()); // Case 2 : we lower capacity to sup(input_levels) = 145. @@ -536,22 +539,22 @@ BOOST_FIXTURE_TEST_CASE(lowering_capacity_too_low_leads_to_suboptimal_solution_f // was infinite. Therefore, solution found is suboptimal : we expect to get an // output HydroGen flat by interval, not flat on the whole domain. capacity = 145.; - auto [new_H2, new_D2, L2] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - // new_H2 is flat by interval - std::vector expected_H2 = {16., 16., 16., 16., 16., 14., 14., 14., 14., 14.}; - BOOST_TEST(new_H2 == expected_H2, boost::test_tools::per_element()); + auto [OutHydroGen_2, OutUnsupE_2, L2] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + // OutHydroGen_2 is flat by interval + std::vector expected_HydroGen_2 = {16., 16., 16., 16., 16., 14., 14., 14., 14., 14.}; + BOOST_TEST(OutHydroGen_2 == expected_HydroGen_2, boost::test_tools::per_element()); } BOOST_FIXTURE_TEST_CASE(lowering_initial_level_too_low_leads_to_suboptimal_solution_for_GplusH, @@ -572,48 +575,48 @@ BOOST_FIXTURE_TEST_CASE(lowering_initial_level_too_low_leads_to_suboptimal_solut // Case 1 : init level (== 100) is high enough so that input levels (computed from input data) // are acceptable for algorithm (input levels >= 0.), and running algorithm leads to optimal - // solution (new_H is flat) - auto [new_H, new_D, L] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H(10, - 25.); // HydroGen is flat and is 25. (means of initial HydroGen) + // solution (OutHydroGen is flat) + auto [OutHydroGen, OutUnsupE, L] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + // HydroGen is flat and is 25. (means of initial HydroGen) + std::vector expected_HydroGen(10, 25.); // Levels associated to new HydroGen are such as inf(L) = 0. > inf(input_levels) = 5 std::vector expected_L = {80., 60., 40., 20., 0., 20., 40., 60., 80., 100.}; - BOOST_TEST(new_H == expected_H, boost::test_tools::per_element()); + BOOST_TEST(OutHydroGen == expected_HydroGen, boost::test_tools::per_element()); BOOST_TEST(L == expected_L, boost::test_tools::per_element()); // Case 2 : we lower initial level. Input data are still acceptable // for algorithm (despite the new init level), algorithm will have to take the levels lower - // bound (0.) into account. As the levels change, the solution new_H will be suboptimal, that is - // flat by interval (not flat on the whole domain). + // bound (0.) into account. As the levels change, the solution OutHydroGen will be suboptimal, + // that is flat by interval (not flat on the whole domain). init_level = 95.; - auto [new_H2, new_D2, L2] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - // new_H2 is flat by interval - std::vector expected_H2 = {24., 24., 24., 24., 24., 26., 26., 26., 26., 26.}; - BOOST_TEST(new_H2 == expected_H2, boost::test_tools::per_element()); + auto [OutHydroGen_2, OutUnsupE_2, L2] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + // OutHydroGen_2 is flat by interval + std::vector expected_HydroGen_2 = {24., 24., 24., 24., 24., 26., 26., 26., 26., 26.}; + BOOST_TEST(OutHydroGen_2 == expected_HydroGen_2, boost::test_tools::per_element()); } BOOST_FIXTURE_TEST_CASE(influence_of_initial_level_on_algorithm___case_where_no_influence, @@ -632,48 +635,48 @@ BOOST_FIXTURE_TEST_CASE(influence_of_initial_level_on_algorithm___case_where_no_ // Case 1 : init level (== 100) is high enough so that input levels (computed from input data) // are acceptable by algorithm, and levels computed by algorithm (output) are optimal, that - // is computed from a optimal (that is flat) new_H. - auto [new_H, new_D, L] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H(10, - 15.); // HydroGen is flat and is 15. (means of initial HydroGen) + // is computed from a optimal (that is flat) OutHydroGen. + auto [OutHydroGen, OutUnsupE, L] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + // HydroGen is flat and is 15. (means of initial HydroGen) + std::vector expected_HydroGen(10, 15.); // Levels associated to new HydroGen are such as inf(L) = 50 > inf(input_levels) = 45 std::vector expected_L = {90., 80., 70., 60., 50., 60., 70., 80., 90., 100.}; - BOOST_TEST(new_H == expected_H, boost::test_tools::per_element()); + BOOST_TEST(OutHydroGen == expected_HydroGen, boost::test_tools::per_element()); BOOST_TEST(L == expected_L, boost::test_tools::per_element()); // Case 2 : now we lower initial level down to 55. // In this way, input data is still acceptable for algorithm // and algorithm won't have to take the levels lower bound (0.) into account. - // The solution new_H will be optimal, that is flat by interval. + // The solution OutHydroGen will be optimal, that is flat by interval. init_level = 55.; - auto [new_H2, new_D2, L2] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - // new_H2 is flat (and optimal) - std::vector expected_H2(10, 15.); - BOOST_TEST(new_H2 == expected_H2, boost::test_tools::per_element()); + auto [OutHydroGen_2, OutUnsupE_2, L2] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + // OutHydroGen_2 is flat (and optimal) + std::vector expected_HydroGen_2(10, 15.); + BOOST_TEST(OutHydroGen_2 == expected_HydroGen_2, boost::test_tools::per_element()); } BOOST_FIXTURE_TEST_CASE(spillage_positive_at_hour_0___no_change_at_this_hour, InputFixture<5>) @@ -688,21 +691,21 @@ BOOST_FIXTURE_TEST_CASE(spillage_positive_at_hour_0___no_change_at_this_hour, In // But : Spillage[0] = 1.; // Now, we expect no change for HydroGen at hour 0 - auto [new_H, __, _] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); + auto [OutHydroGen, __, _] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); - std::vector expected_H = {40., 15., 15., 15., 15.}; - BOOST_CHECK(new_H == expected_H); + std::vector expected_HydroGen = {40., 15., 15., 15., 15.}; + BOOST_CHECK(OutHydroGen == expected_HydroGen); } BOOST_FIXTURE_TEST_CASE(DTG_MRG_positive_on_hour_4___no_change_at_this_hour, InputFixture<5>) @@ -717,21 +720,21 @@ BOOST_FIXTURE_TEST_CASE(DTG_MRG_positive_on_hour_4___no_change_at_this_hour, Inp // But : DTG_MRG[4] = 1.; // Now, we expect no change for HydroGen at hour 4 - auto [new_H, new_D, L] = new_remix_hydro(ThermalGen, - HydroGen, - UnsupE, - HydroPmax, - HydroPmin, - init_level, - capacity, - inflows, - ovf, - pump, - Spillage, - DTG_MRG); - - std::vector expected_H = {25., 25., 25., 25., 0.}; - BOOST_CHECK(new_H == expected_H); + auto [OutHydroGen, OutUnsupE, L] = new_remix_hydro(ThermalGen, + HydroGen, + UnsupE, + HydroPmax, + HydroPmin, + init_level, + capacity, + inflows, + ovf, + pump, + Spillage, + DTG_MRG); + + std::vector expected_HydroGen = {25., 25., 25., 25., 0.}; + BOOST_CHECK(OutHydroGen == expected_HydroGen); } // Ideas for building further tests : @@ -746,9 +749,10 @@ BOOST_FIXTURE_TEST_CASE(DTG_MRG_positive_on_hour_4___no_change_at_this_hour, Inp // Possible simplifications / clarifications of the algorithm itself : // - remove french from variable names // - the algo is flat, it's C (not C++), it should be divided in a small number of steps -// - max_pic is an up hydro production margin (H_up_mrg) -// - max_creux is a down hydro production margin (H_down_mrg) -// - an iter updates new_H : it's its main job. So new_D could be updated from new_H at the +// - max_pic is an up hydro production margin (Hydro_gen_up_mrg) +// - max_creux is a down hydro production margin (Hydro_gen_down_mrg) +// - an iter updates OutHydroGen : it's its main job. So OutUnsupE could be updated from OutHydroGen +// at the // end of an iteration, separately. // - they are 3 while loops. 2 loops should be enough (the iteration loop and -// another one simply updating new_H and new_D) +// another one simply updating OutHydroGen and OutUnsupE)