Skip to content

Commit

Permalink
Restore warm start for OR-Tools+XPRESS (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes authored Jan 10, 2023
1 parent 570cd82 commit 24e8d5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/solver/utils/named_problem.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct PROBLEME_SIMPLEXE_NOMME : public PROBLEME_SIMPLEXE

bool isMIP() const;
bool basisExists() const;
mutable bool solverSupportsWarmStart = false;
};
} // namespace Optimization
} // namespace Antares
22 changes: 17 additions & 5 deletions src/solver/utils/ortools_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ static void tuneSolverSpecificOptions(MPSolver* solver)
}
}

static bool solverSupportsWarmStart(const MPSolver* solver)
{
if (!solver)
return false;

switch (solver->ProblemType())
{
case MPSolver::XPRESS_LINEAR_PROGRAMMING:
return true;
default:
return false;
}
}

namespace Antares
{
namespace Optimization
Expand Down Expand Up @@ -286,8 +300,9 @@ MPSolver* ORTOOLS_Simplexe(Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probl
bool keepBasis)
{
MPSolverParameters params;
bool warmStart = solverSupportsWarmStart(solver);
// Provide an initial simplex basis, if any
if (Probleme->basisExists() && !Probleme->isMIP() && Probleme->solverSupportsWarmStart)
if (warmStart && Probleme->basisExists() && !Probleme->isMIP())
{
solver->SetStartingLpBasisInt(Probleme->StatutDesVariables, Probleme->StatutDesContraintes);
}
Expand All @@ -296,7 +311,7 @@ MPSolver* ORTOOLS_Simplexe(Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probl
{
extract_from_MPSolver(solver, Probleme);
// Save the final simplex basis for next resolutions
if (keepBasis && !Probleme->isMIP() && Probleme->solverSupportsWarmStart)
if (warmStart && keepBasis && !Probleme->isMIP())
{
solver->GetFinalLpBasisInt(Probleme->StatutDesVariables,
Probleme->StatutDesContraintes);
Expand Down Expand Up @@ -388,8 +403,5 @@ MPSolver* MPSolverFactory(const Antares::Optimization::PROBLEME_SIMPLEXE_NOMME*
AntaresSolverEmergencyShutdown();
}

if (solverName == "xpress")
probleme->solverSupportsWarmStart = true;

return solver;
}

0 comments on commit 24e8d5b

Please sign in to comment.