9 #include <unordered_set>
11 #include <boost/functional/hash.hpp>
12 #include <boost/log/trivial.hpp>
13 #include <boost/log/core.hpp>
14 #include <boost/log/expressions.hpp>
16 #include "common_types.hh"
26 std::deque<std::deque<ClockVariables>> order;
31 order.push_front({0});
43 std::vector<std::pair<double, ClockVariables>> fractionalPartsWithIndices;
44 fractionalPartsWithIndices.resize(fractionalParts.size());
45 for (std::size_t i = 0; i < fractionalParts.size(); ++i) {
46 fractionalPartsWithIndices.at(i) = std::make_pair(fractionalParts.at(i), i);
48 std::sort(fractionalPartsWithIndices.begin(), fractionalPartsWithIndices.end());
49 double currentFractionalPart = 0;
51 for (
const auto&[fractionalPart, index]: fractionalPartsWithIndices) {
52 if (currentFractionalPart == fractionalPart) {
53 order.back().push_back(index);
55 order.emplace_back(std::deque<ClockVariables>{index});
56 currentFractionalPart = fractionalPart;
60 size = fractionalParts.size();
67 if (order.front().empty()) {
79 if (order.front().empty()) {
81 std::swap(result.order.front(), result.order.back());
82 result.order.pop_back();
85 result.order.emplace_front();
95 if (order.front().empty()) {
97 std::swap(order.front(), order.back());
101 order.emplace_front();
110 BOOST_LOG_TRIVIAL(error) <<
"Something wrong happened in the predecessorVariables. order is empty";
112 if (order.front().empty()) {
113 if (order.size() <= 1) {
114 BOOST_LOG_TRIVIAL(error) <<
"Something wrong happened in the predecessorVariables. No variable exists";
116 return *(std::next(order.begin()));
118 return order.front();
127 if (order.front().empty()) {
129 result.order.pop_front();
132 result.order.emplace_back();
133 std::swap(result.order.front(), result.order.back());
144 result.order.front().push_back(result.size++);
155 assert(
static_cast<std::size_t
>(result.order.front().back() + 1) == this->size);
156 assert(result.size > 0);
157 result.order.front().pop_back();
168 for (
auto &variables: result.order) {
169 std::transform(variables.begin(), variables.end(), variables.begin(), [](
auto variable) {
173 result.order.front().push_front(0);
184 return this->size == another.size && this->order == another.order;
187 std::ostream &print(std::ostream &os)
const {
188 auto it = order.begin();
195 for (; it != order.end(); it++) {
197 for (
const auto var: *it) {
198 os <<
"x" << int(var) <<
", ";
206 [[nodiscard]] std::size_t hash_value()
const {
207 return boost::hash_value(std::make_pair(this->order, this->size));
212 return order.print(os);
216 return order.hash_value();
Order on the fractional part of the variables.
Definition: fractional_order.hh:24
FractionalOrder extendN() const
Add another variable such that .
Definition: fractional_order.hh:142
FractionalOrder extendZero() const
Rename each variable to and add such that .
Definition: fractional_order.hh:165
FractionalOrder(const std::vector< double > &fractionalParts)
Construct a fractional order from a concrete vector of fractional parts.
Definition: fractional_order.hh:42
FractionalOrder predecessor() const
Make it to be the predecessor.
Definition: fractional_order.hh:125
void successorAssign()
Make it to be the successor.
Definition: fractional_order.hh:94
size_t getSize() const
Returns the number of the variables.
Definition: fractional_order.hh:179
const std::deque< ClockVariables > & successorVariables() const
Return the variable to elapse.
Definition: fractional_order.hh:66
FractionalOrder removeN() const
Remove .
Definition: fractional_order.hh:153
std::deque< ClockVariables > predecessorVariables() const
Return the variable to backward-elapse.
Definition: fractional_order.hh:108
FractionalOrder successor() const
Make it to be the successor.
Definition: fractional_order.hh:77
Definition: experiment_runner.hh:23