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

Support more quadratic solvers #2574

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from
Open

Conversation

pet-mit
Copy link
Contributor

@pet-mit pet-mit commented Jan 13, 2025

This PR adds the possibility for the user to choose quadratic (QP) solvers other than sirius, dor adequacy problems.
It does so by interfacing Antares QP description (PROBLEME_ANTARES_A_RESOUDRE) to the new OR-Tools MathOpt API.

The new "quadratic-solver" parameter allows the user to switch solver:

  • setting the value "sirius" will make Antares behave like before, by shunting OR-Tools and calling sirius directly
  • setting another value will make Antares use OR-Tools via the MathOpt API. For now, only "pdlp" and SCIP are supported. However, SCIP seems to be broken (see here). XPRESS has not been yet added (PR merged, awaiting release)

Breaking change:

  • "ortools-solver" parameter has been renamed to "linear-solver"
  • "solver-parameters" parameter has been renamed to "linear-solver-parameters"
  • New parameters have been added : "quadratic-solver" and "quadratic-solver-parameters" (note that the last parameter is a placeholder, and that is not used for now)

Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
@pet-mit pet-mit added the breaking change This PR/issue introduces a breaking change for users label Jan 13, 2025
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
@pet-mit pet-mit marked this pull request as ready for review January 21, 2025 13:29
@pet-mit pet-mit changed the title Support multiple quadratic solvers Support more quadratic solvers Jan 21, 2025
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
@pet-mit pet-mit requested a review from a team January 21, 2025 13:35
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
@@ -48,7 +48,10 @@ namespace
{
void printSolvers()
Copy link
Contributor

@guilpier-code guilpier-code Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the scope of this PR ? (not sure)

printSolvers() :

  • Should be renamed into : logAllAvailableSolvers()
  • why do we print to std::cout and not in usual logs ? Does it even make sense ?

Moreover printSolvers is called from handleOptions which has a very non expressive and probably wrong name and, besides printing, does very strange things.

Comment on lines +8 to +9
INCLUDE
"${CMAKE_SOURCE_DIR}/solver/utils"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INCLUDE
"${CMAKE_SOURCE_DIR}/solver/utils"

is this useful ?
I mean : if we link with Antares::solverUtils, related include directory should be automatic

Copy link
Contributor Author

@pet-mit pet-mit Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without it, test file "basis_status.cpp" cannot find "basis_status_impl.h" which is located under src/solver/utils (with sources, not with headers in include folder)


BOOST_FIXTURE_TEST_CASE(solver_not_supported, QpFixture)
{
options.quadraticSolver = "sirius";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I look at the fixture (the part that does not "check" anything), I wish it could be turned into an class QuadraticProblem.
If this is possible, in unit tests we could have :

BOOST_FIXTURE_TEST_CASE(simple_qp_one_var, QpFixture)
{
    QuadraticProblem QP(/*whatever needed*/);
    QP.addVariable("x", 0, 1, -0.5, 1);
    QP.solve();
    BOOST_CHECK(QP.success());
    BOOST_TEST(QP.solution() == {0.25});
    ....
}

Instead, we have to manipulate problemeAResoudre things, we don't want to read about as a user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually want the checks to be explicitely on problemAResoudre, which holds both the inputs and the outputs of this ortools_quadratic_wrapper

Copy link
Contributor

@tbittar tbittar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor remarks, otherwise all good for me !

@@ -69,7 +70,7 @@ toc_depth: 2
#### Build
* vcpkg (linux, sirius) (#2078) (#2090) (#2145)
* Remove src/antares-deps (#2182)
* Use OR-Tools v9.11-rte1.1 (#2437)
* Use OR-Tools v9.11-rte1.2 (#2574)
Copy link
Contributor

@tbittar tbittar Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that there is or-tools 9.12 now, could we use it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not yet able to make an RTE release for sirius support (CI issues with Windows)

@pet-mit pet-mit requested a review from tbittar February 25, 2025 15:50
@@ -17,7 +17,8 @@ hide:
| --adequacy | Force the simulation in [adequacy](04-parameters.md#mode) mode |
| --parallel | Enable [parallel](optional-features/multi-threading.md) computation of MC years |
| --force-parallel=VALUE | Override the max number of years computed [simultaneously](optional-features/multi-threading.md) |
| --solver=VALUE | The optimization solver to use. Possible values are: `sirius` (default), `coin`, `xpress`, `scip` |
| --linear-solver=VALUE | The optimization solver to use for linear problems. Possible values are: `sirius` (default), `coin`, `xpress`, `scip` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change in the API should be expressed as a change in major version number.

@@ -25,7 +25,7 @@ target_link_libraries(${PROJ}
Antares::linear-problem-api
Antares::logs
Antares::solverUtils
ortools::ortools
$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::ortools>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment for using this generator expression and not a simple link

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe even write an ADR on the subject

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This PR/issue introduces a breaking change for users size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants