idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
KKT.h
1//
2// Created by henri on 29.11.24.
3//
4
5#ifndef IDOL_BILEVEL_KKT_H
6#define IDOL_BILEVEL_KKT_H
7
8#include "idol/general/optimizers/OptimizerFactory.h"
9#include "idol/bilevel/modeling/Description.h"
10#include "idol/bilevel/optimizers/BilevelOptimizerInterface.h"
11#include "idol/mixed-integer/modeling/models/KKT.h"
12
13namespace idol::Bilevel {
14 class KKT;
15}
16
18 const Bilevel::Description* m_description = nullptr;
19 std::unique_ptr<OptimizerFactory> m_single_level_optimizer;
20 std::unique_ptr<Reformulators::KKT::BoundProvider> m_bound_provider;
21 std::optional<bool> m_use_sos1;
22 std::optional<bool> m_use_kleinart_cuts;
23public:
24 KKT() = default;
25
26 explicit KKT(const Bilevel::Description& t_description);
27
28 KKT(const Bilevel::Description& t_description, const Reformulators::KKT::BoundProvider& t_bound_provider);
29
30 KKT(const KKT& t_src);
31
32 void set_bilevel_description(const Description &t_bilevel_description) override;
33
34 Optimizer *operator()(const Model &t_model) const override;
35
36 [[nodiscard]] OptimizerFactory *clone() const override;
37
38 KKT& with_single_level_optimizer(const OptimizerFactory& t_deterministic_optimizer);
39
40 KKT& with_bound_provider(const Reformulators::KKT::BoundProvider& t_bound_provider);
41
42 KKT& with_sos1_constraints(bool t_value);
43
44 KKT& with_kleinart_cuts(bool t_value);
45
46 KKT& operator+=(const OptimizerFactory& t_optimizer) { return with_single_level_optimizer(t_optimizer); }
47
48 static Model make_model(const Model& t_model, const Bilevel::Description& t_description, bool t_use_sos1 = false);
49
50 static Model make_model(const Model& t_model, const Bilevel::Description& t_description, Reformulators::KKT::BoundProvider& t_bound_provider);
51};
52
53namespace idol {
54 static Bilevel::KKT operator+(const Bilevel::KKT& t_strong_duality, const OptimizerFactory& t_optimizer) {
55 Bilevel::KKT result(t_strong_duality);
56 result += t_optimizer;
57 return result;
58 }
59}
60
61#endif //IDOL_BILEVEL_KKT_H
Optimizer * operator()(const Model &t_model) const override
OptimizerFactory * clone() const override