Antares Xpansion
Investment simulations for Antares studies
Loading...
Searching...
No Matches
BatchCollection.h
1#ifndef SRC_CPP_BENDERS_BENDERS_BY_BATCH_INCLUDE_BATCHCOLLECTION_H_
2#define SRC_CPP_BENDERS_BENDERS_BY_BATCH_INCLUDE_BATCHCOLLECTION_H_
3#include <string>
4#include <vector>
5
6#include <boost/serialization/map.hpp>
7
8#include "antares-xpansion/benders/benders_core/common.h"
9#include "antares-xpansion/xpansion_interfaces/ILogger.h"
10
11struct Batch
12{
13 std::vector<std::string> sub_problem_names;
14 std::vector<int> proc_numbers;
15 std::vector<SubProblemNamesInCut> name_to_cut;
16 unsigned id;
17 friend class boost::serialization::access;
18
19 void AssociateSubProblemsToCut(int n_cuts);
20
21 template<class Archive>
22 void serialize(Archive& ar, [[maybe_unused]] const unsigned int version)
23 {
24 ar & sub_problem_names;
25 ar & proc_numbers;
26 ar & id;
27 }
28};
29
31{
32private:
33 std::vector<std::string> sub_problem_names_;
34 size_t sub_problems_number_;
35 size_t batch_size_;
36 std::vector<Batch> batch_collections_;
37 unsigned number_of_batch_;
38 Logger logger_;
39
40public:
41 BatchCollection() = default;
42 BatchCollection(const std::vector<std::string>& sub_problem_names,
43 size_t batch_size,
44 Logger logger);
45 void BuildBatches(int n_procs = 0);
46
47 void SetLogger(Logger logger)
48 {
49 logger_ = std::move(logger);
50 }
51
52 void SetBatchSize(size_t batch_size)
53 {
54 batch_size_ = batch_size;
55 }
56
57 void SetSubProblemNames(const std::vector<std::string>& sub_problem_names)
58 {
59 sub_problem_names_ = sub_problem_names;
60 sub_problems_number_ = sub_problem_names.size();
61 }
62
63 size_t size() const
64 {
65 return batch_collections_.size();
66 }
67
68 std::vector<Batch> BatchCollections() const
69 {
70 return batch_collections_;
71 }
72
73 std::vector<Batch>& BatchCollections()
74 {
75 return batch_collections_;
76 }
77
78 Batch GetBatchFromId(unsigned batch_id) const
79 {
80 return batch_collections_[batch_id];
81 }
82
83 unsigned NumberOfBatch() const
84 {
85 return number_of_batch_;
86 }
87 friend class boost::serialization::access;
88
89 template<class Archive>
90 void serialize(Archive& ar, [[maybe_unused]] const unsigned int version)
91 {
92 ar & sub_problem_names_;
93 ar & sub_problems_number_;
94 ar & batch_size_;
95 ar & batch_collections_;
96 ar & number_of_batch_;
97 }
98};
99#endif // SRC_CPP_BENDERS_BENDERS_BY_BATCH_INCLUDE_BATCHCOLLECTION_H_
Definition BatchCollection.h:31
Definition BatchCollection.h:12