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

Feature/docker scalian #192

Open
wants to merge 5 commits into
base: New-Antares-Emulator-4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 33 additions & 0 deletions docker/ubuntu-20.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#compile and install "antares-solver" executable
ARG url
ARG branch

FROM ubuntu:20.04

#os packages
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq keyboard-configuration tzdata

RUN apt-get install -y gcc-10 g++-10 cpp-10

RUN apt-get install -yq git unzip
RUN apt-get install -yq python3 python3-pip libboost-all-dev
RUN apt-get install -yq libuuid1 uuid-dev libwxgtk3.0-gtk3-dev
RUN apt-get clean -yq

#cmake.version > 3.18 for ortools
RUN pip install --upgrade cmake
RUN ln -s $HOME/.local/bin/cmake /usr/bin/cmake

RUN mkdir /opt/antares
WORKDIR /opt/antares
RUN git clone $(echo ${url:-https://github.com/AntaresSimulatorTeam/Antares_Simulator.git}) --branch $(echo ${branch:-v8.8.2}) antares_sim

#python packages
RUN pip install -r /opt/antares/antares_sim/src/tests/examples/requirements.txt

WORKDIR /opt/antares/antares_sim
RUN git submodule update --init src/antares-deps
RUN cmake -B _build -S src/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/bin/g++-10
RUN cmake --build _build --config release -j8
RUN ln -s /opt/antares/antares_sim/_build/solver/antares-8.8-solver /usr/bin/antares-solver
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Antares Changelog
=================

v8.2.2 (04/2022)
--------------------
## Bug fixes
- Fix solver crash on parsing command-line parameters #624
### GUI
- Fix crash occuring when switching to the links panel #658

v8.2.1 (03/2022)
--------------------
### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.0)
# Version
set(ANTARES_VERSION_HI 8)
set(ANTARES_VERSION_LO 2)
set(ANTARES_VERSION_REVISION 1)
set(ANTARES_VERSION_REVISION 2)
set(ANTARES_VERSION_YEAR 2022)

set(ANTARES_PUBLISHER "RTE France")
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/array/matrix.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ bool Matrix<T, ReadWriteT>::loadFromCSVFile(const AnyString& filename,
{
assert(not filename.empty() and "Matrix<>:: loadFromCSVFile: empty filename");
// As the loading might be expensive, especially when dealing with
// numerous matriceis, we may want to delay this loading (a `lazy` mode)
// numerous matrices, we may want to delay this loading (a `lazy` mode)
return (JIT::enabled and not(options & optImmediate))
? internalLoadJITData(filename, minWidth, maxHeight, options)
// Reading data from file
Expand Down
16 changes: 2 additions & 14 deletions src/libs/antares/study/area/links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,22 +217,10 @@ bool AreaLink::linkLoadTimeSeries_for_version_820_and_later(const AnyString& fol
String filename;
bool success = true;

bool enabledModeIsChanged = false;
if (JIT::enabled)
{
JIT::enabled = false; // Allowing to read the area's daily max power
enabledModeIsChanged = true;
}

// Read link's parameters times series
filename.clear() << folder << SEP << with->id << "_parameters.txt";
success
= parameters.loadFromCSVFile(
filename, fhlMax, HOURS_PER_YEAR, Matrix<>::optFixedSize | Matrix<>::optImmediate)
&& success;

if (enabledModeIsChanged)
JIT::enabled = true; // Back to the previous loading mode.
success = parameters.loadFromCSVFile(filename, fhlMax, HOURS_PER_YEAR, Matrix<>::optFixedSize)
&& success;

// Read link's direct capacities time series
filename.clear() << capacitiesFolder << SEP << with->id << "_direct.txt";
Expand Down
28 changes: 12 additions & 16 deletions src/libs/antares/study/study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,16 +603,6 @@ void Study::getNumberOfCores(const bool forceParallel, const uint nbYearsParalle

bool Study::checkHydroHotStart()
{
// Error messages possibly used in this method.
std::string parallelParametersErrMsg1
= "Hot Start Hydro option : conflict with parallelization parameters.";
std::string parallelParametersErrMsg2
= "Please update relevant simulation parameters or use Cold Start option. ";

std::string calendarErrMsg1
= "Hot Start Hydro option : conflict with Hydro Local Data and/or Simulation Calendar. ";
std::string calendarErrMsg2 = "Please update data or use Cold Start option.";

bool hydroHotStart = (parameters.initialReservoirLevels.iniLevels == irlHotStart);

// No need to check further if hydro hot start is not required
Expand All @@ -623,8 +613,8 @@ bool Study::checkHydroHotStart()
// run, do all sets of parallel years have the same size ?
if (maxNbYearsInParallel != 1 && !parameters.allSetsHaveSameSize)
{
logs.error() << parallelParametersErrMsg1;
logs.error() << parallelParametersErrMsg2;
logs.error() << "Hot Start Hydro option : conflict with parallelization parameters.";
logs.error() << "Please update relevant simulation parameters or use Cold Start option. ";
return false;
}

Expand All @@ -633,8 +623,8 @@ bool Study::checkHydroHotStart()
uint nbDaysInSimulation = parameters.simulationDays.end - parameters.simulationDays.first + 1;
if (nbDaysInSimulation < 364)
{
logs.error() << calendarErrMsg1;
logs.error() << calendarErrMsg2;
logs.error() << "Hot Start Hydro option : simulation calendar must cover one complete year. ";
logs.error() << "Please update data or use Cold Start option.";
return false;
}

Expand All @@ -647,6 +637,11 @@ bool Study::checkHydroHotStart()
// Reference to the area
Area* area = i->second;

// No need to make a check on level initialization when reservoir management
// is not activated for the current area
if (!area->hydro.reservoirManagement)
continue;

// Month the reservoir level is initialized according to.
// This month number is given in the civil calendar, from january to december (0 is
// january).
Expand All @@ -661,8 +656,9 @@ bool Study::checkHydroHotStart()
// Check the day of level initialization is the first day of simulation
if (initLevelOnSimDay != parameters.simulationDays.first)
{
logs.error() << calendarErrMsg1;
logs.error() << calendarErrMsg2;
logs.error() << "Hot Start Hydro option : area '" << area->name
<< "' - hydro level must be initialized on the first simulation month. ";
logs.error() << "Please update data or use Cold Start option.";
return false;
}
} // End loop over areas
Expand Down
4 changes: 2 additions & 2 deletions src/solver/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ void Application::prepare(int argc, char* argv[])
auto parser = CreateParser(pSettings, options);

// Parse the command line arguments
if (!parser(argc, argv))
throw Error::CommandLineArguments(parser.errors());
if (!parser->operator()(argc, argv))
throw Error::CommandLineArguments(parser->errors());

if (options.displayVersion)
{
Expand Down
66 changes: 33 additions & 33 deletions src/solver/misc/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,106 +70,106 @@ static std::string availableOrToolsSolversString()
return availableSolverListStr;
}

GetOpt::Parser CreateParser(Settings& settings, Antares::Data::StudyLoadOptions& options)
std::unique_ptr<GetOpt::Parser> CreateParser(Settings& settings, Antares::Data::StudyLoadOptions& options)
{
settings.reset();

GetOpt::Parser parser;
auto parser = std::unique_ptr<GetOpt::Parser>(new GetOpt::Parser());

parser.addParagraph(String() << "Antares Solver v" << ANTARES_VERSION_PUB_STR << "\n");
parser->addParagraph(String() << "Antares Solver v" << ANTARES_VERSION_PUB_STR << "\n");

// Simulation mode
parser.addParagraph("Simulation");
parser->addParagraph("Simulation");
// --input
parser.addFlag(options.studyFolder, 'i', "input", "Study folder");
parser->addFlag(options.studyFolder, 'i', "input", "Study folder");
// --expansion
parser.addFlag(
parser->addFlag(
options.forceExpansion, ' ', "expansion", "Force the simulation in expansion mode");
// --economy
parser.addFlag(options.forceEconomy, ' ', "economy", "Force the simulation in economy mode");
parser->addFlag(options.forceEconomy, ' ', "economy", "Force the simulation in economy mode");
// --adequacy
parser.addFlag(options.forceAdequacy, ' ', "adequacy", "Force the simulation in adequacy mode");
parser->addFlag(options.forceAdequacy, ' ', "adequacy", "Force the simulation in adequacy mode");
// --draft
parser.addFlag(
parser->addFlag(
options.forceAdequacyDraft, ' ', "draft", "Force the simulation in adequacy-draft mode");
// --parallel
parser.addFlag(
parser->addFlag(
options.enableParallel, ' ', "parallel", "Enable the parallel computation of MC years");
// --force-parallel
parser.add(options.maxNbYearsInParallel,
parser->add(options.maxNbYearsInParallel,
' ',
"force-parallel",
"Override the max number of years computed simultaneously");

// add option for ortools use
// --use-ortools
parser.addFlag(options.ortoolsUsed, ' ', "use-ortools", "Use ortools library to launch solver");
parser->addFlag(options.ortoolsUsed, ' ', "use-ortools", "Use ortools library to launch solver");

//--ortools-solver
parser.add(options.ortoolsSolver,
parser->add(options.ortoolsSolver,
' ',
"ortools-solver",
"Ortools solver used for simulation (only available with use-ortools "
"option)\nAvailable solver list : "
+ availableOrToolsSolversString());

parser.addParagraph("\nParameters");
parser->addParagraph("\nParameters");
// --name
parser.add(settings.simulationName, 'n', "name", "Set the name of the new simulation to VALUE");
parser->add(settings.simulationName, 'n', "name", "Set the name of the new simulation to VALUE");
// --generators-only
parser.addFlag(
parser->addFlag(
settings.tsGeneratorsOnly, 'g', "generators-only", "Run the time-series generators only");

// --comment-file
parser.add(settings.commentFile,
parser->add(settings.commentFile,
'c',
"comment-file",
"Specify the file to copy as comments of the simulation");
// --force
parser.addFlag(settings.ignoreWarningsErrors, 'f', "force", "Ignore all warnings at loading");
parser->addFlag(settings.ignoreWarningsErrors, 'f', "force", "Ignore all warnings at loading");
// --no-output
parser.addFlag(
parser->addFlag(
settings.noOutput, ' ', "no-output", "Do not write the results in the output folder");
// --year
parser.add(options.nbYears, 'y', "year", "Override the number of MC years");
parser->add(options.nbYears, 'y', "year", "Override the number of MC years");
// --year-by-year
parser.addFlag(options.forceYearByYear,
parser->addFlag(options.forceYearByYear,
' ',
"year-by-year",
"Force the writing the result output for each year (economy only)");
// --derated
parser.addFlag(options.forceDerated, ' ', "derated", "Force the derated mode");
parser->addFlag(options.forceDerated, ' ', "derated", "Force the derated mode");

parser.addParagraph("\nOptimization");
parser->addParagraph("\nOptimization");

// --optimization-range
parser.addFlag(settings.simplexOptimRange,
parser->addFlag(settings.simplexOptimRange,
' ',
"optimization-range",
"Force the simplex optimization range ('day' or 'week')");

// --no-constraints
parser.addFlag(settings.ignoreConstraints, ' ', "no-constraints", "Ignore all constraints");
parser->addFlag(settings.ignoreConstraints, ' ', "no-constraints", "Ignore all constraints");

// --no-ts-import
parser.addFlag(options.noTimeseriesImportIntoInput,
parser->addFlag(options.noTimeseriesImportIntoInput,
' ',
"no-ts-import",
"Do not import timeseries into the input folder. This option might be useful "
"for running old studies without upgrading them");

// --mps-export
parser.addFlag(options.mpsToExport,
parser->addFlag(options.mpsToExport,
' ',
"mps-export",
"Export in the mps format the optimization problems.");

parser.addParagraph("\nMisc.");
parser->addParagraph("\nMisc.");
// --progress
parser.addFlag(
parser->addFlag(
settings.displayProgression, ' ', "progress", "Display the progress of each task");
// --swap
parser.add(settings.swap,
parser->add(settings.swap,
' ',
"swap-folder",
#ifdef ANTARES_SWAP_SUPPORT
Expand All @@ -182,16 +182,16 @@ GetOpt::Parser CreateParser(Settings& settings, Antares::Data::StudyLoadOptions&
);

// --pid
parser.add(settings.PID, 'p', "pid", "Specify the file where to write the process ID");
parser->add(settings.PID, 'p', "pid", "Specify the file where to write the process ID");

// --version

parser.addFlag(
parser->addFlag(
options.displayVersion, 'v', "version", "Print the version of the solver and exit");

// The last argument is the study folder.
// Unlike all other arguments, it does not need to be given after a --flag.
parser.remainingArguments(options.studyFolder);
parser->remainingArguments(options.studyFolder);

return parser;
}
Expand Down
3 changes: 2 additions & 1 deletion src/solver/misc/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#ifndef __SOLVER_MISC_GETOPT_H__
#define __SOLVER_MISC_GETOPT_H__

#include<memory>
#include <yuni/yuni.h>
#include <yuni/core/string.h>
#include <yuni/core/getopt.h>
Expand Down Expand Up @@ -71,7 +72,7 @@ class Settings
/*!
** \brief Interprete options given in command line
*/
Yuni::GetOpt::Parser CreateParser(Settings& settings, Antares::Data::StudyLoadOptions& options);
std::unique_ptr<Yuni::GetOpt::Parser> CreateParser(Settings& settings, Antares::Data::StudyLoadOptions& options);

void checkAndCorrectSettingsAndOptions(Settings& settings, Data::StudyLoadOptions& options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ wxString Connection::rowCaption(int row) const

void Connection::onConnectionChanged(Data::AreaLink* link)
{
setMatrix(link);
if (link)
{
link->invalidate(true); // Force the reload of parameters & capacities to avoid a crash.
setMatrix(link);
mUseLoopFlow = link->useLoopFlow;
}

if (pControl)
{
pControl->InvalidateBestSize();
Expand Down