23 mpi::environment &env, mpi::communicator &world,
24 std::shared_ptr<MathLoggerDriver> mathLoggerDriver);
27 std::string BendersName()
const override {
return "Benders mpi"; }
28 const unsigned int rank_0 = 0;
36 mpi::communicator &_world;
39 void step_1_solve_master();
40 void step_2_solve_subproblems_and_build_cuts();
41 void step_4_update_best_solution(
int rank);
43 void master_build_cuts(
44 std::vector<SubProblemDataMap> gathered_subproblem_map);
45 SubProblemDataMap get_subproblem_cut_package();
47 void solve_master_and_create_trace();
50 void do_solve_master_create_trace_and_update_cuts();
52 virtual void gather_subproblems_cut_package_and_build_cuts(
53 const SubProblemDataMap &subproblem_data_map,
const Timer &process_timer);
55 void write_exception_message(
const std::exception &ex)
const;
57 void check_if_some_proc_had_a_failure(
int success);
59 mpi::environment &_env;
62 [[nodiscard]]
bool shouldParallelize()
const final {
return false; }
63 void PreRunInitialization();
64 int Rank()
const {
return _world.rank(); }
66 void BroadCast(T &value,
int root)
const {
67 mpi::broadcast(_world, value, root);
70 void BroadCast(T *values,
int n,
int root)
const {
71 mpi::broadcast(_world, values, n, root);
74 void Gather(
const T &value, std::vector<T> &vector_of_values,
76 mpi::gather(_world, value, vector_of_values, root);
78 void BuildMasterProblem();
79 int WorldSize()
const {
return _world.size(); }
80 void Barrier()
const { _world.barrier(); }
82 template <
typename T,
typename Op>
83 void Reduce(
const T &in_value, T &out_value, Op op,
int root)
const {
84 mpi::reduce(_world, in_value, out_value, op, root);
86 template <
typename T,
typename Op>
87 void AllReduce(
const T &in_value, T &out_value, Op op)
const {
88 mpi::all_reduce(_world, in_value, out_value, op);
90 virtual void GatherCuts(
const SubProblemDataMap &subproblem_data_map,
91 const Timer &walltime);
92 void BroadCastVariablesIndices();
93 virtual void ComputeSubproblemsContributionToCriteria(
94 const SubProblemDataMap &subproblem_data_map);
96 SubProblemDataMap &subproblem_data_map,
98 const std::shared_ptr<SubproblemWorker> &worker)
override;
99 void UpdateMaxCriterionArea();