@@ -74,30 +74,31 @@ struct RegulatedTrafoProperties {
74
74
Idx id{};
75
75
ControlSide control_side{};
76
76
77
- bool operator <(const RegulatedTrafoProperties& other) const {
78
- return std::tie (this ->id , this ->control_side ) < std::tie (other.id , other.control_side );
79
- }
77
+ auto operator <=>(RegulatedTrafoProperties const & other) const = default ;
80
78
};
81
79
82
- struct RegulatedObjects {
83
- std::set<Idx> transformers{};
84
- std::set<Idx> transformers3w{};
85
- std::set<RegulatedTrafoProperties> trafos{};
86
- std::set<RegulatedTrafoProperties> trafos3w{};
87
-
88
- template <typename TrafoType> // not really necessary to be templated, but just in case
89
- std::pair<bool , ControlSide> contains (TrafoType const & trafos_set, Idx const & id) const {
90
- auto it = std::find_if (trafos_set.begin (), trafos_set.end (),
91
- [&](const RegulatedTrafoProperties& trafo) { return trafo.id == id; });
92
- if (it != trafos_set.end ()) {
93
- return {true , it->control_side };
94
- }
95
- return {false , ControlSide{}}; // no default invalid control side, won't be used by logic
96
- }
80
+ using RegulatedTrafos = std::set<RegulatedTrafoProperties>;
97
81
98
- std::pair<bool , ControlSide> contains_trafo (Idx const & id) const { return contains (trafos, id); }
82
+ inline std::pair<bool , ControlSide> regulated_trafos_contain (RegulatedTrafos const & trafos_set, Idx const & id) {
83
+ if (auto it = std::find_if (trafos_set.begin (), trafos_set.end (),
84
+ [&](RegulatedTrafoProperties const & trafo) { return trafo.id == id; });
85
+ it != trafos_set.end ()) {
86
+ return {true , it->control_side };
87
+ }
88
+ return {false , ControlSide{}}; // no default invalid control side, won't be used by logic
89
+ }
99
90
100
- std::pair<bool , ControlSide> contains_trafo3w (Idx const & id) const { return contains (trafos3w, id); }
91
+ struct RegulatedObjects {
92
+ // (TODO: jguo) old way, to be removed
93
+ // std::set<Idx> transformers{};
94
+ // std::set<Idx> transformers3w{};
95
+ RegulatedTrafos trafos{};
96
+ RegulatedTrafos trafos3w{};
97
+
98
+ std::pair<bool , ControlSide> contains_trafo (Idx const & id) const { return regulated_trafos_contain (trafos, id); }
99
+ std::pair<bool , ControlSide> contains_trafo3w (Idx const & id) const {
100
+ return regulated_trafos_contain (trafos3w, id);
101
+ }
101
102
};
102
103
103
104
using TransformerGraph = boost::compressed_sparse_row_graph<boost::directedS, TrafoGraphVertex, TrafoGraphEdge,
@@ -241,10 +242,10 @@ inline auto retrieve_regulator_info(State const& state) -> RegulatedObjects {
241
242
}
242
243
auto const control_side = regulator.control_side ();
243
244
if (regulator.regulated_object_type () == ComponentType::branch) {
244
- regulated_objects.transformers .emplace (regulator.regulated_object ());
245
+ // regulated_objects.transformers.emplace(regulator.regulated_object());
245
246
regulated_objects.trafos .emplace (RegulatedTrafoProperties{regulator.regulated_object (), control_side});
246
247
} else {
247
- regulated_objects.transformers3w .emplace (regulator.regulated_object ());
248
+ // regulated_objects.transformers3w.emplace(regulator.regulated_object());
248
249
regulated_objects.trafos3w .emplace (RegulatedTrafoProperties{regulator.regulated_object (), control_side});
249
250
}
250
251
}
0 commit comments