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

Add optimization options in OR-Tools / XPRESS, refactor #1837

Merged
merged 44 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e7c21b0
Version 8.8.0-rc4
flomnes Nov 21, 2023
83dc5b5
Add solver parameters from command line
tbittar Dec 5, 2023
06f6fbd
Run CI on CentOS7
flomnes Dec 6, 2023
dce2220
Merge remote-tracking branch 'origin/develop' into fix/xpress-perf
flomnes Dec 6, 2023
ccba98f
Update URL
flomnes Dec 5, 2023
3178830
Merge remote-tracking branch 'github/develop' into fix/xpress-perf
flomnes Dec 21, 2023
0707458
Merge remote-tracking branch 'github/develop' into fix/xpress-perf
flomnes Dec 21, 2023
12c11ff
Reformat + use OptimizationOptions
flomnes Dec 21, 2023
23f67dc
Add CMake target for Optimization options
flomnes Dec 21, 2023
1657b29
Merge branch 'develop' into fix/xpress-perf
tbittar Mar 21, 2024
a79dc3a
Merge remote-tracking branch 'origin/develop' into fix/xpress-perf
tbittar Mar 21, 2024
56a1cd6
Fix conflicts after rebase
tbittar Mar 28, 2024
39492c8
Set generic parameters from generaldata.ini
tbittar Mar 28, 2024
e5ef606
Fix typo
tbittar Mar 29, 2024
7808ea9
Set solver parameters only once and closer to solve
tbittar Apr 2, 2024
e25baf6
Add some const qualifiers
tbittar Apr 8, 2024
3aca9c2
Gather all solverLogs and ortools options in optimization options
tbittar Apr 8, 2024
59e60a7
Remove use basis config
tbittar Apr 9, 2024
5d2beb6
Merge branch 'develop' into fix/xpress-perf
flomnes Apr 9, 2024
fa8ee43
Add solver specific parameters check
tbittar Apr 9, 2024
fe6add0
Add unit tests
tbittar Apr 11, 2024
7ea6f86
Merge branch 'develop' into fix/xpress-perf
tbittar Apr 11, 2024
9ef4d87
Clarify tests and free solver when not needed anymore
tbittar Apr 12, 2024
1c084a8
Add docs
tbittar Apr 12, 2024
b7da5c3
update tests
tbittar Apr 12, 2024
28b4e82
Fix tests
tbittar Apr 12, 2024
db4b662
Take into account (almost all) PR remarks
tbittar Apr 16, 2024
30dc39f
Fix cmake
tbittar Apr 16, 2024
fb2e8b6
Perform specific parameters check only in solve
tbittar Apr 23, 2024
5afadd1
Restore command line option management
tbittar Apr 23, 2024
2a7154f
Allow to set solver parameters from command line, define xpress and s…
tbittar Apr 23, 2024
54ef5e4
Merge branch 'develop' into fix/xpress-perf
tbittar Apr 25, 2024
1282466
Differentiate between xpress and scip parameters
tbittar Apr 25, 2024
2d7cefc
Factorize code
tbittar Apr 26, 2024
bb5e9a9
Merge branch 'develop' into fix/xpress-perf
tbittar May 6, 2024
2f03618
Update docs
tbittar May 6, 2024
166b261
Fix bugs from previous merge
tbittar May 6, 2024
a5aecb2
Fix bug
tbittar May 6, 2024
b8a1128
Merge branch 'develop' into fix/xpress-perf
tbittar May 16, 2024
c563243
Fix typo
tbittar May 16, 2024
2c8d2df
remove unused declarations
tbittar May 16, 2024
a124741
Simplify spec (remove generaldata.ini new stuff, unify CLI options)
flomnes May 16, 2024
49a30ba
Fix changelog
flomnes May 16, 2024
dca22ca
f
flomnes May 16, 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
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ toc_depth: 2

# Antares Changelog

