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

Normalize simulation mode Expansion, fix logs #1771

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion src/libs/antares/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ set(SRC
config.h
constants.h
constants.cpp
xpansion.h
# Misc

locale.h
Expand Down
1 change: 0 additions & 1 deletion src/libs/antares/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#ifndef __ANTARES_LIBS_CONSTANTS_H__
#define __ANTARES_LIBS_CONSTANTS_H__

#include "xpansion.h"
#include <array>

/*! Name of the app to use into logs */
Expand Down
34 changes: 7 additions & 27 deletions src/libs/antares/study/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ const char* StudyModeToCString(StudyMode mode)
return "Economy";
case stdmAdequacy:
return "Adequacy";
case stdmMax:
case stdmExpansion:
return "Expansion";
case stdmMax:
case stdmUnknown:
return "Unknown";
}
Expand Down Expand Up @@ -231,8 +232,6 @@ void Parameters::reset()
{
// Mode
mode = stdmEconomy;
// Expansion
expansion = false;
// Calendar
horizon.clear();

Expand Down Expand Up @@ -1039,25 +1038,12 @@ bool Parameters::loadFromINI(const IniFile& ini, uint version, const StudyLoadOp
}

// Simulation mode
// ... Expansion
if (mode == stdmExpansion)
{
mode = stdmEconomy;
expansion = true;
}

// ... Enforcing simulation mode
if (options.forceMode != stdmUnknown)
{
if (options.forceMode == stdmExpansion)
{
mode = stdmEconomy;
expansion = true;
}
else
mode = options.forceMode;

mode = options.forceMode;
logs.info() << " forcing the simulation mode " << StudyModeToCString(mode);

assert(mode != stdmMax && "Invalid simulation mode");
}
else
Expand Down Expand Up @@ -1359,14 +1345,14 @@ void Parameters::prepareForSimulation(const StudyLoadOptions& options)
{
case stdmEconomy:
case stdmAdequacy:
case stdmExpansion:
{
// The year-by-year mode might have been requested from the command line
if (options.forceYearByYear)
yearByYear = true;
break;
}
case stdmUnknown:
case stdmExpansion:
case stdmMax:
{
// The mode year-by-year can not be enabled in adequacy
Expand Down Expand Up @@ -1437,7 +1423,7 @@ void Parameters::prepareForSimulation(const StudyLoadOptions& options)
exportTimeSeriesInInput = 0;
}

if (expansion)
if (mode == stdmExpansion)
logs.info() << " :: enabling expansion";
if (yearByYear)
logs.info() << " :: enabling the 'year-by-year' mode";
Expand Down Expand Up @@ -1504,13 +1490,7 @@ void Parameters::saveToINI(IniFile& ini) const
auto* section = ini.addSection("general");

// Mode
if (expansion && mode == stdmEconomy)
section->add("mode", "Expansion");
else
{
section->add("mode", StudyModeToCString(mode));
expansion = false;
}
section->add("mode", StudyModeToCString(mode));

// Calendar
section->add("horizon", horizon);
Expand Down
5 changes: 0 additions & 5 deletions src/libs/antares/study/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,6 @@ class Parameters final
StudyMode mode;
//@}

//! \name Expansion
//@{
//! Expansion flag
mutable bool expansion;

//! \name Horizon
//@{
//! Horizon year
Expand Down
4 changes: 3 additions & 1 deletion src/libs/antares/study/study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,10 @@ YString StudyCreateOutputPath(StudyMode mode,
case stdmAdequacy:
folderOutput += "adq";
break;
case stdmUnknown:
case stdmExpansion:
folderOutput += "exp";
break;
case stdmUnknown:
case stdmMax:
break;
}
Expand Down
4 changes: 0 additions & 4 deletions src/libs/antares/xpansion.h

This file was deleted.

1 change: 1 addition & 0 deletions src/solver/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ void Application::execute()
switch (pStudy->runtime->mode)
{
case Data::stdmEconomy:
case Data::stdmExpansion:
runSimulationInEconomicMode();
break;
case Data::stdmAdequacy:
Expand Down
2 changes: 1 addition & 1 deletion src/solver/simulation/sim_calcul_economique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study,

auto& parameters = study.parameters;

problem.Expansion = parameters.expansion;
problem.Expansion = (parameters.mode == Data::stdmExpansion);
problem.firstWeekOfSimulation = false;

problem.hydroHotStart
Expand Down
11 changes: 3 additions & 8 deletions src/solver/variable/state.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,15 @@ inline void State::initFromAreaIndex(const unsigned int areaIndex, uint numSpace

switch (studyMode)
{
case Data::stdmEconomy:
{
hourlyResults = &problemeHebdo->ResultatsHoraires[areaIndex];
break;
}
case Data::stdmAdequacy:
case Data::stdmEconomy:
case Data::stdmExpansion:
{
hourlyResults = &problemeHebdo->ResultatsHoraires[areaIndex];
break;
}

case Data::stdmUnknown:
break;
case Data::stdmExpansion:
break;
case Data::stdmMax:
break;
}
Expand Down
11 changes: 3 additions & 8 deletions src/solver/variable/surveyresults/surveyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,17 @@ void SurveyResultsData::initialize(uint maxVariables)

switch (study.parameters.mode)
{
case Data::stdmEconomy:
{
matrix.resize(study.areas.size(), study.areas.size());
// The initialization will be done later
//::MatrixFill(&matrix, std::numeric_limits<double>::quiet_NaN());
break;
}
case Data::stdmAdequacy:
case Data::stdmEconomy:
case Data::stdmExpansion:
{
matrix.resize(study.areas.size(), study.areas.size());
// The initialization will be done later
//::MatrixFill(&matrix, std::numeric_limits<double>::quiet_NaN());
break;
}

case Data::stdmUnknown:
case Data::stdmExpansion:
case Data::stdmMax:
break;
}
Expand Down
3 changes: 0 additions & 3 deletions src/ui/simulator/windows/inspector/constants.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <antares/xpansion.h>
#include "constants.h"

namespace Antares
Expand Down Expand Up @@ -269,9 +268,7 @@ const wxChar* const calendarWeeks[] = {wxT("MON - SUN"),

const wxChar* const studyMode[] = {wxT("Economy"),
wxT("Adequacy"),
#if STUDY_MODE_EXPANSION
wxT("Expansion"),
#endif
nullptr};

const wxChar* const adequacyPatchMode[] = {wxT("virtual area"),
Expand Down
2 changes: 2 additions & 0 deletions src/ui/simulator/windows/output/panel/area-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ void Panel::loadDataFromFile()
filename << output.path << SEP << "adequacy" << SEP;
break;
case Data::stdmExpansion:
filename << output.path << SEP << "expansion" << SEP;
break;
case Data::stdmUnknown:
case Data::stdmMax:
filename << output.path << SEP << "unknown" << SEP;
Expand Down
4 changes: 3 additions & 1 deletion src/ui/simulator/windows/output/provider/outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ void Outputs::search(Spotlight::IItem::Vector& out,
case Data::stdmAdequacy:
item->addTag("ADQ", 220, 192, 245);
break;
case Data::stdmUnknown:
case Data::stdmExpansion:
item->addTag("EXP", 220, 192, 245);
break;
case Data::stdmUnknown:
case Data::stdmMax:
item->addTag("...", 213, 213, 213);
}
Expand Down