19 std::unique_ptr<OptimizerFactory> m_optimizer_factory;
21 std::optional<bool> m_integer_columns;
23 std::optional<double> m_time_limit;
24 std::optional<unsigned int> m_iteration_limit;
25 std::optional<unsigned int> m_max_depth;
26 std::optional<unsigned int> m_frequency;
38 std::unique_ptr<OptimizerFactory> m_optimizer_factory;
39 bool m_integer_columns =
true;
40 double m_time_limit = std::numeric_limits<double>::max();
41 unsigned int m_iteration_limit = std::numeric_limits<unsigned int>::max();
42 unsigned int m_max_depth = 1000;
43 unsigned int m_frequency = 1;
44 unsigned int m_n_relevant_calls = 0;
46 void operator()(CallbackEvent t_event)
override;
50 [[nodiscard]]
bool with_integer_columns()
const {
return m_integer_columns; }
52 void set_integer_columns(
bool t_value) { m_integer_columns = t_value; }
54 void set_time_limit(
double t_time_limit) { m_time_limit = std::max(0., t_time_limit); }
56 void set_iteration_limit(
unsigned int t_iteration_limit) { m_iteration_limit = t_iteration_limit; }
58 void set_max_depth(
unsigned int t_max_depth) { m_max_depth = t_max_depth; }
60 void set_frequency(
unsigned int t_frequency) { m_frequency = t_frequency; }
73 IntegerMaster& with_iteration_limit(
unsigned int t_iteration_limit);
178 if (t_event != InvalidSolution) {
182 if (m_max_depth < this->node().level()) {
186 unsigned int n_relevant_calls = m_n_relevant_calls++;
188 if ( n_relevant_calls % m_frequency != 0) {
192 const auto& relaxation = this->relaxation();
193 const auto& dantzig_wolfe_optimizer = relaxation.optimizer().template as<Optimizers::DantzigWolfeDecomposition>();
194 const auto& original_model = this->original_model();
195 const auto& formulation = dantzig_wolfe_optimizer.formulation();
196 const unsigned int n_sub_problems = formulation.n_sub_problems();
198 std::unique_ptr<Model> integer_master_new(relaxation.clone());
202 for (
unsigned int k = 0 ; k < n_sub_problems ; ++k) {
203 for (
const auto& [var, col] : formulation.present_generators(k)) {
204 dw.formulation().generate_column(k, col);
209 if (m_integer_columns) {
210 for (
unsigned int i = 0 ; i < n_sub_problems ; ++i) {
211 for (
const auto &[alpha, generator]: dw.formulation().present_generators(i)) {
212 dw.formulation().master().set_var_type(alpha, Binary);
218 dw.set_master_optimizer_factory(*m_optimizer_factory);
221 dw.set_param_logs(
false);
222 dw.set_param_iteration_limit(0);
223 dw.set_param_time_limit(std::min(m_time_limit, relaxation.optimizer().get_remaining_time()));
226 auto& branch_and_bound = this->original_model().optimizer().template as<Optimizers::BranchAndBound<NodeInfoT>>();;
227 dw.set_param_best_bound_stop(branch_and_bound.get_best_obj());
229 integer_master_new->optimize();
231 const int status = integer_master_new->get_status();
233 if (status != Optimal && status != Feasible) {
237 auto* info =
new NodeInfoT();
238 info->save(original_model, *integer_master_new);
239 this->submit_heuristic_solution(info);