Skip to content

Commit

Permalink
implement HiGHS wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
hlefebvr committed Oct 22, 2023
1 parent 18f434f commit b683d7f
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 481 deletions.
17 changes: 3 additions & 14 deletions examples/knapsack-problem/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "idol/optimizers/callbacks/LocalBranching.h"
#include "idol/optimizers/branch-and-bound/branching-rules/factories/VariableBranching.h"
#include "idol/optimizers/branch-and-bound/branching-rules/factories/MostInfeasible.h"
#include "idol/optimizers/solvers/HiGHS.h"

int main(int t_argc, const char** t_argv) {

Expand All @@ -36,29 +37,17 @@ int main(int t_argc, const char** t_argv) {
model.set_obj_expr(idol_Sum(j, Range(n_items), -instance.profit(j) * x[j]));

// Set optimizer
//model.use(Gurobi());
model.use(
BranchAndBound()
.with_node_optimizer(Gurobi::ContinuousRelaxation())
.with_node_optimizer(HiGHS::ContinuousRelaxation())
.with_branching_rule(
MostInfeasible()
)
.with_node_selection_rule(BestBound())
//.with_cutting_planes(CoverCuts().with_optimizer(Gurobi()))
/*
.with_callback(
Heuristics::RENS()
.with_optimizer(
BranchAndBound()
.with_node_optimizer(Gurobi::ContinuousRelaxation())
.with_branching_rule(MostInfeasible())
.with_node_selection_rule(BestBound())
.with_log_level(Info, Green)
)
) */
.with_log_level(Info, Blue)
.with_log_frequency(1)
);
// model.use(HiGHS());
// Solve
model.optimize();

Expand Down
10 changes: 1 addition & 9 deletions lib/include/idol/optimizers/solvers/Optimizers_HiGHS.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ class idol::Optimizers::HiGHS : public OptimizerWithLazyUpdates<int, int> {

bool m_continuous_relaxation;

::Highs m_solver;
bool m_solved_as_mip = false;
::Highs m_model;

SolutionStatus m_solution_status = Loaded;
SolutionReason m_solution_reason = NotSpecified;
std::optional<Solution::Primal> m_unbounded_ray;
std::optional<Solution::Dual> m_farkas_certificate;

std::stack<int> m_deleted_variables;
std::stack<int> m_deleted_constraints;
Expand Down Expand Up @@ -62,11 +59,6 @@ class idol::Optimizers::HiGHS : public OptimizerWithLazyUpdates<int, int> {

void set_ctr_attr(int t_index, int t_type, double t_rhs);

void save_simplex_solution_status();
void compute_farkas_certificate();
void compute_unbounded_ray();
void save_milp_solution_status();

[[nodiscard]] SolutionStatus get_status() const override;
[[nodiscard]] SolutionReason get_reason() const override;
[[nodiscard]] double get_best_obj() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace idol::Problems::MKP {
}

/**
* See also https://en.wikipedia.org/wiki/Generalized_assignment_problem.
* See also https://en.wikipedia.org/wiki/Knapsack_problem.
*/
class idol::Problems::MKP::Instance {
protected:
Expand Down
Loading

0 comments on commit b683d7f

Please sign in to comment.