#ifndef STORM_STORAGE_GEOMETRY_POLYTOPE_H_ #define STORM_STORAGE_GEOMETRY_POLYTOPE_H_ #include #include #include #include "src/storage/geometry/Halfspace.h" namespace storm { namespace storage { namespace geometry { template class Polytope { public: typedef std::vector Point; ~Polytope(); /*! * Creates a polytope from the given halfspaces. * If the given vector of halfspaces is empty, the resulting polytope is universal (i.e., equals R^n). */ static std::shared_ptr> create(std::vector> const& halfspaces); /*! * Creates a polytope from the given points (i.e., the convex hull of the points). * If the vector of points is empty, the resulting polytope be empty. */ static std::shared_ptr> create(std::vector const& points); /*! * Returns the vertices of this polytope. */ virtual std::vector getVertices() const; /*! * Returns the halfspaces of this polytope. */ virtual std::vector> getHalfspaces() const; /*! * Returns whether this polytope is the empty set. */ virtual bool isEmpty() const; /*! * Returns whether this polytope is universal (i.e., equals R^n). */ virtual bool isUniversal() const; /*! * Returns true iff the given point is inside of the polytope. */ virtual bool contains(Point const& point) const; /*! * Returns true iff the given polytope is a subset of this polytope. */ virtual bool contains(std::shared_ptr> const& other) const; /*! * Intersects this polytope with rhs and returns the result. */ virtual std::shared_ptr> intersection(std::shared_ptr> const& rhs) const; virtual std::shared_ptr> intersection(Halfspace const& halfspace) const; /*! * Returns the convex union of this polytope and rhs. */ virtual std::shared_ptr> convexUnion(std::shared_ptr> const& rhs) const; /*! * Returns the minkowskiSum of this polytope and rhs. */ virtual std::shared_ptr> minkowskiSum(std::shared_ptr> const& rhs) const; /*! * Returns the downward closure of this, i.e., the set { x | ex. y \in P : x<=y} where P is this Polytope. * Put differently, the resulting polytope corresponds to this polytope, where * 1. a vector y with y_i=max{x_i | x \in P} is computed and for each i, a halfspace with offset y_i and * normal vector n (where n_i = 1 and the remaining entries are 0) is inserted. * 2. all halfspaces where the normal vector has at least one negative entry are removed * * @param upperBounds If given, this vector is considered for y (hence, max{x_i | x i \in P does not need to be computed) */ virtual std::shared_ptr> downwardClosure(boost::optional const& upperBounds = boost::none) const; /* * Returns a string representation of this polytope. * If the given flag is true, the occurring numbers are converted to double before printing to increase readability */ virtual std::string toString(bool numbersAsDouble = false) const; virtual bool isHyproPolytope() const; protected: Polytope(); private: /*! * Creates a polytope from the given halfspaces or vertices. */ static std::shared_ptr> create(boost::optional>> const& halfspaces, boost::optional> const& points); }; } } } #endif /* STORM_STORAGE_GEOMETRY_POLYTOPE_H_ */