## Next version
## Next version
--------------------
### Improvements
* STS groups are now "dynamic" : group names are no longer fixed by code, user is free to define these groups.
* When XPRESS or SCIP solver is selected (using OR-Tools), solver specific parameters can be specified from the command-line (#1837)

## 9.0.0
--------------------
Expand Down
1 change: 1 addition & 0 deletions docs/reference-guide/10-command_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ _In all cases, arguments " –h" or "–help" can be used to get help_
|-m, --mps-export | Export anonymous mps weekly or daily optimal UC+dispatch linear |
|-s, --named-mps-problems | Export named mps weekly or daily optimal UC+dispatch linear |
|--solver-logs | Print solver logs |
|--solver-parameters | Set solver-specific parameters, for instance `--solver-parameters="param1 value1 param2 value2"`. Syntax is solver-dependent, and only supported for SCIP & XPRESS. |

- Misc.

Expand Down
13 changes: 7 additions & 6 deletions docs/reference-guide/13-file-format.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Study format changes
This is a list of all recent changes that came with new Antares Simulator features. The main goal of this document is to lower the costs of changing existing interfaces, both GUI and scripts.
## v9.1.0
## Input
### Hydro Maximum Generation/Pumping Power
### Input
#### Hydro Maximum Generation/Pumping Power
* For time series ![Migration diagram](migration.png "Migration diagram"), for more details, see [this Python script](migration.py)

Regarding Hydro time-series, the scenario builder allows the user to choose, for a given year and area, a different time series whether we consider :
Expand All @@ -12,7 +12,7 @@ This implies that, inside one of the previous categories, the number of availabl

* [Logic changes](17-v91.md)

### Short term storage groups
#### Short term storage groups
STS groups in input are now "dynamic" : group names are no longer fixed by code, user is free to define these groups.

In the "thematic trimming" section, the new dynamic variable `STS by group` is now used to enable/disable all variables (level/injection/withdrawal) for all groups. The following variables are obsolete and must not be provided
Expand All @@ -35,15 +35,16 @@ Other5_level

The default value for group is "OTHER1".

## Output
### ST Storage
### Output
#### ST Storage

- Output columns for ST storage are capitalized. For any STS group name my_group, 3 output columns are created : `MY_GROUP_INJECTION`, `MY_GROUP_WITHDRAWAL`, `MY_GROUP_LEVEL`.
- If a group is empty, no column is produced.
- There is now a variable number of columns in files values-XXX.txt, depending on the groups of ST storages provided by the user. Note that groups are case-insensitive, for example `battery`, `Battery` and `BATTERY` all represent the same group. If no ST storage exist for a given area, no variables associated to ST storages will be produced.

## v9.0.0
### Input
### Study version
#### Study version
Breaking change in the study format, file **study.antares**
```
version = 900
Expand Down
2 changes: 2 additions & 0 deletions src/libs/antares/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ add_subdirectory(sys)
add_subdirectory(utils)
add_subdirectory(writer)

add_subdirectory(optimization-options)

set(HEADERS
include/antares/antares/antares.h
include/antares/antares/constants.h
Expand Down
6 changes: 3 additions & 3 deletions src/libs/antares/InfoCollection/StudyInfoCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,17 @@ void StudyInfoCollector::solverVersionToFileContent(FileContent& file_content)

void StudyInfoCollector::ORToolsUsed(FileContent& file_content)
{
const bool& ortoolsUsed = study_.parameters.ortoolsUsed;
const bool& ortoolsUsed = study_.parameters.optOptions.ortoolsUsed;
file_content.addItemToSection("study", "ortools used", ortoolsUsed ? "true" : "false");
}

void StudyInfoCollector::ORToolsSolver(FileContent& file_content)
{
const bool& ortoolsUsed = study_.parameters.ortoolsUsed;
const bool& ortoolsUsed = study_.parameters.optOptions.ortoolsUsed;
std::string ortoolsSolver = "none";
if (ortoolsUsed)
{
ortoolsSolver = study_.parameters.ortoolsSolver;
ortoolsSolver = study_.parameters.optOptions.ortoolsSolver;
}
file_content.addItemToSection("study", "ortools solver", ortoolsSolver);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "antares/optimization-options/options.h"
#include "antares/study/fwd.h"

namespace Antares::Check
{

void checkOrtoolsUsage(Antares::Data::UnitCommitmentMode ucMode,
bool ortoolsUsed,
const std::string& solverName);


void checkStudyVersion(const AnyString& optStudyFolder);

void checkSimplexRangeHydroPricing(Antares::Data::SimplexOptimization optRange,
Expand Down
16 changes: 16 additions & 0 deletions src/libs/antares/exception/LoadingError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ InvalidSolver::InvalidSolver(const std::string& solver, const std::string& avail
{
}

static std::string InvalidSolverSpecificParametersHelper(const std::string& solver,
const std::string& specificParameters)
{
std::ostringstream message;
message << "Specific parameters '" << specificParameters
<< "' are not valid or not supported for solver " << solver;
return message.str();
}

InvalidSolverSpecificParameters::InvalidSolverSpecificParameters(
const std::string& solver,
const std::string& specificParameters):
LoadingError(InvalidSolverSpecificParametersHelper(solver, specificParameters))
{
}

InvalidStudy::InvalidStudy(const Yuni::String& study):
LoadingError(std::string("The folder `") + study.c_str()
+ "` does not seem to be a valid study")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ class InvalidSolver: public LoadingError
explicit InvalidSolver(const std::string& solver, const std::string& availableSolverList);
};

