LearnTA  0.0.1
juxtaposed_zone_set.hh
1 
6 #pragma once
7 
8 #include <ostream>
9 #include "juxtaposed_zone.hh"
10 #include "timed_condition_set.hh"
11 
12 namespace learnta {
14  private:
15  std::vector<JuxtaposedZone> zones;
16  public:
17  JuxtaposedZoneSet(const TimedConditionSet &left, const TimedCondition &right) {
18  zones.resize(left.size());
19  std::transform(left.getConditions().begin(), left.getConditions().end(), zones.begin(),
20  [&right](const TimedCondition &condition) {
21  return condition ^ right;
22  });
23  }
24 
32  const std::size_t commonVariableSize) {
33  zones.resize(left.size());
34  std::transform(left.getConditions().begin(), left.getConditions().end(), zones.begin(),
35  [&](const TimedCondition &condition) {
36  return condition.juxtaposeRight(right, static_cast<Eigen::Index>(commonVariableSize));
37  });
38  }
39 
47  const std::size_t commonVariableSize) {
48  zones.resize(right.size());
49  std::transform(right.getConditions().begin(), right.getConditions().end(), zones.begin(),
50  [&](const TimedCondition &condition) {
51  return condition.juxtaposeLeft(left, static_cast<Eigen::Index>(commonVariableSize));
52  });
53  }
54 
58  void addRenaming(const std::vector<std::pair<std::size_t, std::size_t>> &renaming) {
59  for (auto it = this->zones.begin(); it != this->zones.end();) {
60  it->addRenaming(renaming);
61  if (it->isSatisfiableNoCanonize()) {
62  it++;
63  } else {
64  it = this->zones.erase(it);
65  }
66  }
67  }
68 
74  bool operator==(const JuxtaposedZoneSet &another) const {
75  return this->zones.size() == another.zones.size() &&
76  std::all_of(this->zones.begin(), this->zones.end(), [&](const JuxtaposedZone &zone) {
77  return std::any_of(another.zones.begin(), another.zones.end(), [&](const JuxtaposedZone &anotherZone) {
78  return zone.strictEqual(anotherZone);
79  });
80  });
81  }
82 
83  bool operator!=(const JuxtaposedZoneSet &another) const {
84  return !(*this == another);
85  }
86 
87  friend std::ostream &operator<<(std::ostream &os, const JuxtaposedZoneSet &set) {
88  bool isFirst = true;
89  for (const JuxtaposedZone &zone: set.zones) {
90  if (!isFirst) {
91  os << ", ";
92  }
93  os << zone;
94  isFirst = false;
95  }
96 
97  return os;
98  }
99  };
100 }
Definition: juxtaposed_zone_set.hh:13
JuxtaposedZoneSet(const TimedConditionSet &left, const TimedCondition &right, const std::size_t commonVariableSize)
Juxtapose with variable renaming.
Definition: juxtaposed_zone_set.hh:31
bool operator==(const JuxtaposedZoneSet &another) const
Check the equivalence of two juxtaposed zone sets.
Definition: juxtaposed_zone_set.hh:74
void addRenaming(const std::vector< std::pair< std::size_t, std::size_t >> &renaming)
Add renaming constraints.
Definition: juxtaposed_zone_set.hh:58
JuxtaposedZoneSet(const TimedCondition &left, const TimedConditionSet &right, const std::size_t commonVariableSize)
Juxtapose with variable renaming.
Definition: juxtaposed_zone_set.hh:46
A zone constructed by juxtaposing two zones with or without shared variables.
Definition: juxtaposed_zone.hh:12
A set of timed conditions to represent non-convex constraints.
Definition: timed_condition_set.hh:18
A timed condition, a finite conjunction of inequalities of the form , where and .
Definition: timed_condition.hh:19
Definition: experiment_runner.hh:23