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/improve infeasible pb tests #65

Open
wants to merge 83 commits into
base: New-Antares-Emulator-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
0580371
Renaming infeasibility analyzer : renaming in class Constraint
guilpier-code Jul 2, 2024
e46bc1f
Renaming infeasibility analyzer : renaming in class InfeasibleProblem…
guilpier-code Jul 2, 2024
eec4b4f
Simplifying infeasibility analyzer
guilpier-code Jul 2, 2024
f10c53a
format
flomnes Jul 3, 2024
b4f47bd
Merge remote-tracking branch 'github/develop' into fix/simplifying-in…
flomnes Jul 3, 2024
644335b
New constraint to detect by infeasibility analyzer
guilpier-code Jul 2, 2024
b94dfc0
Infeasibility - to more changeability : simplification + renaming
guilpier-code Jul 3, 2024
f408ecd
Infeasibility - to more changeability : simplifying function StringBe…
guilpier-code Jul 3, 2024
bb55301
Infeasibility - to more changeability : simplifying functions areaNam…
guilpier-code Jul 3, 2024
1d58402
Infeasibility - to more changeability : renaming Constraint::getType(…
guilpier-code Jul 3, 2024
666201d
Infeasibility - to more changeability : function STSName() ==> simpli…
guilpier-code Jul 3, 2024
499619b
Infeasibility - to more changeability : remove unnecessary comments
guilpier-code Jul 3, 2024
25d3424
Infeasibility - to more changeability : simplifying function sortCons…
guilpier-code Jul 3, 2024
3c040c0
Infeasibility - to more changeability : in unit tests, change mislead…
guilpier-code Jul 3, 2024
b3fc6f0
Infeasibility - to more changeability : split constraints logs into 2…
guilpier-code Jul 3, 2024
bbdc230
Infeasibility - to more changeability : move call to sortConstraintsB…
guilpier-code Jul 3, 2024
331c1f5
Infeasibility - to more changeability : run clang-format
guilpier-code Jul 4, 2024
fe1c952
Make infeasibily more changeable : move sorting and trimming slack va…
guilpier-code Jul 4, 2024
82ef63c
Make infeasibily more changeable : introducing constraints list to be…
guilpier-code Jul 5, 2024
b73f985
Make infeasibily more changeable : use new list of constraint and rem…
guilpier-code Jul 5, 2024
ef34f66
Make infeasibily more changeable : remove old class Constraint (now u…
guilpier-code Jul 5, 2024
c998d5f
Make infeasibily more changeable : renaming - detected ==> watched (f…
guilpier-code Jul 5, 2024
294b10e
Make infeasibily more changeable : split function addSlackVariables i…
guilpier-code Jul 5, 2024
2b94176
Make infeasibily more changeable : clang format
guilpier-code Jul 5, 2024
64f94d8
Make infeasibily more changeable : correction due to review
guilpier-code Jul 5, 2024
d83e592
Make infeasibily more changeable : add use of a factory and remove th…
guilpier-code Jul 8, 2024
f8f59b6
[skip ci] Make infeasibily more changeable : renaming
guilpier-code Jul 8, 2024
e1d9e64
Make infeasibily more changeable : clang format
guilpier-code Jul 8, 2024
cda782a
Make infeasibily more changeable : avoid useless data member + avoid …
guilpier-code Jul 9, 2024
436da64
[skip ci] Make infeasibily more changeable : correct function naming
guilpier-code Jul 9, 2024
10491bc
Make infeasibility more changeable : simplify constraint factory
guilpier-code Jul 9, 2024
d74212d
Make infeasibility more changeable : simplifying constraint classes
guilpier-code Jul 9, 2024
fb6b7c0
Make infeasibility more changeable : fix compilation error on Linux +…
guilpier-code Jul 9, 2024
288b85e
[skip ci] Make infeasibility more changeable ; very small change
guilpier-code Jul 9, 2024
ddc6b1d
Make infeasibility more changeable : use a std algorithm instead of a…
guilpier-code Jul 9, 2024
304836e
[skip ci] Make infeasibility more changeable : renaming
guilpier-code Jul 9, 2024
45b778c
Make infeasibility more changeable : simplify constraint classes yet …
guilpier-code Jul 9, 2024
45e53db
Make infeasibility more changeable : replace a loop with the use of s…
guilpier-code Jul 9, 2024
e52703f
[skip ci] Make infeasibility more changeable : remove useless include
guilpier-code Jul 9, 2024
599b20c
Make infeasibility more changeable : use of ranges algorithm instead …
guilpier-code Jul 10, 2024
bb493cb
[skip ci] Make infeasibility more changeable : clang format
guilpier-code Jul 10, 2024
fef3a50
Merge remote-tracking branch 'remotes/origin/develop' into fix/infeas…
guilpier-code Jul 10, 2024
6454550
Make infeasibility more changeable : simplifying constraint factory
guilpier-code Jul 11, 2024
827bd55
Make infeasibility more changeable : corrections due to review
guilpier-code Jul 11, 2024
b1ae657
Merge remote-tracking branch 'remotes/origin/develop' into fix/infeas…
guilpier-code Jul 11, 2024
c1326b8
Fix Sonar issues on #2232 (#2257)
flomnes Jul 11, 2024
9873fc6
Minor fixes, use std::unique_ptr, add safety (#2256)
flomnes Jul 11, 2024
be8101d
Make infeasibility more changeable : changing inner class constant in…
guilpier-code Jul 15, 2024
23d06d6
Make infeasibility more changeable : trial to simplify method Infeasi…
guilpier-code Jul 15, 2024
ea5e282
Make infeasibility more changeable : fix filterConstraintsToOneByType…
guilpier-code Jul 15, 2024
c63d089
Make infeasibility more changeable : simplify filterConstraintsToOneB…
guilpier-code Jul 15, 2024
9e4413c
Make infeasibility more changeable : fix compilation error
guilpier-code Jul 15, 2024
2b4769e
Make infeasibility more changeable : add comments to make code more u…
guilpier-code Jul 16, 2024
422a76f
Use std::type_index (#2264)
flomnes Jul 16, 2024
b018185
Formatting
flomnes Jul 16, 2024
3bbae2a
Make infeasibility more changeable : fix an error in infeasibility ca…
guilpier-code Jul 16, 2024
e67167a
Fix linking
flomnes Jul 16, 2024
5bda935
Minor fixes, use std::unique_ptr
flomnes Jul 11, 2024
af62a60
Caller safer
flomnes Jul 11, 2024
8496fe8
Revert
flomnes Jul 11, 2024
1d15b62
Improve infeasible pb test : improve constraint violation detection
guilpier-code Jul 10, 2024
f1991c4
Improve infeasible pb test : fix detection error detection + change r…
guilpier-code Jul 10, 2024
47341e7
Improve infeasible pb test : fix bug in logging violated variables + …
guilpier-code Jul 10, 2024
4666c56
Improve infeasible pb test : test slack analysis results (list of sla…
guilpier-code Jul 10, 2024
424269a
Improve infeasible pb test : make creation of a problem with infeasib…
guilpier-code Jul 11, 2024
fd43956
Improve infeasible pb test : adding a test on limit of 10 to detected…
guilpier-code Jul 15, 2024
64516a1
Improve infeasible pb test : replace a simple loop on integers with a…
guilpier-code Jul 15, 2024
6e40b52
Improve infeasible pb test : fixing a compilation error on Linux (<fo…
guilpier-code Jul 15, 2024
e7e1cb0
Improve infeasible pb test : small improvements on unit tests
guilpier-code Jul 15, 2024
6087b6b
Improve infeasible pb test : restore a wrong removal
guilpier-code Jul 15, 2024
b23ca90
Improve infeasible pb test : add a new test on reporting infeasibilit…
guilpier-code Jul 16, 2024
059645f
Improve infeasible pb test : removing a useless test
guilpier-code Jul 16, 2024
17fecd6
Format
guilpier-code Jul 16, 2024
72db842
[skip ci] Improve infeasible pb test : very small fix
guilpier-code Jul 16, 2024
a58ad3e
Merge remote-tracking branch 'remotes/origin/develop' into fix/improv…
guilpier-code Jul 17, 2024
6c3646b
Remove manual dynamic memory usage (#2254)
payetvin Jul 17, 2024
f25b260
Improve infeasible pb test : simplify tests by simplifying infeasible…
guilpier-code Jul 17, 2024
beb39da
Improve infeasible pb test : give a name to the (only) var of constra…
guilpier-code Jul 18, 2024
3fe3d72
Improve infeasible pb test : cleaning due to review
guilpier-code Jul 18, 2024
768680f
Improve infeasible pb test : renaming
guilpier-code Jul 18, 2024
79df835
[skip ci] Improve infeasible pb test : remove useless include
guilpier-code Jul 18, 2024
67f31e4
Remove manual dynamic allocations in Xcast (#2270)
payetvin Jul 19, 2024
cb27845
Merge branch 'develop' into fix/improve-infeasible-pb-tests
flomnes Jul 22, 2024
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
2 changes: 1 addition & 1 deletion src/api/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ SimulationResults APIInternal::execute() const
study_->parameters.resultFormat, study_->folderOutput, ioQueueService, durationCollector);
SimulationObserver simulationObserver;
// Run the simulation
switch (study_->runtime->mode)
switch (study_->runtime.mode)
{
case Data::SimulationMode::Economy:
case Data::SimulationMode::Expansion:
Expand Down
1 change: 0 additions & 1 deletion src/libs/antares/study/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ set(SRC_STUDY
include/antares/study/load-options.h
load-options.cpp
include/antares/study/runtime/runtime.h
include/antares/study/runtime/runtime.hxx
runtime/runtime.cpp
include/antares/study/runtime.h
include/antares/study/study.h
Expand Down
44 changes: 16 additions & 28 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,43 +449,31 @@ const AreaLink* AreaList::findLink(const AreaName& area, const AreaName& with) c

void AreaList::clear()
{
delete[] byIndex;
byIndex = nullptr;
byIndex.clear();

if (!areas.empty())
{
Area::Map copy;
copy.swap(areas);
Area::Map copy;
copy.swap(areas);

auto end = copy.end();
for (auto i = copy.begin(); i != end; ++i)
{
delete i->second;
}
auto end = copy.end();
for (auto i = copy.begin(); i != end; ++i)
{
delete i->second;
}
}

void AreaList::rebuildIndexes()
{
delete[] byIndex;
byIndex.clear();

if (areas.empty())
{
byIndex = nullptr;
}
else
{
using AreaWeakPtr = Area*;
byIndex = new AreaWeakPtr[areas.size()];
byIndex.resize(areas.size());

uint indx = 0;
auto end = areas.end();
for (auto i = areas.begin(); i != end; ++i, ++indx)
{
Area* area = i->second;
byIndex[indx] = area;
area->index = indx;
}
uint indx = 0;
auto end = areas.end();
for (auto i = areas.begin(); i != end; ++i, ++indx)
{
Area* area = i->second;
byIndex[indx] = area;
area->index = indx;
}
}

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 @@ -689,7 +689,7 @@ class AreaList final: public Yuni::NonCopyable<AreaList>

public:
//! All areas by their index
Area** byIndex = nullptr;
std::vector<Area*> byIndex;
//! All areas in the list
Area::Map areas;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ class Progression final

public:
//! The total number of ticks to achieve
int maxTickCount;
unsigned maxTickCount;
//! The current number of ticks
std::atomic<int> tickCount;
std::atomic<unsigned> tickCount;
//! The last number of ticks, to reduce the log verbosity
int lastTickCount;
unsigned lastTickCount;
// Caption to use when displaying logs
// Example: 'year: 10000, task: thermal'
Yuni::CString<40, false> caption;
Expand All @@ -104,7 +104,7 @@ class Progression final
return *this;
}

Task& operator+=(int value)
Task& operator+=(unsigned value)
{
pPart.tickCount += value;
return *this;
Expand Down Expand Up @@ -138,7 +138,7 @@ class Progression final
** \internal The number of ticks should remain an `int` because
** we can not use unsigned atomic integer
*/
void add(uint year, Section section, int nbTicks);
void add(uint year, Section section, unsigned nbTicks);

void add(Section section, int nbTicks);

Expand Down
12 changes: 9 additions & 3 deletions src/libs/antares/study/include/antares/study/runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
#include <vector>

#include <antares/mersenne-twister/mersenne-twister.h>
#include "antares/study/study.h"
#include <antares/study/parameters.h>

namespace Antares::Data
{

class Study;

enum RangeLimitsIndex
{
rangeBegin = 0,
Expand Down Expand Up @@ -139,8 +141,12 @@ class StudyRuntimeInfos
void checkThermalTSGeneration(Study& study);
}; // struct StudyRuntimeInfos

} // namespace Antares::Data
#ifdef NDEBUG
inline void StudyRangeLimits::checkIntegrity() const
{
}
#endif

#include "runtime.hxx"
} // namespace Antares::Data

#endif // __ANTARES_LIBS_STUDY_RUNTIME_RUNTIME_INFOS_H__
37 changes: 0 additions & 37 deletions src/libs/antares/study/include/antares/study/runtime/runtime.hxx

This file was deleted.

4 changes: 2 additions & 2 deletions src/libs/antares/study/include/antares/study/study.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <antares/correlation/correlation.h>
#include <antares/date/date.h>
#include <antares/study/runtime/runtime.h>
#include <antares/writer/i_writer.h>
#include "antares/antares/antares.h"
#include "antares/study/binding_constraint/BindingConstraintGroupRepository.h"
Expand Down Expand Up @@ -596,7 +597,7 @@ class Study: public Yuni::NonCopyable<Study>, public LayerData
**
** These informations are only needed when a study is processed.
*/
StudyRuntimeInfos* runtime = nullptr;
StudyRuntimeInfos runtime;

// Antares::Solver::Variable::State* state;

Expand Down Expand Up @@ -690,7 +691,6 @@ YString StudyCreateOutputPath(SimulationMode mode,
int64_t startTime);
} // namespace Antares::Data

#include "runtime.h"
#include "study.hxx"

#endif /* __ANTARES_LIBS_STUDY_STUDY_H__ */
2 changes: 1 addition & 1 deletion src/libs/antares/study/progression/progression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Progression::Task::Task(const Antares::Data::Study& study, uint year, Section se
assert(&pProgression);
}

void Progression::add(uint year, Section section, int nbTicks)
void Progression::add(uint year, Section section, unsigned nbTicks)
{
// This section is not thread-safe because always called before really launching
// the simulation
Expand Down
1 change: 1 addition & 0 deletions src/libs/antares/study/runtime/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "antares/study/runtime/runtime.h"

#include <antares/study/study.h>
#include <antares/utils/utils.h>
#include "antares/antares/fatal-error.h"
#include "antares/study/area/scratchpad.h"
Expand Down
43 changes: 19 additions & 24 deletions src/libs/antares/study/study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ Study::~Study()

void Study::clear()
{
// Releasing runtime infos
FreeAndNil(runtime);
FreeAndNil(scenarioRules);
FreeAndNil(uiinfo);

Expand Down Expand Up @@ -504,9 +502,7 @@ void Study::getNumberOfCores(const bool forceParallel, const uint nbYearsParalle

bool Study::initializeRuntimeInfos()
{
delete runtime;
runtime = new StudyRuntimeInfos();
return runtime->loadFromStudy(*this);
return runtime.loadFromStudy(*this);
}

void Study::performTransformationsBeforeLaunchingSimulation()
Expand Down Expand Up @@ -1164,25 +1160,24 @@ struct TS final

void Study::initializeProgressMeter(bool tsGeneratorOnly)
{
uint years = tsGeneratorOnly ? 1 : (runtime->rangeLimits.year[rangeEnd] + 1);
assert(runtime);
uint years = tsGeneratorOnly ? 1 : (runtime.rangeLimits.year[rangeEnd] + 1);

int ticksPerYear = 0;
int ticksPerOutput = 0;
unsigned ticksPerYear = 0;
unsigned ticksPerOutput = 0;

if (not tsGeneratorOnly)
{
// One tick at the begining and 2 at the end of the year
// Output - Areas
ticksPerOutput += (int)areas.size();
ticksPerOutput += areas.size();
// Output - Links
ticksPerOutput += (int)runtime->interconnectionsCount();
ticksPerOutput += runtime.interconnectionsCount();
// Output - digest
ticksPerOutput += 1;
ticksPerYear = 1;
}

int n;
unsigned n;

for (uint y = 0; y != years; ++y)
{
Expand All @@ -1191,7 +1186,7 @@ void Study::initializeProgressMeter(bool tsGeneratorOnly)
n = parameters.nbTimeSeriesLoad * areas.size() * 365;
if (0 != (timeSeriesLoad & parameters.timeSeriesToArchive))
{
n += (int)areas.size();
n += areas.size();
}
progression.add(y, Solver::Progression::sectTSGLoad, n);
}
Expand All @@ -1200,7 +1195,7 @@ void Study::initializeProgressMeter(bool tsGeneratorOnly)
n = parameters.nbTimeSeriesSolar * areas.size() * 365;
if (0 != (timeSeriesSolar & parameters.timeSeriesToArchive))
{
n += (int)areas.size();
n += areas.size();
}
progression.add(y, Solver::Progression::sectTSGSolar, n);
}
Expand All @@ -1209,7 +1204,7 @@ void Study::initializeProgressMeter(bool tsGeneratorOnly)
n = parameters.nbTimeSeriesWind * areas.size() * 365;
if (0 != (timeSeriesWind & parameters.timeSeriesToArchive))
{
n += (int)areas.size();
n += areas.size();
}
progression.add(y, Solver::Progression::sectTSGWind, n);
}
Expand All @@ -1219,17 +1214,17 @@ void Study::initializeProgressMeter(bool tsGeneratorOnly)
n = parameters.nbTimeSeriesHydro;
if (0 != (timeSeriesHydro & parameters.timeSeriesToArchive))
{
n += (int)areas.size();
n += areas.size();
}
progression.add(y, Solver::Progression::sectTSGHydro, n);
}
if (TS<timeSeriesThermal>::IsNeeded(*this, y))
{
n = runtime->thermalPlantTotalCount;
n = runtime.thermalPlantTotalCount;
if (0 != (timeSeriesThermal & parameters.timeSeriesToArchive))
{
n += (int)runtime->thermalPlantTotalCount;
n += (int)runtime->thermalPlantTotalCountMustRun;
n += runtime.thermalPlantTotalCount;
n += runtime.thermalPlantTotalCountMustRun;
}
progression.add(y, Solver::Progression::sectTSGThermal, n);
}
Expand All @@ -1249,23 +1244,23 @@ void Study::initializeProgressMeter(bool tsGeneratorOnly)
n = 0;
if (0 != (timeSeriesLoad & parameters.exportTimeSeriesInInput))
{
n += (int)areas.size();
n += areas.size();
}
if (0 != (timeSeriesSolar & parameters.exportTimeSeriesInInput))
{
n += (int)areas.size();
n += areas.size();
}
if (0 != (timeSeriesWind & parameters.exportTimeSeriesInInput))
{
n += (int)areas.size();
n += areas.size();
}
if (0 != (timeSeriesHydro & parameters.exportTimeSeriesInInput))
{
n += (int)areas.size();
n += areas.size();
}
if (0 != (timeSeriesThermal & parameters.exportTimeSeriesInInput))
{
n += (int)areas.size();
n += areas.size();
}
if (n)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/study.importprepro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool Study::importTimeseriesIntoInput()
{
// Special case: some thermal clusters may force TS generation
const bool importThermal = parameters.haveToImport(timeSeriesThermal)
&& runtime->thermalTSRefresh;
&& runtime.thermalTSRefresh;
// Something to import ?
if ((parameters.exportTimeSeriesInInput && parameters.timeSeriesToGenerate) || importThermal)
{
Expand Down
2 changes: 1 addition & 1 deletion src/solver/application/ScenarioBuilderOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Antares::Solver::ScenarioBuilderOwner::callScenarioBuilder()
// We will resize all matrix related to the time-series numbers
// This operation can be done once since the number of years is constant
// for a single simulation
study_.resizeAllTimeseriesNumbers(1 + study_.runtime->rangeLimits.year[Data::rangeEnd]);
study_.resizeAllTimeseriesNumbers(1 + study_.runtime.rangeLimits.year[Data::rangeEnd]);
if (not TimeSeriesNumbers::CheckNumberOfColumns(study_.areas))
{
throw FatalError(
Expand Down
3 changes: 1 addition & 2 deletions src/solver/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ void Application::readDataForTheStudy(Data::StudyLoadOptions& options)
writeComment(study);
}

// Runtime data dedicated for the solver
if (!study.initializeRuntimeInfos())
{
throw Error::RuntimeInfoInitialization();
Expand Down Expand Up @@ -391,7 +390,7 @@ void Application::execute()
pStudy->computePThetaInfForThermalClusters();

// Run the simulation
switch (pStudy->runtime->mode)
switch (pStudy->runtime.mode)
{
case Data::SimulationMode::Economy:
case Data::SimulationMode::Expansion:
Expand Down
Loading
Loading