class InvalidStudy: public LoadingError
class InvalidSolverSpecificParameters : public LoadingError
{
public:
explicit InvalidSolverSpecificParameters(const std::string& solver, const std::string& specificParameters);
};

class InvalidStudy : public LoadingError
{
public:
explicit InvalidStudy(const Yuni::String& study);
Expand Down
10 changes: 10 additions & 0 deletions src/libs/antares/optimization-options/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(PROJ optimization-options)

add_library(${PROJ} INTERFACE)

target_include_directories(${PROJ}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

add_library(Antares::${PROJ} ALIAS ${PROJ})
pet-mit marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#pragma once
#include <antares/logs/logs.h>

namespace Antares::Solver::Optimization
{

struct OptimizationOptions
{
//! Force ortools use
bool ortoolsUsed = false;
//! The solver name, sirius is the default
std::string ortoolsSolver = "sirius";
bool solverLogs = false;
std::string solverParameters;
};
} // namespace Antares::Solver::Optimization
10 changes: 4 additions & 6 deletions src/libs/antares/study/include/antares/study/load-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <yuni/yuni.h>
#include <yuni/core/string.h>

#include <antares/optimization-options/options.h>

#include "parameters.h"

namespace Antares
Expand Down Expand Up @@ -63,8 +65,6 @@ class StudyLoadOptions
bool mpsToExport;
//! named problems
bool namedProblems = false;
//! enable solver logs
bool solverLogs = false;
//! Ignore all constraints
bool ignoreConstraints;
//! Simulation mode
Expand All @@ -80,10 +80,8 @@ class StudyLoadOptions
//! A non-zero value if the data will be used for a simulation
bool usedByTheSolver;

//! Force ortools use
bool ortoolsUsed;
//! THe solver name, sirius is the default
std::string ortoolsSolver = "sirius";
//! All options related to optimization
Antares::Solver::Optimization::OptimizationOptions optOptions;

//! Temporary string for passing log message
mutable Yuni::String logMessage;
Expand Down
21 changes: 11 additions & 10 deletions src/libs/antares/study/include/antares/study/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <antares/date/date.h>
#include <antares/inifile/inifile.h>
#include <antares/optimization-options/options.h>
#include <antares/study/UnfeasibleProblemBehavior.hpp>
#include <antares/writer/result_format.h>
#include "antares/antares/antares.h"
Expand Down Expand Up @@ -141,6 +142,11 @@ class Parameters final
*/
void resetAdqPatchParameters();

/*!
** \brief Handle priority between command-line option and configuration file
*/
void handleOptimizationOptions(const StudyLoadOptions& options);

/*!
** \brief Try to detect then fix any bad value
*/
Expand Down Expand Up @@ -509,25 +515,20 @@ class Parameters final
uint seed[seedMax];
//@}

//! \name Ortools configuration
//@{
//! Define if ortools is used
bool ortoolsUsed;
//! Ortool solver used for simulation
std::string ortoolsSolver;
//@}
// Format of results. Currently, only single files or zip archive are supported
ResultFormat resultFormat = legacyFilesDirectories;

// Naming constraints and variables in problems
bool namedProblems;

// solver logs
bool solverLogs;
// All options related to optimization
Antares::Solver::Optimization::OptimizationOptions optOptions;

private:
//! Load data from an INI file
bool loadFromINI(const IniFile& ini, StudyVersion& version, const StudyLoadOptions& options);
bool loadFromINI(const IniFile& ini,
const StudyVersion& version,
const StudyLoadOptions& options);

void resetPlayedYears(uint nbOfYears);

Expand Down
3 changes: 1 addition & 2 deletions src/libs/antares/study/load-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ StudyLoadOptions::StudyLoadOptions():
enableParallel(false),
forceParallel(false),
maxNbYearsInParallel(0),
usedByTheSolver(false),
ortoolsUsed(false)
usedByTheSolver(false)
{
}

Expand Down
Loading
Loading