18template<
typename ValueType>
31 if (!
isEmpty() && !polytope->intersection(rhs)->isEmpty()) {
32 if (children.empty()) {
35 auto newChildren = polytope->setMinus(rhs);
36 if (newChildren.empty()) {
39 }
else if (newChildren.size() == 1) {
41 polytope = newChildren.front()->clean();
44 for (
auto& c : newChildren) {
45 children.push_back(c->clean());
50 std::vector<PolytopeTree<ValueType>> newChildren;
51 std::vector<std::vector<ValueType>> newPolytopeVertices;
52 for (
auto& c : children) {
54 if (c.polytope !=
nullptr) {
55 newChildren.push_back(c);
56 auto cVertices = c.polytope->getVertices();
57 newPolytopeVertices.insert(newPolytopeVertices.end(), cVertices.begin(), cVertices.end());
60 if (newPolytopeVertices.empty()) {
65 children = std::move(newChildren);
85 assert(point.size() == offset.size());
86 std::vector<ValueType> pointPrime(point.size());
95 return polytope ==
nullptr;
127 for (
auto const& v : vertices) {
129 for (
auto const& vi : v) {
130 s << storm::utility::convertNumber<double>(vi) <<
"-";
133 s <<
"_id" << children.data();
142 return "Empty PolytopeTree";
145 s <<
"PolytopeTree node with " <<
getChildren().size() <<
" children: " <<
getPolytope()->toString(
true) <<
"\nVertices: ";
147 for (
auto const& v : vertices) {
149 for (
auto const& vi : v) {
150 s << storm::utility::convertNumber<double>(vi) <<
",";
159 std::shared_ptr<Polytope<ValueType>> polytope;
160 std::vector<PolytopeTree<ValueType>> children;
static std::shared_ptr< Polytope< ValueType > > create(std::vector< Halfspace< ValueType > > const &halfspaces)
Creates a polytope from the given halfspaces.
Represents a set of points in Euclidean space.
std::shared_ptr< Polytope< ValueType > > & getPolytope()
Gets the polytope at this node.
void substractDownwardClosure(std::vector< ValueType > const &point)
Substracts the downward closure of the given point from this set.
void setMinus(std::shared_ptr< Polytope< ValueType > > const &rhs)
Substracts the given rhs from this polytope.
PolytopeTree(std::shared_ptr< Polytope< ValueType > > const &polytope=nullptr)
bool isEmpty() const
Returns true if this is the empty set.
std::vector< PolytopeTree > & getChildren()
Gets the children at this node.
std::string toString()
Returns a string representation of this node (for debugging purposes)
void clear()
Clears all contents of this set, making it the empty set.
void substractDownwardClosure(std::vector< ValueType > const &point, std::vector< ValueType > const &offset)
Substracts the downward closure of the given point from this set.
void addVectors(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target)
Adds the two given vectors and writes the result to the target vector.