21 bool m_continuous_relaxation;
23 glp_prob* m_model =
nullptr;
24 glp_smcp m_simplex_parameters;
25 glp_iocp m_mip_parameters;
26 bool m_solved_as_mip =
false;
27 bool m_rebuild_basis =
false;
29 SolutionStatus m_solution_status = Loaded;
30 SolutionReason m_solution_reason = NotSpecified;
31 std::optional<PrimalPoint> m_unbounded_ray;
32 std::optional<DualPoint> m_farkas_certificate;
34 std::stack<int> m_deleted_variables;
35 std::stack<int> m_deleted_constraints;
37 void hook_build()
override;
39 void hook_optimize()
override;
41 void hook_write(
const std::string &t_name)
override;
43 int hook_add(
const Var &t_var,
bool t_add_column)
override;
45 int hook_add(
const Ctr &t_ctr)
override;
47 int hook_add(
const QCtr &t_ctr)
override;
49 int hook_add(
const SOSCtr &t_ctr)
override;
51 void hook_update_objective_sense()
override;
53 void hook_update_matrix(
const Ctr &t_ctr,
const Var &t_var,
double t_constant)
override;
55 void hook_update()
override;
57 void hook_update(
const Var &t_var)
override;
59 void hook_update(
const Ctr &t_ctr)
override;
61 void hook_update_objective()
override;
63 void hook_update_rhs()
override;
65 void hook_remove(
const Var &t_var)
override;
67 void hook_remove(
const Ctr &t_ctr)
override;
69 void hook_remove(
const QCtr &t_ctr)
override;
71 void hook_remove(
const SOSCtr &t_ctr)
override;
73 void set_var_attr(
int t_index,
int t_type,
double t_lb,
double t_ub,
double t_obj);
75 void set_ctr_attr(
int t_index,
int t_type,
double t_rhs);
77 void save_simplex_solution_status();
78 void compute_farkas_certificate();
79 void compute_unbounded_ray();
80 void save_milp_solution_status();
82 [[nodiscard]] SolutionStatus get_status()
const override;
83 [[nodiscard]] SolutionReason get_reason()
const override;
84 [[nodiscard]]
double get_best_obj()
const override;
85 [[nodiscard]]
double get_best_bound()
const override;
86 [[nodiscard]]
double get_var_primal(
const Var &t_var)
const override;
87 [[nodiscard]]
double get_var_reduced_cost(
const Var &t_var)
const override;
88 [[nodiscard]]
double get_var_ray(
const Var &t_var)
const override;
89 [[nodiscard]]
double get_ctr_dual(
const Ctr &t_ctr)
const override;
90 [[nodiscard]]
double get_ctr_farkas(
const Ctr &t_ctr)
const override;
91 [[nodiscard]]
double get_relative_gap()
const override;
92 [[nodiscard]]
double get_absolute_gap()
const override;
93 [[nodiscard]]
unsigned int get_n_solutions()
const override;
94 [[nodiscard]]
unsigned int get_solution_index()
const override;
95 void set_solution_index(
unsigned int t_index)
override;
98 static Model read_from_lp_file(
Env& t_env,
const std::string& t_filename);
99 static Model read_from_mps_file(
Env& t_env,
const std::string& t_filename);
101 explicit GLPK(
const Model& t_model,
bool t_continuous_relaxation);
103 [[nodiscard]] std::string name()
const override {
return "GLPK"; }
105 void set_param_time_limit(
double t_time_limit)
override;
107 void set_param_best_obj_stop(
double t_best_obj_stop)
override;
109 void set_param_best_bound_stop(
double t_best_bound_stop)
override;
111 void set_param_presolve(
bool t_value)
override;
113 void set_param_logs(
bool t_value)
override;
115 static Model read_from_file(
Env& t_env,
const std::string& t_filename);