11 #include "timed_condition.hh"
12 #include "elementary_language.hh"
20 std::vector<TimedCondition> conditions;
22 explicit TimedConditionSet(std::vector<TimedCondition> conditions) : conditions(std::move(conditions)) {}
41 if (elementaryLanguages.empty()) {
42 return TimedConditionSet::bottom();
45 assert(std::all_of(elementaryLanguages.begin(), elementaryLanguages.end(), [&](
const auto &elem) {
46 return elem.getWord() == elementaryLanguages.front().getWord();
49 assert(std::all_of(elementaryLanguages.begin(), elementaryLanguages.end(), [&](
const auto &elem) {
50 return elem.getTimedCondition().isSimple();
52 std::list<std::pair<TimedCondition, int>> timedConditionsWithSize;
53 timedConditionsWithSize.resize(elementaryLanguages.size());
54 std::transform(std::make_move_iterator(elementaryLanguages.begin()),
55 std::make_move_iterator(elementaryLanguages.end()),
56 timedConditionsWithSize.begin(),
57 [&](
auto &&elementary) {
58 return std::make_pair(elementary.getTimedCondition(), 1);
60 auto it = timedConditionsWithSize.begin();
61 while (it != timedConditionsWithSize.end()) {
62 auto timedCondition = it->first;
64 for (
auto it2 = std::next(it); it2 != timedConditionsWithSize.end(); it2++) {
66 auto convexHull = timedCondition.convexHull(it2->first);
67 if (convexHull.enumerate().size() ==
static_cast<std::size_t
>(it->second + it2->second)) {
68 it->first = std::move(convexHull);
69 it->second += it2->second;
70 timedConditionsWithSize.erase(it2);
71 it = timedConditionsWithSize.begin();
80 std::vector<TimedCondition> result;
81 result.resize(timedConditionsWithSize.size());
82 std::transform(std::make_move_iterator(timedConditionsWithSize.begin()),
83 std::make_move_iterator(timedConditionsWithSize.end()),
85 [](
auto &&timedConditionWithSize) {
86 return timedConditionWithSize.first;
92 [[nodiscard]]
bool empty()
const {
93 return this->conditions.empty();
96 [[nodiscard]] std::size_t size()
const {
97 return this->conditions.size();
100 [[nodiscard]] TimedCondition& front() {
101 return this->conditions.front();
104 [[nodiscard]] TimedCondition& at(std::size_t i) {
105 return this->conditions.at(i);
108 [[nodiscard]]
const std::vector<TimedCondition> &getConditions()
const {
118 const size_t examinedVariableSize)
const {
119 std::vector<std::size_t> result;
120 for (
const auto &condition: this->conditions) {
121 std::vector<std::size_t> tmp =
123 result.reserve(result.size() + tmp.size());
124 std::move(tmp.begin(), tmp.end(), std::back_inserter(result));
133 for (
auto &condition: this->conditions) {
139 this->conditions.push_back(condition);
142 TimedCondition& back() {
143 return this->conditions.back();
146 decltype(conditions.begin()) begin() {
147 return this->conditions.begin();
150 decltype(conditions.end()) end() {
151 return this->conditions.end();
A set of timed conditions to represent non-convex constraints.
Definition: timed_condition_set.hh:18
void removeEqualityUpperBoundAssign()
Remove the equality upper bound.
Definition: timed_condition_set.hh:132
static TimedConditionSet reduce(std::list< ElementaryLanguage > elementaryLanguages)
Construct a timed condition set from a set of simple elementary languages.
Definition: timed_condition_set.hh:40
std::vector< std::size_t > getStrictlyConstrainedVariables(const TimedCondition &originalCondition, const size_t examinedVariableSize) const
Returns the set of variables strictly constrained compared with the original condition.
Definition: timed_condition_set.hh:117
A timed condition, a finite conjunction of inequalities of the form , where and .
Definition: timed_condition.hh:19
std::vector< std::size_t > getStrictlyConstrainedVariables(const TimedCondition &originalCondition, const size_t examinedVariableSize) const
Returns the set of variables strictly constrained compared with the original condition.
Definition: timed_condition.hh:580
void removeEqualityUpperBoundAssign()
Remove the equality upper bound.
Definition: timed_condition.hh:411
Definition: experiment_runner.hh:23