Skip to content

Commit

Permalink
Merge branch 'feature/review_NSA' into feature/reserve_model_lot3_sca…
Browse files Browse the repository at this point in the history
…lian
  • Loading branch information
h-fournier committed Dec 16, 2024
2 parents 64918d7 + 1de95dd commit cbf52c3
Show file tree
Hide file tree
Showing 19 changed files with 1,586 additions and 1,388 deletions.
24 changes: 24 additions & 0 deletions src/format-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

if [ $# -eq 0 ]
then
# No arguments: format all
SOURCE_DIRS="analyzer/ libs/ solver/ tools/ config/ tests/ packaging/"
SOURCE_FILES=$(find $SOURCE_DIRS -regextype egrep -regex ".*/*\.(c|cxx|cpp|cc|h|hxx|hpp)$" ! -path '*/antlr-interface/*')
else
# Format files provided as arguments
SOURCE_FILES="$@"
fi

# Remove ^M, etc.
if ! [ -x "$(command -v dos2unix)" ]; then
echo 'Warning: dos2unix is not installed. Skipping' >&2
else
echo "$SOURCE_FILES" | xargs dos2unix
fi

if ! [ -x "$(command -v clang-format)" ]; then
echo 'Warning: clang-format is not installed. Skipping' >&2
else
echo "$SOURCE_FILES" | xargs clang-format -i --verbose
fi
12 changes: 5 additions & 7 deletions src/libs/antares/study/include/antares/study/area/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@
template<typename T>
class BiMap
{
private:
// Maps for both directions: key-to-value and value-to-key
std::map<int, T> key_to_value; // Map from key (int) to value (T)
std::map<T, int> value_to_key; // Map from value (T) to key (int)
std::map<int, T> key_to_value; //!< Map from key (int) to value (T)
std::map<T, int> value_to_key; //!< Map from value (T) to key (int)

public:
// Function to insert a key-value pair
Expand All @@ -65,12 +64,11 @@ class BiMap
}

// Function to get the value from the key
T get(int key) const
const T& get(int key) const
{
auto it = key_to_value.find(key);
if (it != key_to_value.end())
if (key_to_value.count(key))
{
return it->second; // Return the associated value if the key exists
return key_to_value.at(key); // Return the associated value if the key exists
}
throw std::out_of_range("This index is not in the BiMap");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ class PartHydro

std::optional<Data::ReserveName> reserveParticipationAt(const Area* area, unsigned int index) const;

//! \brief Returns max turbining power for a reserve if participating, -1 otherwise
//! Returns max turbining power for a reserve if participating, -1 otherwise
float reserveMaxTurbining(Data::ReserveName name);

//! \brief Returns max pumping power for a reserve if participating, -1 otherwise
//! Returns max pumping power for a reserve if participating, -1 otherwise
float reserveMaxPumping(Data::ReserveName name);

//! \brief Returns participating cost for a reserve if participating, -1 otherwise
//! Returns participating cost for a reserve if participating, -1 otherwise
float reserveCost(Data::ReserveName name);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class Properties
/// cluster name
std::string name;

/// Cluster gloval index (across areas)
int clusterGlobalIndex;

/// Enabled ?
bool enabled = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool STStorageInput::createSTStorageClustersFromIniFile(const fs::path& path)
{
return false;
}

cluster.properties.clusterGlobalIndex = storagesByIndex.size();
storagesByIndex.push_back(cluster);
}

Expand Down
2 changes: 1 addition & 1 deletion src/solver/optimisation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(RTESOLVER_OPT
opt_gestion_des_couts_cas_quadratique.cpp
opt_construction_variables_couts_demarrages.cpp
opt_gestion_des_bornes_couts_demarrage.cpp
opt_gestion_des_bornes_reserves_thermiques.cpp
opt_gestion_des_bornes_reserves.cpp
opt_gestion_des_couts_couts_demarrage.cpp
opt_gestion_des_couts_reserves.cpp
opt_gestion_second_membre_couts_demarrage.cpp
Expand Down
24 changes: 12 additions & 12 deletions src/solver/optimisation/constraints/POutBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ void POutBounds::add(int pays, int cluster, int pdt)
for (const auto& capacityReservation :
data.areaReserves[pays].areaCapacityReservationsDown)
{
for (const auto& [clusterId, reserveParticipations] :
capacityReservation.AllThermalReservesParticipation)
if (capacityReservation.AllThermalReservesParticipation.contains(cluster))
{
if (cluster == clusterId)
builder.RunningThermalClusterReserveParticipation(
reserveParticipations.globalIndexClusterParticipation,
1);
auto& reserveParticipation = capacityReservation.AllThermalReservesParticipation
.at(cluster);
builder.RunningThermalClusterReserveParticipation(
reserveParticipation.globalIndexClusterParticipation,
1);
}
}

Expand Down Expand Up @@ -60,13 +60,13 @@ void POutBounds::add(int pays, int cluster, int pdt)
for (const auto& capacityReservation :
data.areaReserves[pays].areaCapacityReservationsUp)
{
for (const auto& [clusterId, reserveParticipations] :
capacityReservation.AllThermalReservesParticipation)
if (capacityReservation.AllThermalReservesParticipation.contains(cluster))
{
if (cluster == clusterId)
builder.RunningThermalClusterReserveParticipation(
reserveParticipations.globalIndexClusterParticipation,
1);
auto& reserveParticipation = capacityReservation.AllThermalReservesParticipation
.at(cluster);
builder.RunningThermalClusterReserveParticipation(
reserveParticipation.globalIndexClusterParticipation,
1);
}
}

Expand Down
23 changes: 12 additions & 11 deletions src/solver/optimisation/constraints/POutCapacityThreasholds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt)
for (const auto& capacityReservation :
data.areaReserves[pays].areaCapacityReservationsDown)
{
for (const auto& [clusterId, reserveParticipations] :
capacityReservation.AllThermalReservesParticipation)
if (capacityReservation.AllThermalReservesParticipation.contains(cluster))
{
if (cluster == clusterId)
builder.RunningThermalClusterReserveParticipation(
reserveParticipations.globalIndexClusterParticipation, 1);
auto& reserveParticipation = capacityReservation.AllThermalReservesParticipation
.at(cluster);
builder.RunningThermalClusterReserveParticipation(
reserveParticipation.globalIndexClusterParticipation,
1);
}
}

Expand Down Expand Up @@ -59,13 +60,13 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt)
for (const auto& capacityReservation :
data.areaReserves[pays].areaCapacityReservationsUp)
{
for (const auto& [clusterId, reserveParticipations] :
capacityReservation.AllThermalReservesParticipation)
if (capacityReservation.AllThermalReservesParticipation.contains(cluster))
{
if (cluster == clusterId)
builder.RunningThermalClusterReserveParticipation(
reserveParticipations.globalIndexClusterParticipation,
1);
auto& reserveParticipation = capacityReservation.AllThermalReservesParticipation
.at(cluster);
builder.RunningThermalClusterReserveParticipation(
reserveParticipation.globalIndexClusterParticipation,
1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ void STPumpingCapacityThreasholds::add(int pays, int cluster, int pdt)
for (const auto& capacityReservation :
data.areaReserves[pays].areaCapacityReservationsUp)
{
for (const auto& [clusterId, reserveParticipations] :
capacityReservation.AllSTStorageReservesParticipation)
if (capacityReservation.AllThermalReservesParticipation.contains(cluster))
{
if (cluster == clusterId)
builder.STStoragePumpingClusterReserveParticipation(
reserveParticipations.globalIndexClusterParticipation, 1);
auto& reserveParticipation = capacityReservation
.AllSTStorageReservesParticipation.at(cluster);
builder.STStoragePumpingClusterReserveParticipation(
reserveParticipation.globalIndexClusterParticipation,
1);
}
}

Expand All @@ -50,12 +51,13 @@ void STPumpingCapacityThreasholds::add(int pays, int cluster, int pdt)
for (const auto& capacityReservation :
data.areaReserves[pays].areaCapacityReservationsDown)
{
for (const auto& [clusterId, reserveParticipations] :
capacityReservation.AllSTStorageReservesParticipation)
if (capacityReservation.AllThermalReservesParticipation.contains(cluster))
{
if (cluster == clusterId)
builder.STStoragePumpingClusterReserveParticipation(
reserveParticipations.globalIndexClusterParticipation, 1);
auto& reserveParticipation = capacityReservation
.AllSTStorageReservesParticipation.at(cluster);
builder.STStoragePumpingClusterReserveParticipation(
reserveParticipation.globalIndexClusterParticipation,
1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ void STTurbiningCapacityThreasholds::add(int pays, int cluster, int pdt)
for (const auto& capacityReservation :
data.areaReserves[pays].areaCapacityReservationsDown)
{
for (const auto& [clusterId, reserveParticipations] :
capacityReservation.AllSTStorageReservesParticipation)
if (capacityReservation.AllThermalReservesParticipation.contains(cluster))
{
if (cluster == clusterId)
builder.STStorageTurbiningClusterReserveParticipation(
reserveParticipations.globalIndexClusterParticipation, -1);
auto& reserveParticipation = capacityReservation
.AllSTStorageReservesParticipation.at(cluster);
builder.STStorageTurbiningClusterReserveParticipation(
reserveParticipation.globalIndexClusterParticipation,
-1);
}
}

Expand Down Expand Up @@ -55,12 +56,13 @@ void STTurbiningCapacityThreasholds::add(int pays, int cluster, int pdt)
for (const auto& capacityReservation :
data.areaReserves[pays].areaCapacityReservationsUp)
{
for (const auto& [clusterId, reserveParticipations] :
capacityReservation.AllSTStorageReservesParticipation)
if (capacityReservation.AllThermalReservesParticipation.contains(cluster))
{
if (cluster == clusterId)
builder.STStorageTurbiningClusterReserveParticipation(
reserveParticipations.globalIndexClusterParticipation, 1);
auto& reserveParticipation = capacityReservation
.AllSTStorageReservesParticipation.at(cluster);
builder.STStorageTurbiningClusterReserveParticipation(
reserveParticipation.globalIndexClusterParticipation,
1);
}
}

Expand Down
Loading

0 comments on commit cbf52c3

Please sign in to comment.