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
Merged
Show file tree
Hide file tree
Changes from 18 commits
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
62863e7
PR comments
pet-mit Oct 22, 2024
5237a6f
remove useless include
pet-mit Oct 23, 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
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ jobs:
os: ${{ env.os }}

- name: Run parallel tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
pet-mit marked this conversation as resolved.
Show resolved Hide resolved
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand All @@ -275,7 +275,7 @@ jobs:
variant: "tsgenerator"

- name: Run medium-tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
pet-mit marked this conversation as resolved.
Show resolved Hide resolved
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ jobs:
os: ${{ env.os }}

- name: Run parallel tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
pet-mit marked this conversation as resolved.
Show resolved Hide resolved
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand All @@ -277,7 +277,7 @@ jobs:
variant: "tsgenerator"

- name: Run medium-tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
pet-mit marked this conversation as resolved.
Show resolved Hide resolved
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
Expand Down
2 changes: 1 addition & 1 deletion simtest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v9.2.0e"
"version": "v9.2.0.d-ortools"
}
43 changes: 22 additions & 21 deletions src/packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class ILinearProblem
virtual IMipVariable* addNumVariable(double lb, double ub, const std::string& name) = 0;
/// Create a integer variable
virtual IMipVariable* addIntVariable(double lb, double ub, const std::string& name) = 0;
/// Create a continuous or integer variable
virtual IMipVariable* addVariable(double lb, double ub, bool integer, const std::string& name)
= 0;
virtual IMipVariable* getVariable(const std::string& name) const = 0;
virtual int variableCount() const = 0;

Expand All @@ -68,6 +71,9 @@ class ILinearProblem

/// Solve the problem, returns a IMipSolution
virtual IMipSolution* solve(bool verboseSolver) = 0;

// Definition of infinity
virtual double infinity() const = 0;
};

} // namespace Antares::Solver::Modeler::Api
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ class MPObjective;
namespace Antares::Solver::Modeler::OrtoolsImpl
{

class OrtoolsLinearProblem final: public Api::ILinearProblem
flomnes marked this conversation as resolved.
Show resolved Hide resolved
class OrtoolsLinearProblem: public Api::ILinearProblem
{
public:
OrtoolsLinearProblem(bool isMip, const std::string& solverName);
~OrtoolsLinearProblem() override = default;

OrtoolsMipVariable* addNumVariable(double lb, double ub, const std::string& name) override;
OrtoolsMipVariable* addIntVariable(double lb, double ub, const std::string& name) override;
OrtoolsMipVariable* addVariable(double lb,
double ub,
bool integer,
const std::string& name) override;
OrtoolsMipVariable* getVariable(const std::string& name) const override;
int variableCount() const override;

Expand All @@ -62,10 +66,13 @@ class OrtoolsLinearProblem final: public Api::ILinearProblem

OrtoolsMipSolution* solve(bool verboseSolver) override;

private:
OrtoolsMipVariable* addVariable(double lb, double ub, bool integer, const std::string& name);
double infinity() const override;

protected:
operations_research::MPSolver* MpSolver() const;

std::shared_ptr<operations_research::MPSolver> mpSolver_;
private:
operations_research::MPSolver* mpSolver_;
pet-mit marked this conversation as resolved.
Show resolved Hide resolved
operations_research::MPObjective* objective_;
operations_research::MPSolverParameters params_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OrtoolsMipSolution final: public Api::IMipSolution
{
public:
OrtoolsMipSolution(operations_research::MPSolver::ResultStatus& responseStatus,
std::shared_ptr<operations_research::MPSolver> solver);
operations_research::MPSolver* solver);

~OrtoolsMipSolution() override = default;

Expand All @@ -47,7 +47,7 @@ class OrtoolsMipSolution final: public Api::IMipSolution

private:
operations_research::MPSolver::ResultStatus status_;
std::shared_ptr<operations_research::MPSolver> mpSolver_;
operations_research::MPSolver* mpSolver_;
std::map<std::string, double> solution_;
};

Expand Down
22 changes: 12 additions & 10 deletions src/solver/modeler/ortoolsImpl/linearProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,8 @@ namespace Antares::Solver::Modeler::OrtoolsImpl

OrtoolsLinearProblem::OrtoolsLinearProblem(bool isMip, const std::string& solverName)
{
auto* mpSolver = isMip ? MPSolver::CreateSolver(
(OrtoolsUtils::solverMap.at(solverName)).MIPSolverName)
: MPSolver::CreateSolver(
(OrtoolsUtils::solverMap.at(solverName)).LPSolverName);

mpSolver_ = std::unique_ptr<operations_research::MPSolver>(mpSolver);
objective_ = mpSolver->MutableObjective();

params_.SetIntegerParam(MPSolverParameters::SCALING, 0);
params_.SetIntegerParam(MPSolverParameters::PRESOLVE, 0);
mpSolver_ = MPSolverFactory(isMip, solverName);
objective_ = mpSolver_->MutableObjective();
}

class ElemAlreadyExists: public std::exception
Expand Down Expand Up @@ -172,6 +164,11 @@ bool OrtoolsLinearProblem::isMaximization() const
return objective_->maximization();
}

MPSolver* OrtoolsLinearProblem::MpSolver() const
{
return mpSolver_;
}

OrtoolsMipSolution* OrtoolsLinearProblem::solve(bool verboseSolver)
{
if (verboseSolver)
Expand All @@ -185,4 +182,9 @@ OrtoolsMipSolution* OrtoolsLinearProblem::solve(bool verboseSolver)
return solution_.get();
}

double OrtoolsLinearProblem::infinity() const
{
return MPSolver::infinity();
}

} // namespace Antares::Solver::Modeler::OrtoolsImpl
2 changes: 1 addition & 1 deletion src/solver/modeler/ortoolsImpl/mipSolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Antares::Solver::Modeler::OrtoolsImpl
{

OrtoolsMipSolution::OrtoolsMipSolution(operations_research::MPSolver::ResultStatus& status,
std::shared_ptr<operations_research::MPSolver> solver):
operations_research::MPSolver* solver):
status_(status),
mpSolver_(solver)
{
Expand Down
Loading
Loading