Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Dec 16, 2024
1 parent 2f23076 commit 8109806
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace Antares::Data::ShortTermStorage {
std::vector<int> hours;
double rhs;

unsigned int globalIndex = 0;

bool validate() const;
};
} // namespace Antares::Data::ShortTermStorage
4 changes: 2 additions & 2 deletions src/libs/antares/study/parts/short-term-storage/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ bool STStorageInput::LoadConstraintsFromIniFile(const fs::path& parent_path)
const auto pathIni = parent_path / "additional-constraints.ini";
if (!ini.open(pathIni))
{
logs.error() << "Failed to open INI file: " << pathIni;
return false;
logs.info() << "There is no: " << pathIni;
return true;
}

for (auto* section = ini.firstSection; section; section = section->next)
Expand Down
2 changes: 2 additions & 0 deletions src/libs/antares/study/runtime/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ bool StudyRuntimeInfos::loadFromStudy(Study& study)
logs.info() << " thermal clusters: " << thermalPlantTotalCount;
logs.info() << " thermal clusters (must-run): " << thermalPlantTotalCountMustRun;
logs.info() << " short-term storages: " << shortTermStorageCount;
logs.info() << " short-term storage cumulative constraints count: " <<
shortTermStorageCumulativeConstraintCount;
logs.info() << " binding constraints: "
<< study.bindingConstraints.activeConstraints().size();
logs.info() << " geographic trimming:" << (gd.geographicTrimming ? "true" : "false");
Expand Down
46 changes: 28 additions & 18 deletions src/solver/optimisation/constraints/ShortTermStorageCumulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,24 @@ void ShortTermStorageCumulation::Netting(unsigned int index,
ShortTermStorageWithdrawal(index, -input.withdrawalEfficiency);
}
auto getMemberFunction = [](const std::string& name)
-> void (ShortTermStorageCumulation::*)(unsigned int,
const ::ShortTermStorage::PROPERTIES& ) {
if (name == "withdrawal") {
return &ShortTermStorageCumulation::Withdrawal;
} else if (name == "injection") {
return &ShortTermStorageCumulation::Injection;
}
else if (name == "netting"){
return &ShortTermStorageCumulation::Netting;
}
return nullptr; // Return null if no match
};
-> std::pair<std::string, void (ShortTermStorageCumulation::*)(unsigned int,
const ::ShortTermStorage::PROPERTIES&
)>
{
if (name == "withdrawal")
{
return {"WithdrawalSum", &ShortTermStorageCumulation::Withdrawal};
}
else if (name == "injection")
{
return {"InjectionSum", &ShortTermStorageCumulation::Injection};
}
else if (name == "netting")
{
return {"NettingSum", &ShortTermStorageCumulation::Netting};
}
return {"", nullptr}; // Return null if no match
};


char ConvertSign(const std::string& sign){
Expand All @@ -76,15 +82,19 @@ void ShortTermStorageCumulation::add(int pays){
for(const auto& constraint: storage.additional_constraints){

//sum (var[h]) sign rhs, h in list provied by user

namer.ShortTermStorageLevel(builder.data.nombreDeContraintes, storage.name);
auto [constraintType,memberFunction] = getMemberFunction(constraint.variable);
namer.ShortTermStorageCumulation(constraintType,
builder.data.nombreDeContraintes,
storage.name,
constraint.name
);
const auto index = storage.clusterGlobalIndex;
//TODO
data.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation[index]
= builder.data.nombreDeContraintes;
auto memberFunction = getMemberFunction(constraint.variable);
data.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation[constraint
.globalIndex]
= builder.data.nombreDeContraintes;

for (const auto& hour: constraint.hours){
const int hourInTheYear = builder.data.weekInTheYear * 168 + hour-1;
builder.updateHourWithinWeek(hour-1);
(this->*memberFunction)(index, storage);
builder.SetOperator(ConvertSign(constraint.operatorType))
Expand Down
6 changes: 6 additions & 0 deletions src/solver/simulation/sim_calcul_economique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static void importShortTermStorages(
std::vector<::ShortTermStorage::AREA_INPUT>& ShortTermStorageOut)
{
int clusterGlobalIndex = 0;
int clusterCumulativeConstraintGlobalIndex = 0;
for (uint areaIndex = 0; areaIndex != areas.size(); areaIndex++)
{
ShortTermStorageOut[areaIndex].resize(areas[areaIndex]->shortTermStorage.count());
Expand All @@ -60,6 +61,11 @@ static void importShortTermStorages(
toInsert.penalizeVariationWithdrawal = st.properties.penalizeVariationWithdrawal;
toInsert.name = st.properties.name;
toInsert.additional_constraints = st.additional_constraints;
for (auto& constraint: toInsert.additional_constraints)
{
constraint.globalIndex = clusterCumulativeConstraintGlobalIndex;
++clusterCumulativeConstraintGlobalIndex;
}
toInsert.series = st.series;

// TODO add missing properties, or use the same struct
Expand Down

0 comments on commit 8109806

Please sign in to comment.