14 Eigen::Index leftSize = 0;
15 Eigen::Index rightSize = 0;
28 leftSize(static_cast<Eigen::Index>(left.
getNumOfVar())),
29 rightSize(static_cast<Eigen::Index>(right.
getNumOfVar())) {
30 static boost::unordered_map<std::pair<Zone, Zone>, Eigen::Matrix<Bounds, Eigen::Dynamic, Eigen::Dynamic>> memo;
31 const auto key = std::make_pair(left, right);
32 auto it = memo.find(key);
33 if (it != memo.end()) {
34 this->
value = it->second;
36 this->
value.resize(leftSize + rightSize + 1, leftSize + rightSize + 1);
37 this->
value.fill(Bounds(std::numeric_limits<double>::max(),
false));
42 right.
value.block(1, 1, right.
value.cols() - 1, right.
value.rows() - 1);
44 right.
value.block(0, 1, 1, right.
value.rows() - 1);
46 right.
value.block(1, 0, right.
value.cols() - 1, 1);
49 memo[key] = this->
value;
63 leftSize(static_cast<Eigen::Index>(left.
getNumOfVar())),
64 rightSize(static_cast<Eigen::Index>(right.
getNumOfVar())) {
65 static boost::unordered_map<std::tuple<Zone, Zone, Eigen::Index>, Eigen::Matrix<Bounds, Eigen::Dynamic, Eigen::Dynamic>> memoWithCommon;
66 const auto key = std::make_tuple(left, right, commonVariableSize);
67 auto it = memoWithCommon.find(key);
68 if (it != memoWithCommon.end()) {
69 this->
value = it->second;
71 const auto M = leftSize;
72 const auto N = rightSize;
73 const auto L = commonVariableSize;
74 const auto resultVariableSize =
M + N - L;
75 const auto commonBeginIndex =
M - L + 1;
76 const auto commonBeginInRightIndex = N - L + 1;
77 const auto rightBeginIndex =
M + 1;
78 this->
value.resize(resultVariableSize + 1, resultVariableSize + 1);
79 this->
value.fill(Bounds(std::numeric_limits<double>::max(),
false));
86 this->
value.block(commonBeginIndex, commonBeginIndex, L, L) =
87 this->
value.block(commonBeginIndex, commonBeginIndex, L, L).cwiseMin(
88 right.
value.block(commonBeginInRightIndex, commonBeginInRightIndex, L, L));
89 this->
value.block(0, commonBeginIndex, 1, L) = this->
value.block(0, commonBeginIndex, 1, L).cwiseMin(
90 right.
value.block(0, commonBeginInRightIndex, 1, L));
91 this->
value.block(commonBeginIndex, 0, L, 1) = this->
value.block(commonBeginIndex, 0, L, 1).cwiseMin(
92 right.
value.block(commonBeginInRightIndex, 0, L, 1));
98 this->
value.block(rightBeginIndex, rightBeginIndex, N - L, N - L) = right.
value.block(1, 1, N - L, N - L);
99 this->
value.block(0, rightBeginIndex, 1, N - L) = right.
value.block(0, 1, 1, N - L);
100 this->
value.block(rightBeginIndex, 0, N - L, 1) = right.
value.block(1, 0, N - L, 1);
106 this->
value.block(rightBeginIndex, commonBeginIndex, N - L, L) =
107 this->
value.block(rightBeginIndex, commonBeginIndex, N - L, L).cwiseMin(
108 right.
value.block(1, commonBeginInRightIndex, N - L, L));
109 this->
value.block(commonBeginIndex, rightBeginIndex, L, N - L) =
110 this->
value.block(commonBeginIndex, rightBeginIndex, L, N - L).cwiseMin(
111 right.
value.block(commonBeginInRightIndex, 1, L, N - L));
115 memoWithCommon[key] = this->
value;
127 void addRenaming(
const std::vector<std::pair<std::size_t, std::size_t>> &renaming) {
128 std::vector<ClockVariables> modifiedVariables;
129 modifiedVariables.reserve(renaming.size() * 2);
130 for (
const auto &[leftClock, rightClock]: renaming) {
132 assert(leftClock <
static_cast<std::size_t
>(leftSize));
133 assert(rightClock <
static_cast<std::size_t
>(rightSize));
135 Eigen::Index leftIndex =
static_cast<Eigen::Index
>(leftClock) + 1;
136 Eigen::Index rightIndex =
static_cast<Eigen::Index
>(rightClock) + leftSize + 1;
137 this->
value(leftIndex, rightIndex) = std::min(this->
value(leftIndex, rightIndex), {0,
true});
138 this->
value(rightIndex, leftIndex) = std::min(this->
value(rightIndex, leftIndex), {0,
true});
139 modifiedVariables.push_back(leftIndex);
140 modifiedVariables.push_back(rightIndex);
143 for (
const ClockVariables modifiedVariable: modifiedVariables) {
144 this->
close1(modifiedVariable);
150 std::vector<std::pair<std::size_t, std::size_t>> renaming;
151 for (Eigen::Index leftIndex = 1; leftIndex <= leftSize; ++leftIndex) {
152 for (Eigen::Index rightIndex = leftSize + 1; rightIndex <= rightSize + leftSize; ++rightIndex) {
153 if (this->
value(leftIndex, rightIndex) == Bounds{0,
true} && this->
value(rightIndex, leftIndex) == Bounds{0,
true}) {
154 renaming.emplace_back(leftIndex - 1, rightIndex - leftSize - 1);
168 if (
static_cast<Eigen::Index
>(this->
getNumOfVar()) != this->leftSize + this->rightSize) {
169 BOOST_LOG_TRIVIAL(error) <<
"JuxtaposedZone::getRight assumes that there is no common variables";
174 right.
value.block(1, 1, right.
value.cols() - 1, right.
value.rows() - 1) =
175 this->
value.block(leftSize + 1, leftSize + 1, right.
value.cols() - 1, right.
value.rows() - 1);
176 right.
value.block(0, 1, 1, right.
value.rows() - 1) =
177 this->
value.block(0, leftSize + 1, 1, right.
value.rows() - 1);
178 right.
value.block(1, 0, right.
value.cols() - 1, 1) =
179 this->
value.block(leftSize + 1, 0, right.
value.cols() - 1, 1);
185 [[nodiscard]] Eigen::Index getLeftSize()
const {
A zone constructed by juxtaposing two zones with or without shared variables.
Definition: juxtaposed_zone.hh:12
Zone getRight() const
Return the right side zone.
Definition: juxtaposed_zone.hh:167
auto makeRenaming() const
Make renaming constraints.
Definition: juxtaposed_zone.hh:149
JuxtaposedZone(const Zone &left, const Zone &right)
Juxtapose two zones without shared variables.
Definition: juxtaposed_zone.hh:27
JuxtaposedZone(const Zone &left, const Zone &right, Eigen::Index commonVariableSize)
Juxtapose two zones with shared variables.
Definition: juxtaposed_zone.hh:62
void addRenaming(const std::vector< std::pair< std::size_t, std::size_t >> &renaming)
Add renaming constraints.
Definition: juxtaposed_zone.hh:127
Definition: experiment_runner.hh:23
Implementation of a zone with DBM.
Definition: zone.hh:24
std::size_t getNumOfVar() const noexcept
Definition: zone.hh:66
void canonize()
make the zone canonical
Definition: zone.hh:314
void close1(ClockVariables x)
Close using only x.
Definition: zone.hh:261
Bounds M
The threshold for the normalization.
Definition: zone.hh:28
Eigen::Matrix< Bounds, Eigen::Dynamic, Eigen::Dynamic > value
The matrix representing the DBM.
Definition: zone.hh:26
static Zone top(std::size_t size)
Make the zone of size size with no constraints.
Definition: zone.hh:84