idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
Info.h
1//
2// Created by henri on 06.11.23.
3//
4
5#ifndef IDOL_LOGS_DANTZIGWOLFE_INFO_H
6#define IDOL_LOGS_DANTZIGWOLFE_INFO_H
7
8#include "Factory.h"
9#include "idol/general/utils/types.h"
10#include <optional>
11
12namespace idol::Logs::DantzigWolfe {
13 class Info;
14}
15
17 std::optional<unsigned int> m_frequency_in_seconds;
18 std::optional<bool> m_log_for_sub_problems;
19public:
21 const double m_frequency_in_seconds;
22 bool m_log_for_sub_problems;
23 double m_last_log_timestamp = 0;
24 bool m_sub_problems_should_currently_be_logged = false;
25 public:
26 Strategy(unsigned int t_frequency, bool t_log_sub_problems);
27
28 void log_init(unsigned int t_n_sub_problems) override;
29
30 void log_master(unsigned int t_iteration,
31 double t_total_time,
32 SolutionStatus t_problem_status,
33 SolutionStatus t_last_master_status,
34 SolutionReason t_last_master_reason,
35 double t_last_master_objective,
36 double t_last_master_time,
37 double t_best_bound,
38 double t_best_obj,
39 unsigned int t_n_generated_columns,
40 unsigned int t_n_present_columns) override;
41
42 void log_sub_problem(unsigned int t_iteration,
43 double t_total_time,
44 unsigned int t_sub_problem_id,
45 SolutionStatus t_problem_status,
46 SolutionStatus t_sub_problem_status,
47 SolutionReason t_sub_problem_reason,
48 double t_sub_problem_objective,
49 double t_sub_problem_time,
50 double t_best_bound,
51 double t_best_obj,
52 unsigned int t_n_generated_columns,
53 unsigned int t_n_present_columns) override;
54
55 void log_end() override;
56 };
57
58 Info& with_frequency_in_seconds(double t_frequency);
59
60 Info& with_sub_problems(bool t_value);
61
62 Strategy *operator()() const override {
63 return new Strategy(
64 m_frequency_in_seconds.has_value() ? m_frequency_in_seconds.value() : 5,
65 m_log_for_sub_problems.has_value() && m_log_for_sub_problems.value()
66 );
67 }
68
69 [[nodiscard]] Factory *clone() const override {
70 return new Info(*this);
71 }
72};
73
74#endif //IDOL_LOGS_DANTZIGWOLFE_INFO_H