Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/dynamic-cl…
Browse files Browse the repository at this point in the history
…uster-groups
  • Loading branch information
payetvin committed Jan 29, 2025
2 parents a950e82 + c5b5123 commit 411f155
Show file tree
Hide file tree
Showing 85 changed files with 409 additions and 669 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
git apply ../docs/antares-simulator-doxygen.patch
- name: Doxygen
uses: mattnotmitt/doxygen-action@v1.9.8
uses: mattnotmitt/doxygen-action@v1.12.0
with:
doxyfile-path: docs/Doxyfile

Expand Down
9 changes: 2 additions & 7 deletions src/analyzer/atsp/atsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ ATSP::ATSP():

ATSP::~ATSP()
{
for (uint i = 0; i != pArea.size(); ++i)
{
delete pArea[i];
}

if (pAutoClean)
{
logs.info() << "Cleaning...";
Expand Down Expand Up @@ -116,7 +111,7 @@ void ATSP::printSummary() const

for (uint i = 0; i != pArea.size(); ++i)
{
const AreaInfo& info = *pArea[i];
const AreaInfo& info = pArea[i];
if (info.rawData)
{
logs.info() << " " << info.name << ": law '"
Expand Down Expand Up @@ -163,7 +158,7 @@ bool ATSP::writeMoments() const

for (uint i = 0; i < pArea.size(); ++i)
{
const AreaInfo& info = *(pArea[i]);
const AreaInfo& info = pArea[i];
if (!info.enabled)
{
continue;
Expand Down
5 changes: 2 additions & 3 deletions src/analyzer/atsp/atsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ATSP final
{
public:
//! Vector
using Vector = std::vector<AreaInfo*>;
using Vector = std::vector<AreaInfo>;

public:
bool enabled;
Expand Down Expand Up @@ -200,7 +200,6 @@ class ATSP final
bool writeMoments() const;

void cacheCreate();
void cacheDestroy();
void cacheClear();
bool cacheFetch(uint index, Matrix<>& out) const;

Expand Down Expand Up @@ -289,7 +288,7 @@ class ATSP final
uint64_t pLimitMemory;
uint64_t pCacheMemoryUsed;
uint pCacheLastValidIndex;
Matrix<>* pCacheMatrix;
std::vector<Matrix<>> pCacheMatrix;

Yuni::String::Vector folderPerArea;
//! Temporary string mainly used for filename manipulation
Expand Down
8 changes: 1 addition & 7 deletions src/analyzer/atsp/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,11 @@ namespace Antares
{
void ATSP::cacheCreate()
{
pCacheMatrix = new Matrix<>[pArea.size()];
pCacheMatrix.resize(pArea.size());
pCacheMemoryUsed = sizeof(Matrix<>) * pArea.size();
pCacheLastValidIndex = 0;
}

void ATSP::cacheDestroy()
{
delete[] pCacheMatrix;
pCacheMatrix = nullptr;
}

void ATSP::cacheClear()
{
for (uint i = 0; i != pCacheLastValidIndex; ++i)
Expand Down
19 changes: 7 additions & 12 deletions src/analyzer/atsp/correlations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ bool ATSP::computeMonthlyCorrelations()

// Initialize mapping, to skip areas which has been disabled
// the real number of items is `realAreaCount`
uint* mapping = new uint[pArea.size()];
std::vector<uint> mapping(pArea.size());
{
uint z = 0;
for (uint i = 0; i != pArea.size(); ++i)
{
mapping[i] = (uint)-1;
if (pArea[i]->enabled)
if (pArea[i].enabled)
{
mapping[z] = i;
++z;
Expand Down Expand Up @@ -168,8 +168,8 @@ bool ATSP::computeMonthlyCorrelations()

logs.info() << "Correlation: month: " << Antares::Date::MonthToString(m)
<< ", area " << (1 + iZ) << '/' << realAreaCount << ": "
<< pArea[i]->name << " with area " << (1 + jZ) << '/' << realAreaCount
<< ": " << pArea[j]->name;
<< pArea[i].name << " with area " << (1 + jZ) << '/' << realAreaCount
<< ": " << pArea[j].name;

if (!cacheFetch(j, SERIE_P))
{
Expand Down Expand Up @@ -442,7 +442,6 @@ bool ATSP::computeMonthlyCorrelations()
moments_centr_net.clear();
moments_centr_raw.clear();
hidden_hours.clear();
cacheDestroy();

// Rounding annual correlation coefficients -zero excluded
for (uint i = 1; i < CORR_YNP.width; ++i)
Expand Down Expand Up @@ -614,7 +613,7 @@ bool ATSP::computeMonthlyCorrelations()
if (!Utils::isZero(col[jZ]))
{
const uint j = mapping[jZ];
f << pArea[i]->name << '%' << pArea[j]->name << " = " << col[jZ] << '\n';
f << pArea[i].name << '%' << pArea[j].name << " = " << col[jZ] << '\n';
}
}
}
Expand Down Expand Up @@ -650,8 +649,7 @@ bool ATSP::computeMonthlyCorrelations()
if (!Utils::isZero(col[jZ]))
{
const uint j = mapping[jZ];
f << pArea[i]->name << '%' << pArea[j]->name << " = " << col[jZ]
<< '\n';
f << pArea[i].name << '%' << pArea[j].name << " = " << col[jZ] << '\n';
}
}
}
Expand All @@ -669,7 +667,7 @@ bool ATSP::computeMonthlyCorrelations()
for (uint iZ = 0; iZ != realAreaCount; ++iZ)
{
const uint i = mapping[iZ];
f << pArea[i]->name << '\n';
f << pArea[i].name << '\n';
}
}
else
Expand All @@ -678,9 +676,6 @@ bool ATSP::computeMonthlyCorrelations()
}
}

// removing the mapping list
delete[] mapping;

return true;
}

Expand Down
22 changes: 11 additions & 11 deletions src/analyzer/atsp/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ bool ATSP::loadFromINIFile(const String& filename)
}
else
{
AreaInfo* info = new AreaInfo();
info->name = section->name;
info->name.toLower();
info->enabled = true;
info->distribution = Data::XCast::dtBeta;
AreaInfo info;
info.name = section->name;
info.name.toLower();
info.enabled = true;
info.distribution = Data::XCast::dtBeta;

IniFile::Property* p = section->firstProperty;
for (; p; p = p->next)
Expand All @@ -187,30 +187,30 @@ bool ATSP::loadFromINIFile(const String& filename)

if (key == "file")
{
info->filename = p->value;
info.filename = p->value;
continue;
}
if (key == "data")
{
key = p->value;
key.toLower();
info->rawData = (key == "raw");
info.rawData = (key == "raw");
continue;
}
if (key == "distribution")
{
info->distribution = Data::XCast::StringToDistribution(p->value);
if (info->distribution == Data::XCast::dtNone)
info.distribution = Data::XCast::StringToDistribution(p->value);
if (info.distribution == Data::XCast::dtNone)
{
logs.error() << "invalid distribution for " << section->name
<< " ('beta' will be used)";
info->distribution = Data::XCast::dtBeta;
info.distribution = Data::XCast::dtBeta;
}
continue;
}
}

pArea.push_back(info);
pArea.push_back(std::move(info));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/analyzer/atsp/preflight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool ATSP::preflight()
for (uint i = 0; i != pArea.size(); ++i)
{
String& folder = folderPerArea[i];
folder.clear() << pTemp << SEP << tsName << SEP << (i / 256) << SEP << pArea[i]->name;
folder.clear() << pTemp << SEP << tsName << SEP << (i / 256) << SEP << pArea[i].name;
if (!IO::Directory::Create(folder))
{
logs.error() << "impossible to create the directory " << folder;
Expand All @@ -67,8 +67,8 @@ bool ATSP::preflight()
{
if (!preflight(i))
{
pArea[i]->enabled = false;
logs.info() << " The area '" << pArea[i]->name << "' has been removed";
pArea[i].enabled = false;
logs.info() << " The area '" << pArea[i].name << "' has been removed";
}
else
{
Expand Down Expand Up @@ -102,7 +102,7 @@ bool ATSP::preflight()
bool ATSP::preflight(const uint areaIndex)
{
// Alias to the current area info
const AreaInfo& info = *(pArea[areaIndex]);
const AreaInfo& info = pArea[areaIndex];
// The folder for the current area
const String& folder = folderPerArea[areaIndex];

Expand Down
5 changes: 1 addition & 4 deletions src/libs/antares/study/area/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void Area::internalInitialize()
// Make sure we have
if (JIT::usedFromGUI)
{
ui = new AreaUI();
ui = std::make_unique<AreaUI>();
}
}

Expand Down Expand Up @@ -76,9 +76,6 @@ Area::~Area()

reserves.clear();
miscGen.clear();

delete ui;
ui = nullptr;
}

void Area::clearAllLinks()
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
{
if (!area.ui)
{
area.ui = new AreaUI();
area.ui = std::make_unique<AreaUI>();
}

buffer.clear() << study.folderInput << SEP << "areas" << SEP << area.id << SEP << "ui.ini";
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/include/antares/study/area/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class Area final: private Yuni::NonCopyable<Area>
//! \name UI
//@{
//! Information for the UI
AreaUI* ui = nullptr;
std::unique_ptr<AreaUI> ui;
//@}

//! \name Dynamic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ bool thermalTSNumberData::reset(const Study& study)
// solver or not.
// WARNING: At this point, the variable pArea->thermal.list.size()
// might not be valid (because not really initialized yet)
uint clusterCount = (study.usedByTheSolver) ? (pArea->thermal.list.enabledCount())
: pArea->thermal.list.allClustersCount();
uint clusterCount = pArea->thermal.list.allClustersCount();

// Resize
pTSNumberRules.reset(clusterCount, nbYears);
Expand Down
1 change: 0 additions & 1 deletion src/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ add_library(solver-lib INTERFACE
add_executable(antares-solver
main.cpp
${SRCS}
modelParser/encoders.hxx
)

set_target_properties(antares-solver PROPERTIES OUTPUT_NAME ${exec_name})
Expand Down
6 changes: 5 additions & 1 deletion src/solver/modelConverter/modelConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ std::vector<Antares::Study::SystemModel::PortType> convertTypes(
{
// Convert portTypes to Antares::Study::SystemModel::PortType
std::vector<Antares::Study::SystemModel::PortType> out;
out.reserve(library.port_types.size());
for (const auto& portType: library.port_types)
{
std::vector<Antares::Study::SystemModel::PortField> fields;
Expand Down Expand Up @@ -77,6 +78,7 @@ std::vector<Antares::Study::SystemModel::Parameter> convertParameters(
{
namespace SM = Antares::Study::SystemModel;
std::vector<SM::Parameter> parameters;
parameters.reserve(model.parameters.size());
for (const auto& parameter: model.parameters)
{
parameters.emplace_back(parameter.id,
Expand Down Expand Up @@ -119,7 +121,7 @@ std::vector<Antares::Study::SystemModel::Variable> convertVariables(const ModelP
namespace SM = Antares::Study::SystemModel;

std::vector<SM::Variable> variables;

variables.reserve(model.variables.size());
for (const auto& variable: model.variables)
{
SM::Expression lb(variable.lower_bound,
Expand Down Expand Up @@ -153,6 +155,7 @@ std::vector<Antares::Study::SystemModel::Constraint> convertConstraints(
const Antares::Solver::ModelParser::Model& model)
{
std::vector<Antares::Study::SystemModel::Constraint> constraints;
constraints.reserve(model.constraints.size());
for (const auto& constraint: model.constraints)
{
auto nodeRegistry = convertExpressionToNode(constraint.expression, model);
Expand All @@ -173,6 +176,7 @@ std::vector<Antares::Study::SystemModel::Model> convertModels(
const Antares::Solver::ModelParser::Library& library)
{
std::vector<Antares::Study::SystemModel::Model> models;
models.reserve(library.models.size());
for (const auto& model: library.models)
{
Antares::Study::SystemModel::ModelBuilder modelBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/solver/modelParser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(SOURCES
parser.cpp
encoders.hxx
decoders.hxx
include/antares/solver/modelParser/parser.h
)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/solver/modelParser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "antares/solver/modelParser/Library.h"

#include "encoders.hxx"
#include "decoders.hxx"

namespace Antares::Solver::ModelParser
{
Expand Down
2 changes: 1 addition & 1 deletion src/solver/simulation/common-hydro-remix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void RemixHydroForAllAreas(const Data::AreaList& areas,

if (!result)
{
throw new Data::AssertionError(
throw Data::AssertionError(
"Error in simplex optimisation. Check logs for more details.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/solver/systemParser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(SOURCES
parser.cpp
converter.cpp
encoders.hxx
decoders.hxx
include/antares/solver/systemParser/parser.h
include/antares/solver/systemParser/converter.h
include/antares/solver/systemParser/system.h
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/solver/systemParser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "antares/solver/systemParser/system.h"

#include "encoders.hxx"
#include "decoders.hxx"

namespace Antares::Solver::SystemParser
{
Expand Down
Loading

0 comments on commit 411f155

Please sign in to comment.