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 - After user story 3.1 : trial for simplification #2458

Draft
wants to merge 35 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ab11215
Legacy ortools behind API : in CI, run tests with ortools + sirius
guilpier-code Oct 8, 2024
2f704ca
Legacy ortools behind API : mainly preparing the field for further ch…
guilpier-code Oct 9, 2024
0a308a9
Legacy ortools behind API : put solver creation behind or-tools
guilpier-code Oct 10, 2024
51d19d8
Legacy ortools behind API : fix crash in modeler unit tests
guilpier-code Oct 10, 2024
8223c47
Legacy ortools behind API : fix a crash - smart pointer on ortools so…
guilpier-code Oct 10, 2024
f588590
Legacy ortools behind API : remove duplicate code
guilpier-code Oct 10, 2024
b4ef65f
Legacy ortools behind API : correction due to review
guilpier-code Oct 11, 2024
ef29f1d
Legacy ortools behind API : correction due to review
guilpier-code Oct 11, 2024
b6c9758
activate some tests on new simtest reference
pet-mit Oct 14, 2024
499f548
activate ortools in end-to-end tests
pet-mit Oct 14, 2024
3fdc8fc
fix simtest version
pet-mit Oct 14, 2024
89724ea
fix clang format
pet-mit Oct 14, 2024
f03e705
fix simtest version
pet-mit Oct 14, 2024
96707ac
Merge branch 'develop' into feature/legacy-ortools-behind-api-3.1
pet-mit Oct 14, 2024
836a73a
fix after merge
pet-mit Oct 14, 2024
d326428
fix clang format
pet-mit Oct 14, 2024
c2a02d8
Improve 3.1 (#2461)
pet-mit Oct 14, 2024
8d89138
Merge branch 'develop' into feature/legacy-ortools-behind-api-3.1
pet-mit Oct 14, 2024
678fea0
some fixes
pet-mit Oct 14, 2024
41b9c83
some fixes
pet-mit Oct 14, 2024
c37bf6c
activate long tests
pet-mit Oct 15, 2024
9d9dcfe
Merge branch 'develop' into feature/legacy-ortools-behind-api-3.1
pet-mit Oct 15, 2024
0c7d054
Update src/solver/optimisation/LegacyFiller.cpp
pet-mit Oct 15, 2024
4aa95a2
fix
pet-mit Oct 15, 2024
a0463b8
revert CI test changes
pet-mit Oct 16, 2024
d0a0686
revert CI test changes
pet-mit Oct 16, 2024
342b926
Merge branch 'develop' into feature/legacy-ortools-behind-api-3.1
pet-mit Oct 16, 2024
6a018aa
revert CI test changes
pet-mit Oct 16, 2024
7fc4d93
Merge remote-tracking branch 'origin/feature/legacy-ortools-behind-ap…
pet-mit Oct 16, 2024
33abc2f
revert CI test changes
pet-mit Oct 16, 2024
bf386b9
add message in case of MPS check failure
pet-mit Oct 17, 2024
6b217e9
revert ortools activation in test
pet-mit Oct 17, 2024
399f634
Merge branch 'develop' into feature/legacy-ortools-behind-api-3.1
pet-mit Oct 17, 2024
b57f845
Simplify calls to solver (after modeler 3.1) : move code where it bel…
guilpier-code Oct 10, 2024
e1dbef2
Simplifying solver calls : force to call ortools (to be reverted)
guilpier-code Oct 21, 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
Prev Previous commit
Next Next commit
Legacy ortools behind API : mainly preparing the field for further ch…
…anges
guilpier-code committed Oct 9, 2024
commit 2f704cae4ea2ad46c33728449a9f9a6b6fddd000
43 changes: 22 additions & 21 deletions src/packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -6,18 +6,18 @@
include(GNUInstallDirs)
# generate and install export file
set(TARGET_LIBS #No alias
#each "block" of dependency describe the dependency for a target
#not dependency is present since once a dependency is in the export set
#it is available for everything
# each "block" of dependency describe the dependency for a target
# not dependency is present since once a dependency is in the export set
# it is available for everything

solver_api #What we want to export
solver_api # What we want to export

#solver_api
# solver_api
study
study-loader
file-tree-study-loader
antares-solver-simulation
#study
# study
yuni-static-core
array
date
@@ -37,56 +37,57 @@ set(TARGET_LIBS #No alias
antares-solver-variable
lps

#study-loader
#nothing
# study-loader : nothing

#file-tree-study-loader
# file-tree-study-loader
application

#run-mode
# run-mode
infoCollection

#antares-solver-simulation
# antares-solver-simulation
concurrency
misc
model_antares
antares-solver-ts-generator

#lps
#nothing
# lps : nothing

#array
# array
io
jit
AntaresMemory

#date
# date
logs

#correlation
# correlation
locator

#antares-core
# antares-core
antares-config-lib

#application
# application
solver-lib
sys
signal-handling
antares-solver-variable-info
optimization-options
resources

#model_antares
# model_antares
infeasible_problem_analysis
modeler_api
modeler-ortools-impl

#solver-lib
# solver-lib
args_helper
checks
locale
yuni-static-uuid

antares-solver #executable
# executable
antares-solver
)

install(TARGETS ${TARGET_LIBS}
2 changes: 2 additions & 0 deletions src/solver/modeler/api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ set(SRC_API
include/antares/solver/modeler/api/linearProblemFiller.h
include/antares/solver/modeler/api/linearProblemBuilder.h

include/antares/solver/modeler/api/fillers/LegacyOrtoolsFiller.h

linearProblemData.cpp
linearProblemBuilder.cpp
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "antares/solver/modeler/api/linearProblemFiller.h"

namespace Antares::Solver::Modeler::Api
{
class LegacyOrtoolsFiller: public LinearProblemFiller
{
public:
explicit LegacyOrtoolsFiller() = default;
void addVariables(ILinearProblem& pb, LinearProblemData& data) override;
void addConstraints(ILinearProblem& pb, LinearProblemData& data) override;
void addObjective(ILinearProblem& pb, LinearProblemData& data) override;
};

void LegacyOrtoolsFiller::addVariables(ILinearProblem& pb, LinearProblemData& data)
{
}

void LegacyOrtoolsFiller::addConstraints(ILinearProblem& pb, LinearProblemData& data)
{
}

void LegacyOrtoolsFiller::addObjective(ILinearProblem& pb, LinearProblemData& data)
{
}
}
16 changes: 9 additions & 7 deletions src/solver/optimisation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -188,14 +188,16 @@ else ()
endif ()
target_link_libraries(model_antares
PUBLIC
Antares::solverUtils
sirius_solver
antares-solver-simulation
Antares::benchmarking
Antares::optimization-options
Antares::lps
Antares::solverUtils
sirius_solver
antares-solver-simulation
Antares::benchmarking
Antares::optimization-options
Antares::lps
PRIVATE
infeasible_problem_analysis
infeasible_problem_analysis
Antares::modeler_api
Antares::modeler-ortools-impl
)

target_include_directories(model_antares
17 changes: 15 additions & 2 deletions src/solver/optimisation/opt_appel_solveur_lineaire.cpp
Original file line number Diff line number Diff line change
@@ -31,8 +31,13 @@
#include "antares/solver/simulation/sim_structure_probleme_economique.h"
#include "antares/solver/utils/filename.h"
#include "antares/solver/utils/mps_utils.h"
#include "antares/solver/modeler/api/fillers/LegacyOrtoolsFiller.h"
#include "antares/solver/modeler/api/linearProblemBuilder.h"
#include "antares/solver/modeler/ortoolsImpl/linearProblem.h"

using namespace operations_research;
using namespace Antares::Solver::Modeler::Api;
using namespace Antares::Solver::Modeler::OrtoolsImpl;

using Antares::Solver::IResultWriter;
using Antares::Solver::Optimization::OptimizationOptions;
@@ -201,9 +206,17 @@ static SimplexResult OPT_TryToCallSimplex(const OptimizationOptions& options,

Probleme.NombreDeContraintesCoupes = 0;

if (options.ortoolsUsed)
if (options.ortoolsUsed && solver == nullptr)
{
solver = ORTOOLS_ConvertIfNeeded(options.ortoolsSolver, &Probleme, solver);
auto legacyOrtoolsFiller = std::make_unique<LegacyOrtoolsFiller>();
std::vector<LinearProblemFiller*> fillersCollection = {legacyOrtoolsFiller.get()};
LinearProblemData LP_Data;
LinearProblemBuilder linearProblemBuilder(fillersCollection);
auto ortoolsProblem = std::make_unique<OrtoolsLinearProblem>(false, "sirius");
linearProblemBuilder.build(*ortoolsProblem, LP_Data);


solver = ConvertIntoOrtools(options.ortoolsSolver, &Probleme);
}
const std::string filename = createMPSfilename(optPeriodStringGenerator, optimizationNumber);

Original file line number Diff line number Diff line change
@@ -34,9 +34,8 @@ MPSolver* ORTOOLS_Simplexe(Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probl
bool keepBasis,
const Antares::Solver::Optimization::OptimizationOptions& options);

MPSolver* ORTOOLS_ConvertIfNeeded(const std::string& solverName,
const Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probleme,
MPSolver* solver);
MPSolver* ConvertIntoOrtools(const std::string& solverName,
const Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probleme);

void ORTOOLS_ModifierLeVecteurCouts(MPSolver* ProbSpx, const double* costs, int nbVar);
void ORTOOLS_ModifierLeVecteurSecondMembre(MPSolver* ProbSpx,
16 changes: 4 additions & 12 deletions src/solver/utils/ortools_utils.cpp
Original file line number Diff line number Diff line change
@@ -329,19 +329,11 @@ bool solveAndManageStatus(MPSolver* solver, int& resultStatus, const MPSolverPar
return resultStatus == OUI_SPX;
}

MPSolver* ORTOOLS_ConvertIfNeeded(const std::string& solverName,
const Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probleme,
MPSolver* solver)
MPSolver* ConvertIntoOrtools(const std::string& solverName,
const Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probleme)
{
if (solver == nullptr)
{
Antares::Optimization::ProblemSimplexeNommeConverter converter(solverName, Probleme);
return converter.Convert();
}
else
{
return solver;
}
Antares::Optimization::ProblemSimplexeNommeConverter converter(solverName, Probleme);
return converter.Convert();
}

MPSolver* ORTOOLS_Simplexe(Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probleme,