diff --git a/src/solver/modeler/api/include/antares/solver/modeler/api/linearProblem.h b/src/solver/modeler/api/include/antares/solver/modeler/api/linearProblem.h index 17cd8c6f8b..dffc7f874c 100644 --- a/src/solver/modeler/api/include/antares/solver/modeler/api/linearProblem.h +++ b/src/solver/modeler/api/include/antares/solver/modeler/api/linearProblem.h @@ -72,7 +72,7 @@ class ILinearProblem /// Solve the problem, returns a IMipSolution virtual IMipSolution* solve(bool verboseSolver) = 0; - virtual void Write(const std::string& filename) = 0; + virtual void WriteLP(const std::string& filename) = 0; // Definition of infinity virtual double infinity() const = 0; diff --git a/src/solver/modeler/main.cpp b/src/solver/modeler/main.cpp index 4b52470f83..43bfc19593 100644 --- a/src/solver/modeler/main.cpp +++ b/src/solver/modeler/main.cpp @@ -83,9 +83,9 @@ int main(int argc, const char** argv) if (!parameters.noOutput) { - logs.info() << "Writing problem.mps..."; - auto mps_path = std::filesystem::current_path() / "problem.mps"; - pb.Write(mps_path.c_str()); + logs.info() << "Writing problem.lp..."; + auto mps_path = std::filesystem::current_path() / "problem.lp"; + pb.WriteLP(mps_path.c_str()); } logs.info() << "Launching resolution..."; diff --git a/src/solver/modeler/ortoolsImpl/include/antares/solver/modeler/ortoolsImpl/linearProblem.h b/src/solver/modeler/ortoolsImpl/include/antares/solver/modeler/ortoolsImpl/linearProblem.h index 4cf5b72e90..f4a2fed61e 100644 --- a/src/solver/modeler/ortoolsImpl/include/antares/solver/modeler/ortoolsImpl/linearProblem.h +++ b/src/solver/modeler/ortoolsImpl/include/antares/solver/modeler/ortoolsImpl/linearProblem.h @@ -65,7 +65,7 @@ class OrtoolsLinearProblem: public Api::ILinearProblem bool isMaximization() const override; OrtoolsMipSolution* solve(bool verboseSolver) override; - void Write(const std::string& filename) override; + void WriteLP(const std::string& filename) override; double infinity() const override; diff --git a/src/solver/modeler/ortoolsImpl/linearProblem.cpp b/src/solver/modeler/ortoolsImpl/linearProblem.cpp index df07989c29..20c302c9fd 100644 --- a/src/solver/modeler/ortoolsImpl/linearProblem.cpp +++ b/src/solver/modeler/ortoolsImpl/linearProblem.cpp @@ -20,6 +20,7 @@ */ #include +#include #include #include @@ -165,9 +166,12 @@ bool OrtoolsLinearProblem::isMaximization() const return objective_->maximization(); } -void OrtoolsLinearProblem::Write(const std::string& filename) +void OrtoolsLinearProblem::WriteLP(const std::string& filename) { - mpSolver_->Write(filename); + std::string out; + mpSolver_->ExportModelAsLpFormat(false, &out); + std::ofstream of(filename); + of << out; } MPSolver* OrtoolsLinearProblem::MpSolver() const