Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix find cluster logic #2537

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -132,20 +132,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
Loading