idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
Optimizers_Osi.h
1//
2// Created by henri on 05.02.24.
3//
4
5#ifndef IDOL_OPTIMIZERS_OSI_H
6#define IDOL_OPTIMIZERS_OSI_H
7
8#ifdef IDOL_USE_OSI
9
10#include <OsiSolverInterface.hpp>
11#include <stack>
12#include "idol/general/optimizers/OptimizerWithLazyUpdates.h"
13
14namespace idol::Optimizers {
15 class Osi;
16}
17
18class idol::Optimizers::Osi : public OptimizerWithLazyUpdates<int, int, int, int> {
19 bool m_continuous_relaxation;
20 bool m_is_resolve = false;
21
22 std::unique_ptr<OsiSolverInterface> m_solver_interface;
23public:
24 [[nodiscard]] std::string name() const override;
25 [[nodiscard]] SolutionStatus get_status() const override;
26 [[nodiscard]] SolutionReason get_reason() const override;
27 [[nodiscard]] double get_best_obj() const override;
28 [[nodiscard]] double get_best_bound() const override;
29 [[nodiscard]] double get_var_primal(const Var &t_var) const override;
30 [[nodiscard]] double get_var_reduced_cost(const Var &t_var) const override;
31 [[nodiscard]] double get_var_ray(const Var &t_var) const override;
32 [[nodiscard]] double get_ctr_dual(const Ctr &t_ctr) const override;
33 [[nodiscard]] double get_ctr_farkas(const Ctr &t_ctr) const override;
34 [[nodiscard]] double get_relative_gap() const override;
35 [[nodiscard]] double get_absolute_gap() const override;
36 [[nodiscard]] unsigned int get_n_solutions() const override;
37 [[nodiscard]] unsigned int get_solution_index() const override;
38
39protected:
40 void hook_optimize() override;
41 void set_solution_index(unsigned int t_index) override;
42 void hook_build() override;
43 void hook_write(const std::string &t_name) override;
44 int hook_add(const Var &t_var, bool t_add_column) override;
45 int hook_add(const Ctr &t_ctr) override;
46 int hook_add(const QCtr &t_ctr) override;
47 int hook_add(const SOSCtr &t_ctr) override;
48 void hook_update_objective_sense() override;
49 void hook_update_matrix(const Ctr &t_ctr, const Var &t_var, double t_constant) override;
50 void hook_update() override;
51 void hook_update(const Var &t_var) override;
52 void hook_update(const Ctr &t_ctr) override;
53 void hook_update_objective() override;
54 void hook_update_rhs() override;
55 void hook_remove(const Var &t_var) override;
56 void hook_remove(const Ctr &t_ctr) override;
57 void hook_remove(const QCtr &t_ctr) override;
58 void hook_remove(const SOSCtr &t_ctr) override;
59public:
60 Osi(const Model& t_model, const OsiSolverInterface& t_solver_interface, bool t_continuous_relaxation);
61
62 void set_param_logs(bool t_value) override;
63
64 void set_param_presolve(bool t_value) override;
65};
66
67#endif
68
69#endif //IDOL_OPTIMIZERS_OSI_H