Skip to content

Commit

Permalink
handle return status of HiGHS
Browse files Browse the repository at this point in the history
  • Loading branch information
hlefebvr committed Nov 2, 2023
1 parent de991f3 commit 5c5868e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class idol::Optimizers::HiGHS : public OptimizerWithLazyUpdates<int, int> {
[[nodiscard]] unsigned int get_solution_index() const override;
void set_solution_index(unsigned int t_index) override;

void analyze_status();
void analyze_status(HighsStatus t_status);
public:
explicit HiGHS(const Model& t_model, bool t_continuous_relaxation);

Expand Down
23 changes: 17 additions & 6 deletions lib/src/optimizers/wrappers/HiGHS/Optimizers_HiGHS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ void idol::Optimizers::HiGHS::hook_optimize() {
delete[] m_farkas_certificate;
m_farkas_certificate = nullptr;

m_model.run();
auto result = m_model.run();

analyze_status();
analyze_status(result);

if (m_solution_status == Fail) {
m_model.clearSolver();
m_model.run();
analyze_status();
result = m_model.run();
analyze_status(result);
}

if (get_param_infeasible_or_unbounded_info() && m_solution_status == Unbounded) {
Expand Down Expand Up @@ -322,7 +322,13 @@ void idol::Optimizers::HiGHS::hook_optimize() {

}

void idol::Optimizers::HiGHS::analyze_status() {
void idol::Optimizers::HiGHS::analyze_status(HighsStatus t_status) {

if (t_status != HighsStatus::kOk) {
m_solution_status = Fail;
m_solution_reason = NotSpecified;
return;
}

const auto status = m_model.getModelStatus();

Expand Down Expand Up @@ -378,8 +384,13 @@ void idol::Optimizers::HiGHS::run_without_presolve() {
return;
}
m_model.setOptionValue("presolve", "off");
m_model.run();
auto result = m_model.run();
m_model.setOptionValue("presolve", old_presolve_setting);

if (result != HighsStatus::kOk) {
m_solution_status = Fail;
m_solution_reason = NotSpecified;
}
}

void idol::Optimizers::HiGHS::set_param_time_limit(double t_time_limit) {
Expand Down

0 comments on commit 5c5868e

Please sign in to comment.