idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
ArtificialCosts.h
1//
2// Created by henri on 31.10.23.
3//
4
5#ifndef IDOL_ARTIFICIALCOSTS_H
6#define IDOL_ARTIFICIALCOSTS_H
7
8#include "DantzigWolfeInfeasibilityStrategy.h"
9#include "idol/mixed-integer/optimizers/dantzig-wolfe/ColumnGeneration.h"
10
11namespace idol::DantzigWolfe {
12 class ArtificialCosts;
13}
14
16 std::optional<double> m_initial_costs;
17 std::optional<double> m_update_factor;
18 std::optional<unsigned int> m_max_updates_before_phase_I;
19public:
20
22 double m_initial_costs;
23 double m_update_factor;
24 unsigned int m_max_updates_before_phase_I;
25
26 QuadExpr<Var> m_objective_function;
27 std::list<Var> m_artificial_variables;
28
29 void save_objective_function(const Model& t_original_formulation);
30 void create_artificial_variables(DantzigWolfe::Formulation& t_formulation);
31 void find_initial_columns(idol::Optimizers::DantzigWolfeDecomposition::ColumnGeneration &t_column_generation);
32 void delete_artificial_variables(DantzigWolfe::Formulation& t_formulation);
33 bool all_artificial_variables_are_non_basic(const PrimalPoint &t_primal_values) const;
34 void update_objective_function(DantzigWolfe::Formulation& t_formulation, const PrimalPoint& t_primal_values, bool t_include_original_objective_function);
35 void restore_objective_function(DantzigWolfe::Formulation& t_formulation);
36 public:
37 Strategy(double t_initial_costs, double t_update_factor, unsigned int t_max_updates_before_phase_I);
38
39 void execute(Optimizers::DantzigWolfeDecomposition &t_parent) override;
40 };
41
42 InfeasibilityStrategyFactory::Strategy *operator()() const override {
43 return new Strategy(
44 m_initial_costs.has_value() ? m_initial_costs.value() : 1e4,
45 m_update_factor.has_value() ? m_update_factor.value() : 2.,
46 m_max_updates_before_phase_I.has_value() ? m_max_updates_before_phase_I.value() : 4
47 );
48 }
49
50 [[nodiscard]] ArtificialCosts *clone() const override {
51 return new ArtificialCosts(*this);
52 }
53
54 ArtificialCosts& with_max_updates_before_phase_I(unsigned int t_value);
55
56 ArtificialCosts& with_update_factor(double t_value);
57
58 ArtificialCosts& with_initial_costs(double t_value);
59
60};
61
62#endif //IDOL_ARTIFICIALCOSTS_H