-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,292 @@ | ||
|
||
//BOOST_AUTO_TEST_SUITE_END() | ||
//; | ||
// | ||
// | ||
//// Mock CORRESPONDANCES_DES_VARIABLES (dummy implementation for example purposes) | ||
//struct CORRESPONDANCES_DES_VARIABLES | ||
//{ | ||
// // Define the structure as needed for your tests | ||
//}; | ||
// | ||
|
||
// | ||
//BOOST_AUTO_TEST_CASE(Test_ShortTermStorageCumulation) | ||
//{ | ||
// // Mock ConstraintBuilderData | ||
// ConstraintBuilderData data =InitializeMockData(); | ||
// | ||
// // Mock ConstraintBuilder | ||
// ConstraintBuilder builder(data); | ||
// | ||
// // Mock ConstraintNamer with the target name vector | ||
// std::vector<std::string> targetNames; | ||
// ConstraintNamer namer(targetNames); | ||
// | ||
// // Mock ShortTermStorageCumulativeConstraintData | ||
// std::vector<int> empty; | ||
// std::vector<int> CorrespondancesShortTermStorageCumulation; | ||
// ShortTermStorageCumulativeConstraintData cumulativeData = { | ||
// | ||
// empty, | ||
// CorrespondancesShortTermStorageCumulation | ||
// | ||
// }; | ||
// | ||
// // Mock ShortTermStorageCumulation | ||
// ShortTermStorageCumulation cumulation(builder, cumulativeData); | ||
// | ||
// // Define test data | ||
// int areaIndex = 0; // Example area index | ||
// ShortTermStorage::ShortTermStorageCluster mockStorageCluster; | ||
// mockStorageCluster.clusterGlobalIndex = 0; | ||
// mockStorageCluster.name = "ClusterA"; | ||
// | ||
// // Create and populate AdditionalConstraints | ||
// ShortTermStorage::AdditionalConstraints additionalConstraints; | ||
// additionalConstraints.name = "TestConstraint"; | ||
// additionalConstraints.variable = "injection"; | ||
// additionalConstraints.operatorType = "less"; | ||
// additionalConstraints.rhs = {10.0, 20.0, 30.0}; // Example RHS values | ||
// | ||
// // Create and populate SingleAdditionalConstraint | ||
// SingleAdditionalConstraint singleConstraint; | ||
// singleConstraint.hours = {1, 2, 3}; | ||
// singleConstraint.globalIndex = 1; | ||
// singleConstraint.localIndex = 0; | ||
// | ||
// // Add the single constraint to additionalConstraints | ||
// additionalConstraints.constraints.push_back(singleConstraint); | ||
// | ||
// // Validate the additional constraints | ||
// auto validationResult = additionalConstraints.validate(); | ||
// BOOST_CHECK(validationResult.ok); | ||
// | ||
// mockStorageCluster.additional_constraints.push_back(additionalConstraints); | ||
// cumulativeData.ShortTermStorage.push_back(mockStorageCluster); | ||
// | ||
// // Update namer for the area | ||
// namer.UpdateArea("France"); | ||
// | ||
// // Add the constraints | ||
// BOOST_CHECK_NO_THROW(cumulation.add(areaIndex)); | ||
// | ||
// // Check constraints were properly added | ||
// BOOST_CHECK_EQUAL(data.nombreDeContraintes, 1); | ||
// BOOST_CHECK_EQUAL(data.Sens, "<"); | ||
// BOOST_CHECK(!data.NomDesContraintes.empty()); | ||
// | ||
// // Check the naming logic | ||
// BOOST_REQUIRE_EQUAL(targetNames.size(), 1); | ||
// std::string expectedName = "InjectionSum" + std::string(SEPARATOR) + | ||
// "area<France>" + SEPARATOR + | ||
// "ShortTermStorage<ClusterA>" + SEPARATOR + | ||
// "Constraint<TestConstraint>"; | ||
// BOOST_CHECK_EQUAL(targetNames[0], expectedName); | ||
//} | ||
// | ||
//BOOST_AUTO_TEST_SUITE_END() | ||
/* | ||
#include <boost/test/included/unit_test.hpp> | ||
#include <boost/test/mock_object.hpp> | ||
#include "antares/solver/optimisation/constraints/ShortTermStorageCumulation.h" | ||
#include "antares/solver/optimisation/constraints/ConstraintBuilder.h" | ||
#include "antares/solver/optimisation/constraints/ShortTermStorage.h" | ||
|
||
class MockConstraintBuilder : public ConstraintBuilder { | ||
public: | ||
MOCK_METHOD(void, ShortTermStorageWithdrawal, (unsigned int, double), (override)); | ||
BOOST_MOCK_METHOD(void, ShortTermStorageInjection, (unsigned int, double), (override)); | ||
BOOST_MOCK_METHOD(ConstraintBuilder&, SetOperator, (char), (override)); | ||
BOOST_MOCK_METHOD(void, build, (), (override)); | ||
BOOST_MOCK_METHOD(void, updateHourWithinWeek, (int), (override)); | ||
}; | ||
|
||
BOOST_AUTO_TEST_CASE(AddWithdrawalConstraint) { | ||
MockConstraintBuilder builder; | ||
ShortTermStorageCumulation cumulation(builder); | ||
|
||
// Setup mock expectations | ||
BOOST_CHECK_NO_THROW( | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageWithdrawal(1, 1.0)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('>')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
); | ||
|
||
// Create test data | ||
ShortTermStorage::PROPERTIES properties; | ||
properties.withdrawalEfficiency = 0.9; | ||
properties.injectionEfficiency = 0.8; | ||
|
||
ShortTermStorage storage; | ||
storage.name = "TestStorage"; | ||
storage.clusterGlobalIndex = 1; | ||
storage.additional_constraints.push_back({"withdrawal", "greater", { { {1, 2, 3}, 0, 0 } } }); | ||
|
||
cumulation.add(0); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(AddInjectionConstraint) { | ||
MockConstraintBuilder builder; | ||
ShortTermStorageCumulation cumulation(builder); | ||
|
||
// Setup mock expectations | ||
BOOST_CHECK_NO_THROW( | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageInjection(1, 1.0)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('<')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
); | ||
|
||
// Create test data | ||
ShortTermStorage::PROPERTIES properties; | ||
properties.withdrawalEfficiency = 0.9; | ||
properties.injectionEfficiency = 0.8; | ||
|
||
ShortTermStorage storage; | ||
storage.name = "TestStorage"; | ||
storage.clusterGlobalIndex = 1; | ||
storage.additional_constraints.push_back({"injection", "less", { { {1, 2, 3}, 0, 0 } } }); | ||
|
||
cumulation.add(0); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(AddNettingConstraint) { | ||
MockConstraintBuilder builder; | ||
ShortTermStorageCumulation cumulation(builder); | ||
|
||
// Setup mock expectations | ||
BOOST_CHECK_NO_THROW( | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageInjection(1, 0.8)); | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageWithdrawal(1, -0.9)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('=')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
); | ||
|
||
// Create test data | ||
ShortTermStorage::PROPERTIES properties; | ||
properties.withdrawalEfficiency = 0.9; | ||
properties.injectionEfficiency = 0.8; | ||
|
||
ShortTermStorage storage; | ||
storage.name = "TestStorage"; | ||
storage.clusterGlobalIndex = 1; | ||
storage.additional_constraints.push_back({"netting", "equal", { { {1, 2, 3}, 0, 0 } } }); | ||
|
||
cumulation.add(0); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(AddMultipleConstraints) { | ||
MockConstraintBuilder builder; | ||
ShortTermStorageCumulation cumulation(builder); | ||
|
||
// Setup mock expectations | ||
BOOST_CHECK_NO_THROW( | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageWithdrawal(1, 1.0)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('>')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
|
||
BOOST_TEST_REQUIRE(builder.ShortTermStorageInjection(1, 1.0)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('<')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
|
||
BOOST_TEST_REQUIRE(builder.ShortTermStorageInjection(1, 0.8)); | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageWithdrawal(1, -0.9)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('=')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
); | ||
|
||
// Create test data | ||
ShortTermStorage::PROPERTIES properties; | ||
properties.withdrawalEfficiency = 0.9; | ||
properties.injectionEfficiency = 0.8; | ||
|
||
ShortTermStorage storage; | ||
storage.name = "TestStorage"; | ||
storage.clusterGlobalIndex = 1; | ||
storage.additional_constraints.push_back({"withdrawal", "greater", { { {1, 2, 3}, 0, 0 } } }); | ||
storage.additional_constraints.push_back({"injection", "less", { { {1, 2, 3}, 0, 0 } } }); | ||
storage.additional_constraints.push_back({"netting", "equal", { { {1, 2, 3}, 0, 0 } } }); | ||
|
||
cumulation.add(0); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(VerifyConstraintNames) { | ||
MockConstraintBuilder builder; | ||
ShortTermStorageCumulation cumulation(builder); | ||
|
||
// Setup mock expectations | ||
BOOST_CHECK_NO_THROW( | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageWithdrawal(1, 1.0)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('>')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
|
||
BOOST_TEST_REQUIRE(builder.ShortTermStorageInjection(1, 1.0)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('<')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
|
||
BOOST_TEST_REQUIRE(builder.ShortTermStorageInjection(1, 0.8)); | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageWithdrawal(1, -0.9)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('=')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
); | ||
|
||
// Create test data | ||
ShortTermStorage::PROPERTIES properties; | ||
properties.withdrawalEfficiency = 0.9; | ||
properties.injectionEfficiency = 0.8; | ||
|
||
ShortTermStorage storage; | ||
storage.name = "TestStorage"; | ||
storage.clusterGlobalIndex = 1; | ||
storage.additional_constraints.push_back({"withdrawal", "greater", { { {1, 2, 3}, 0, 0 } } }); | ||
storage.additional_constraints.push_back({"injection", "less", { { {1, 2, 3}, 0, 0 } } }); | ||
storage.additional_constraints.push_back({"netting", "equal", { { {1, 2, 3}, 0, 0 } } }); | ||
|
||
cumulation.add(0); | ||
|
||
// Verify constraint names | ||
BOOST_CHECK_EQUAL(builder.data.NomDesContraintes[0], "WithdrawalSum"); | ||
BOOST_CHECK_EQUAL(builder.data.NomDesContraintes[1], "InjectionSum"); | ||
BOOST_CHECK_EQUAL(builder.data.NomDesContraintes[2], "NettingSum"); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(VerifyConstraintIndices) { | ||
MockConstraintBuilder builder; | ||
ShortTermStorageCumulation cumulation(builder); | ||
|
||
// Setup mock expectations | ||
BOOST_CHECK_NO_THROW( | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageWithdrawal(1, 1.0)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('>')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
|
||
BOOST_TEST_REQUIRE(builder.ShortTermStorageInjection(1, 1.0)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('<')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
|
||
BOOST_TEST_REQUIRE(builder.ShortTermStorageInjection(1, 0.8)); | ||
BOOST_TEST_REQUIRE(builder.ShortTermStorageWithdrawal(1, -0.9)); | ||
BOOST_TEST_REQUIRE(builder.SetOperator('=')); | ||
BOOST_TEST_REQUIRE(builder.build()); | ||
); | ||
|
||
// Create test data | ||
ShortTermStorage::PROPERTIES properties; | ||
properties.withdrawalEfficiency = 0.9; | ||
properties.injectionEfficiency = 0.8; | ||
|
||
ShortTermStorage storage; | ||
storage.name = "TestStorage"; | ||
storage.clusterGlobalIndex = 1; | ||
storage.additional_constraints.push_back({"withdrawal", "greater", { { {1, 2, 3}, 0, 0 } } }); | ||
storage.additional_constraints.push_back({"injection", "less", { { {1, 2, 3}, 0, 0 } } }); | ||
storage.additional_constraints.push_back({"netting", "equal", { { {1, 2, 3}, 0, 0 } } }); | ||
|
||
cumulation.add(0); | ||
|
||
// Verify constraint indices | ||
BOOST_CHECK_EQUAL(builder.data.nombreDeContraintes, 3); | ||
BOOST_CHECK_EQUAL(builder.data.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation[0], 0); | ||
BOOST_CHECK_EQUAL(builder.data.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation[1], 1); | ||
BOOST_CHECK_EQUAL(builder.data.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation[2], 2); | ||
}*/ |