Skip to content

Commit

Permalink
Intern Review NSA
Browse files Browse the repository at this point in the history
  • Loading branch information
h-fournier committed Nov 27, 2024
1 parent d8e5806 commit 6c2dfeb
Show file tree
Hide file tree
Showing 14 changed files with 1,370 additions and 1,191 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
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
Loading

0 comments on commit 6c2dfeb

Please sign in to comment.