Skip to content

Commit

Permalink
Fix find cluster logic (#2537)
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes authored Dec 17, 2024
1 parent bf05c8f commit 938d726
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/libs/antares/study/parts/short-term-storage/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,19 @@ bool STStorageInput::LoadConstraintsFromIniFile(const fs::path& parent_path)
return false;
}

// TODO not the fastest way
for (auto& cluster: storagesByIndex)
auto it = std::find_if(storagesByIndex.begin(),
storagesByIndex.end(),
[&constraint](const STStorageCluster& cluster)
{return cluster.id == constraint.cluster_id; });
if (it == storagesByIndex.end())
{
if (cluster.id == constraint.cluster_id)
{
cluster.additional_constraints.push_back(constraint);
}
else
{
logs.warning() << " from file " << pathIni;
logs.warning() << "Constraint " << section->name
<< "does not reference an existing cluster (" << cluster.id
<< "),\n therefore it is ignored!";
}
logs.warning() << " from file " << pathIni;
logs.warning() << "Constraint " << section->name
<< " does not reference an existing cluster";
}
else
{
it->additional_constraints.push_back(constraint);
}
}

Expand Down

0 comments on commit 938d726

Please sign in to comment.