22 friend class ::idol::GurobiCallbackI;
23 static std::unique_ptr<GRBEnv> s_global_env;
25 static GRBEnv& get_global_env();
29 bool m_continuous_relaxation;
31 std::unique_ptr<GurobiCallbackI> m_gurobi_callback;
33 char gurobi_var_type(
int t_type);
34 static char gurobi_ctr_type(
int t_type);
35 static char gurobi_obj_sense(
int t_sense);
36 static double gurobi_numeric(
double t_value);
37 static VarType idol_var_type(
char t_type);
38 static CtrType idol_ctr_type(
char t_type);
39 static ObjectiveSense idol_obj_sense(
int t_sense);
40 [[nodiscard]] std::pair<SolutionStatus, SolutionReason> gurobi_status(
int t_status)
const;
42 void hook_build()
override;
43 void hook_optimize()
override;
44 void hook_write(
const std::string &t_name)
override;
45 GRBVar hook_add(
const Var& t_var,
bool t_add_column)
override;
46 GRBConstr hook_add(
const Ctr& t_ctr)
override;
47 GRBQConstr hook_add(
const QCtr& t_ctr)
override;
48 GRBSOS hook_add(
const SOSCtr& t_ctr)
override;
49 void hook_update(
const Var& t_var)
override;
50 void hook_update(
const Ctr& t_ctr)
override;
51 void hook_update_objective_sense()
override;
52 void hook_update_matrix(
const Ctr &t_ctr,
const Var &t_var,
double t_constant)
override;
53 void hook_update_objective()
override;
54 void hook_update_rhs()
override;
55 void hook_update()
override;
56 void hook_remove(
const Var& t_var)
override;
57 void hook_remove(
const Ctr& t_ctr)
override;
58 void hook_remove(
const QCtr& t_ctr)
override;
59 void hook_remove(
const SOSCtr& t_ctr)
override;
60 void update_objective_constant();
62 [[nodiscard]] SolutionStatus get_status()
const override;
63 [[nodiscard]] SolutionReason get_reason()
const override;
64 [[nodiscard]]
double get_best_obj()
const override;
65 [[nodiscard]]
double get_best_bound()
const override;
66 [[nodiscard]]
double get_var_primal(
const Var &t_var)
const override;
67 [[nodiscard]]
double get_var_reduced_cost(
const Var &t_var)
const override;
68 [[nodiscard]]
double get_var_ray(
const Var &t_var)
const override;
69 [[nodiscard]]
double get_ctr_dual(
const Ctr &t_ctr)
const override;
70 [[nodiscard]]
double get_ctr_farkas(
const Ctr &t_ctr)
const override;
71 [[nodiscard]]
double get_relative_gap()
const override;
72 [[nodiscard]]
double get_absolute_gap()
const override;
73 [[nodiscard]]
unsigned int get_n_solutions()
const override;
74 [[nodiscard]]
unsigned int get_solution_index()
const override;
76 void set_solution_index(
unsigned int t_index)
override;
79 Gurobi(
const Model& t_model,
bool t_continuous_relaxation, GRBEnv& t_env);
80 explicit Gurobi(
const Model& t_model,
bool t_continuous_relaxation) :
Gurobi(t_model, t_continuous_relaxation, Gurobi::get_global_env()) {}
82 GRBEnv& env() {
return m_env; }
84 [[nodiscard]]
const GRBEnv& env()
const {
return m_env; }
86 GRBModel& model() {
return m_model; }
88 [[nodiscard]]
const GRBModel& model()
const {
return m_model; }
90 [[nodiscard]] std::string name()
const override {
return "Gurobi"; }
92 void set_param_time_limit(
double t_time_limit)
override;
94 void set_param_threads(
unsigned int t_thread_limit)
override;
96 void set_param_best_obj_stop(
double t_best_obj_stop)
override;
98 void set_param_best_bound_stop(
double t_best_bound_stop)
override;
100 void set_param_presolve(
bool t_value)
override;
102 void set_param_infeasible_or_unbounded_info(
bool t_value)
override;
104 void add_callback(
Callback* t_ptr_to_callback);
106 void set_lazy_cut(
bool t_value);
108 void set_max_n_solution_in_pool(
unsigned int t_value);
110 void set_param_logs(
bool t_value)
override;
112 void set_param(GRB_IntParam t_param,
int t_value);
114 void set_param(GRB_DoubleParam t_param,
double t_value);
116 void set_tol_mip_relative_gap(
double t_relative_gap_tolerance)
override;
118 void set_tol_mip_absolute_gap(
double t_absolute_gap_tolerance)
override;
120 void set_tol_feasibility(
double t_tol_feasibility)
override;
122 void set_tol_optimality(
double t_tol_optimality)
override;
124 void set_tol_integer(
double t_tol_integer)
override;
126 static Model read_from_file(
Env& t_env,
const std::string& t_filename);