From 3652bd42276a5e723cf442db29c3e3316ad1048a Mon Sep 17 00:00:00 2001 From: Charlie Vanaret Date: Mon, 11 Nov 2024 11:56:52 +0100 Subject: [PATCH] HiGHS (LP solver): detect infeasible and unbounded subproblems --- uno/solvers/HiGHS/HiGHSSolver.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/uno/solvers/HiGHS/HiGHSSolver.cpp b/uno/solvers/HiGHS/HiGHSSolver.cpp index e0d29943..46110e29 100644 --- a/uno/solvers/HiGHS/HiGHSSolver.cpp +++ b/uno/solvers/HiGHS/HiGHSSolver.cpp @@ -88,12 +88,11 @@ namespace uno { } } - - void HiGHSSolver::solve_subproblem(Direction& direction, size_t number_variables, size_t number_constraints) { // solve the LP HighsStatus return_status = this->highs_solver.passModel(this->model); assert(return_status == HighsStatus::kOk); + return_status = this->highs_solver.run(); // solve DEBUG << "HiGHS status: " << static_cast(return_status) << '\n'; @@ -102,8 +101,18 @@ namespace uno { direction.status = SubproblemStatus::ERROR; return; } + HighsModelStatus model_status = highs_solver.getModelStatus(); + DEBUG << "HiGHS model status: " << static_cast(model_status) << '\n'; - // TODO check unbounded problems + if (model_status == HighsModelStatus::kInfeasible) { + direction.status = SubproblemStatus::INFEASIBLE; + return; + } + else if (model_status == HighsModelStatus::kUnbounded) { + direction.status = SubproblemStatus::UNBOUNDED_PROBLEM; + return; + } + direction.status = SubproblemStatus::OPTIMAL; const HighsSolution& solution = this->highs_solver.getSolution(); // read the primal solution and bound dual solution