Skip to content

Commit

Permalink
Expose method Write instead of relying on protected MpSolver method
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes committed Jan 8, 2025
1 parent 7edc1a0 commit ba6a212
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class ILinearProblem
/// Solve the problem, returns a IMipSolution
virtual IMipSolution* solve(bool verboseSolver) = 0;

virtual void Write(const std::string& filename) = 0;

// Definition of infinity
virtual double infinity() const = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion src/solver/modeler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int main(int argc, const char** argv)
{
logs.info() << "Writing problem.mps...";
auto mps_path = std::filesystem::current_path() / "problem.mps";
pb.MpSolver()->Write(mps_path.c_str());
pb.Write(mps_path.c_str());
}

logs.info() << "Launching resolution...";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class OrtoolsLinearProblem: public Api::ILinearProblem
bool isMaximization() const override;

OrtoolsMipSolution* solve(bool verboseSolver) override;
void Write(const std::string& filename) override;

double infinity() const override;

Expand Down
5 changes: 5 additions & 0 deletions src/solver/modeler/ortoolsImpl/linearProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ bool OrtoolsLinearProblem::isMaximization() const
return objective_->maximization();
}

void OrtoolsLinearProblem::Write(const std::string& filename)
{
mpSolver_->Write(filename);
}

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

0 comments on commit ba6a212

Please sign in to comment.