1#ifndef CDA_RAIL_SOLVER_MIP_BASED_GENERALMIPSOLVER_HPP
2#define CDA_RAIL_SOLVER_MIP_BASED_GENERALMIPSOLVER_HPP
14#include <unordered_map>
66 if (where == GRB_CB_MESSAGE) {
67 std::string msg = getStringInfo(GRB_CB_MSG_STRING);
68 if (!msg.empty() && msg.back() ==
'\n') {
89template <
typename T,
typename S>
92 std::is_base_of_v<cda_rail::instances::GeneralProblemInstance, T>,
93 "T must be a child of GeneralProblemInstance");
95 std::is_base_of_v<cda_rail::instances::SolGeneralProblemInstance, S>,
96 "S must be a child of SolGeneralProblemInstance<T>");
104 std::unordered_map<std::string, MultiArray<GRBVar>>
m_vars;
139 PLOGD <<
"Create Gurobi environment and model";
140 this->m_env.emplace(
true);
142 this->m_env->start();
143 this->m_model.emplace(
m_env.value());
145 this->m_model->setCallback(cb);
146 this->m_model->set(GRB_IntParam_LogToConsole, 0);
155 template <
typename... Args>
void solve_init_general(bool debug_input, bool overwrite_severity)
Initializes logging and records solver start time.
Definition GeneralSolver.hpp:142
GeneralSolver()=default
Constructs a solver with a default-initialized problem instance.
GeneralMIPSolver()=default
Constructs a solver with a default-initialized problem instance.
void solve_init_general_mip(bool debug_input, bool overwrite_severity, GRBCallback *cb)
Initializes the logging, the Gurobi environment, and the model.
Definition GeneralMIPSolver.hpp:134
std::optional< GRBModel > m_model
Definition GeneralMIPSolver.hpp:103
std::optional< GRBEnv > m_env
Definition GeneralMIPSolver.hpp:102
std::vector< GRBTempConstr > m_lazy_constraints
Definition GeneralMIPSolver.hpp:99
void solve_init_general_mip(bool debug_input, bool overwrite_severity)
Initializes the model with the default message callback.
Definition GeneralMIPSolver.hpp:120
std::unordered_map< std::string, MultiArray< GRBVar > > m_vars
Definition GeneralMIPSolver.hpp:104
GeneralMIPSolver(const T &instance)
Constructs a solver from a problem instance.
Definition GeneralMIPSolver.hpp:152
GRBLinExpr m_objective_expr
Definition GeneralMIPSolver.hpp:105
GeneralMIPSolver(Args &&... args)
Constructs the problem instance from the given arguments.
Definition GeneralMIPSolver.hpp:156
virtual void cleanup()
Releases the model and the environment after solving.
Definition GeneralMIPSolver.hpp:108
Routes the output of Gurobi into the logging of this tool.
Definition GeneralMIPSolver.hpp:59
void callback() override
Logs one message of Gurobi, without its trailing newline.
Definition GeneralMIPSolver.hpp:65
MessageCallback()=default
Definition GeneralMIPSolver.hpp:17
SolutionSettingsMIP SolutionSettingsMovingBlock
Export settings of the moving block MIP solver.
Definition GeneralMIPSolver.hpp:39
Where a solver writes its solution to, see GeneralSolver::export_general_solution.
Definition GeneralSolver.hpp:61
Definition GeneralSolver.hpp:128
Export settings shared by all MIP based solvers.
Definition GeneralMIPSolver.hpp:28
bool export_lp_model
Definition GeneralMIPSolver.hpp:29
std::string model_name
Definition GeneralMIPSolver.hpp:30
Export settings of the VSS generation MIP solver.
Definition GeneralMIPSolver.hpp:47
bool postprocess
Definition GeneralMIPSolver.hpp:48