A C++ Framework for Optimization
Loading...
Searching...
No Matches
Optimizers_BranchAndCut.h
1//
2// Created by henri on 11.04.25.
3//
4
5#ifndef IDOL_BILEVEL_OPTIMIZERS_BRANCHANDCUT_H
6#define IDOL_BILEVEL_OPTIMIZERS_BRANCHANDCUT_H
7
8#include "idol/general/optimizers/Algorithm.h"
9#include "idol/bilevel/modeling/Description.h"
10#include "idol/general/utils/GenerationPattern.h"
11
12namespace idol::Optimizers::Bilevel {
13 class BranchAndCut;
14}
15
17 const ::idol::Bilevel::Description& m_description;
18 std::unique_ptr<OptimizerFactory> m_optimizer_for_sub_problems;
19 std::unique_ptr<Model> m_hpr;
20 std::unique_ptr<Model> m_separation_problem;
21 std::vector<Var> m_linking_upper_variables;
22 std::optional<Var> m_pi;
23 std::vector<Var> m_lambda;
24
25 void check_value_function_is_well_posed();
26 void check_assumptions();
27 void build_separation_problem();
28 std::tuple<double, double, double, double> compute_big_M(const Model& t_model);
29 void build_hpr(double t_lambda_lb, double t_lambda_ub, double t_pi_lb, double t_pi_ub);
30 GenerationPattern<Ctr> build_dantzig_wolfe_cut();
31
32 class BoundTighteningCallback;
33public:
34 BranchAndCut(const Model& t_parent,
35 const ::idol::Bilevel::Description& t_description,
36 const OptimizerFactory& t_optimizer_for_sub_problems);
37
38 [[nodiscard]] std::string name() const override;
39 [[nodiscard]] double get_var_primal(const Var &t_var) const override;
40 [[nodiscard]] double get_var_reduced_cost(const Var &t_var) const override;
41 [[nodiscard]] double get_var_ray(const Var &t_var) const override;
42 [[nodiscard]] double get_ctr_dual(const Ctr &t_ctr) const override;
43 [[nodiscard]] double get_ctr_farkas(const Ctr &t_ctr) const override;
44 [[nodiscard]] unsigned int get_n_solutions() const override;
45 [[nodiscard]] unsigned int get_solution_index() const override;
46
47protected:
48 void add(const Var &t_var) override;
49 void add(const Ctr &t_ctr) override;
50 void add(const QCtr &t_ctr) override;
51 void remove(const Var &t_var) override;
52 void remove(const Ctr &t_ctr) override;
53 void remove(const QCtr &t_ctr) override;
54 void update() override;
55 void write(const std::string &t_name) override;
56 void hook_before_optimize() override;
57 void hook_optimize() override;
58 void set_solution_index(unsigned int t_index) override;
59 void update_obj_sense() override;
60 void update_obj() override;
61 void update_rhs() override;
62 void update_obj_constant() override;
63 void update_mat_coeff(const Ctr &t_ctr, const Var &t_var) override;
64 void update_ctr_type(const Ctr &t_ctr) override;
65 void update_ctr_rhs(const Ctr &t_ctr) override;
66 void update_var_type(const Var &t_var) override;
67 void update_var_lb(const Var &t_var) override;
68 void update_var_ub(const Var &t_var) override;
69 void update_var_obj(const Var &t_var) override;
70};
71
72#endif //IDOL_BILEVEL_OPTIMIZERS_BRANCHANDCUT_H