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

Legacy ortools behind API - user story 3.1 #2455

Merged
merged 35 commits into from
Oct 23, 2024

Conversation

guilpier-code
Copy link
Contributor

@guilpier-code guilpier-code commented Oct 8, 2024

Do not merge with changes on CI yaml files

What we plan to do :

  • Replace solver ortools + Sirius with API + (ortools + Sirius).
    More specifically, we replace the current ortools LP building with a use :
    • of existing classes OrtoolsLinearProblem and LinearProblemBuilder
    • the coding of a new filler.
  • Current ortools LP run with the run of OrtoolsLinearProblem
  • Run CI end-to-end tests with options --use-ortools --ortools-solver sirius
  • Check that regressions are expected (only on Windows and for "parallel" tests)
  • No unit tests are planned

Notes :

  • The first commit of this PR only intends to run all end-to-end tests with options --use-ortools --ortools-solver sirius in the CI. We can spot the expected regressions.
  • Some comments from the author of devs were added to this PR to spot difficulties or possible enhancements.

@guilpier-code guilpier-code changed the title Legacy ortools behind API : in CI, run tests with ortools + sirius Legacy ortools behind API - user story 3.1 Oct 8, 2024
@pull-request-size pull-request-size bot added size/L and removed size/M labels Oct 9, 2024
@guilpier-code guilpier-code marked this pull request as ready for review October 10, 2024 08:56
@guilpier-code guilpier-code requested review from flomnes, payetvin, JasonMarechal25 and pet-mit and removed request for payetvin October 10, 2024 14:35
Comment on lines 385 to 392
auto ortoolsProblem = std::make_unique<OrtoolsLinearProblem>(Probleme.isMIP(), options.ortoolsSolver);
auto legacyOrtoolsFiller = std::make_unique<LegacyOrtoolsFiller>(ortoolsProblem->MPSolver(), &Probleme);
std::vector<LinearProblemFiller*> fillersCollection = {legacyOrtoolsFiller.get()};
LinearProblemData LP_Data;
LinearProblemBuilder linearProblemBuilder(fillersCollection);

linearProblemBuilder.build(*ortoolsProblem, LP_Data);
auto MPproblem = std::shared_ptr<MPSolver>(ortoolsProblem->MPSolver());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This block appears twice in this file.
It is meant to create a ortools MPSolver.
It's a kind of code duplication.
This duplication will be removed in a further PR

@guilpier-code guilpier-code requested a review from pet-mit October 11, 2024 14:37
@pet-mit pet-mit requested a review from flomnes October 15, 2024 13:05
src/solver/optimisation/LegacyFiller.cpp Outdated Show resolved Hide resolved
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/windows-vcpkg.yml Outdated Show resolved Hide resolved
.github/workflows/windows-vcpkg.yml Outdated Show resolved Hide resolved
.github/workflows/windows-vcpkg.yml Outdated Show resolved Hide resolved
.github/workflows/windows-vcpkg.yml Outdated Show resolved Hide resolved
.github/workflows/windows-vcpkg.yml Outdated Show resolved Hide resolved
* 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/>.
*/

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 can't understand the point of this new class.
It seems like it adds nothing to its parent class.
Is the parent class not enough ?

Copy link
Contributor

Choose a reason for hiding this comment

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

For now, this only makes MPSolver public. As MPSolver is only needed in legacy code, this allows us to keep the design of the parent class clean: other users of the parent class must not need access to MPSolver

#include "antares/solver/utils/named_problem.h"
#include "antares/solver/utils/ortools_utils.h"

#include "ortools/linear_solver/linear_solver.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#include "ortools/linear_solver/linear_solver.h"

We don't need that


#include "antares/solver/modeler/api/linearProblemFiller.h"
#include "antares/solver/utils/named_problem.h"
#include "antares/solver/utils/ortools_utils.h"
Copy link
Contributor Author

@guilpier-code guilpier-code Oct 21, 2024

Choose a reason for hiding this comment

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

About :

#include "antares/solver/utils/ortools_utils.h"

It seems that the only reason for which we have this inclusion is the definition of class Nomenclature.
But this class :

  • has nothing to do with ortools or ortools utils
  • is only used in current files LegacyFiller.h/.cpp

So we should move this class from ortools_utils.h to LegacyFiller.h, and remove this previously pointed inclusion.
I tested it : code compiles.

And honestly, this class makes so little thing that we can wonder if it's useful, and should not be replaced with simple data structures inside the current filler.

@guilpier-code
Copy link
Contributor Author

guilpier-code commented Oct 21, 2024

In file linearProblemBuilder.cpp (not touched in this PR), there is a not needed inclusion :

#include <memory>

We should remove it.

Signed-off-by: Peter Mitri <[email protected]>
Signed-off-by: Peter Mitri <[email protected]>
Copy link

@pet-mit pet-mit merged commit b94e65e into develop Oct 23, 2024
8 checks passed
@pet-mit pet-mit deleted the feature/legacy-ortools-behind-api-3.1 branch October 23, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants