Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Polytope.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_GEOMETRY_POLYTOPE_H_
2#define STORM_STORAGE_GEOMETRY_POLYTOPE_H_
3
4#include <boost/optional.hpp>
5#include <memory>
6#include <vector>
7
11
12namespace storm {
13namespace storage {
14namespace geometry {
15
16template<typename ValueType>
17class Polytope {
18 public:
19 typedef std::vector<ValueType> Point;
20
21 virtual ~Polytope();
22
27 static std::shared_ptr<Polytope<ValueType>> create(std::vector<Halfspace<ValueType>> const& halfspaces);
28
33 static std::shared_ptr<Polytope<ValueType>> create(std::vector<Point> const& points);
34
38 static std::shared_ptr<Polytope<ValueType>> createUniversalPolytope();
39
43 static std::shared_ptr<Polytope<ValueType>> createEmptyPolytope();
44
49 static std::shared_ptr<Polytope<ValueType>> createDownwardClosure(std::vector<Point> const& points);
50
56 static std::shared_ptr<Polytope<ValueType>> createSelectiveDownwardClosure(std::vector<Point> const& points,
57 storm::storage::BitVector const& selectedDimensions);
58
62 virtual std::vector<Point> getVertices() const = 0;
63
68 virtual std::vector<Point> getVerticesInClockwiseOrder() const;
69
73 virtual std::vector<Halfspace<ValueType>> getHalfspaces() const = 0;
74
78 virtual bool isEmpty() const = 0;
79
83 virtual bool isUniversal() const = 0;
84
88 virtual bool contains(Point const& point) const = 0;
89
93 virtual bool contains(std::shared_ptr<Polytope<ValueType>> const& other) const = 0;
94
98 virtual std::shared_ptr<Polytope<ValueType>> intersection(std::shared_ptr<Polytope<ValueType>> const& rhs) const = 0;
99 virtual std::shared_ptr<Polytope<ValueType>> intersection(Halfspace<ValueType> const& halfspace) const = 0;
100
104 virtual std::shared_ptr<Polytope<ValueType>> convexUnion(std::shared_ptr<Polytope<ValueType>> const& rhs) const = 0;
105
109 virtual std::shared_ptr<Polytope<ValueType>> minkowskiSum(std::shared_ptr<Polytope<ValueType>> const& rhs) const = 0;
110
118 virtual std::shared_ptr<Polytope<ValueType>> affineTransformation(std::vector<Point> const& matrix, Point const& vector) const = 0;
119
125 std::shared_ptr<Polytope<ValueType>> shift(Point const& b) const;
126
130 virtual std::shared_ptr<Polytope<ValueType>> downwardClosure() const;
131
138 std::vector<std::shared_ptr<Polytope<ValueType>>> setMinus(std::shared_ptr<Polytope<ValueType>> const& rhs) const;
139
147 virtual std::pair<Point, bool> optimize(Point const& direction) const = 0;
148
154 virtual std::vector<storm::expressions::Variable> declareVariables(storm::expressions::ExpressionManager& manager, std::string const& namePrefix) const;
155
159 virtual std::vector<storm::expressions::Expression> getConstraints(storm::expressions::ExpressionManager const& manager,
160 std::vector<storm::expressions::Variable> const& variables) const;
161
165 template<typename TargetType>
166 std::shared_ptr<Polytope<TargetType>> convertNumberRepresentation() const;
167
171 virtual std::shared_ptr<Polytope<ValueType>> clean();
172
173 /*
174 * Returns a string representation of this polytope.
175 * @param numbersAsDouble If true, the occurring numbers are converted to double before printing to increase readability.
176 */
177 virtual std::string toString(bool numbersAsDouble = false) const;
178
179 virtual bool isNativePolytope() const;
180
181 protected:
182 Polytope();
183
184 private:
188 static std::shared_ptr<Polytope<ValueType>> create(boost::optional<std::vector<Halfspace<ValueType>>> const& halfspaces,
189 boost::optional<std::vector<Point>> const& points);
190};
191
192} // namespace geometry
193} // namespace storage
194} // namespace storm
195
196#endif /* STORM_STORAGE_GEOMETRY_POLYTOPE_H_ */
This class is responsible for managing a set of typed variables and all expressions using these varia...
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
std::vector< ValueType > Point
Definition Polytope.h:19
virtual std::shared_ptr< Polytope< ValueType > > affineTransformation(std::vector< Point > const &matrix, Point const &vector) const =0
Returns the affine transformation of this polytope P w.r.t.
static std::shared_ptr< Polytope< ValueType > > createDownwardClosure(std::vector< Point > const &points)
Creates the downward closure of the given points (i.e., the set { x | ex.
Definition Polytope.cpp:43
virtual bool contains(std::shared_ptr< Polytope< ValueType > > const &other) const =0
Returns true iff the given polytope is a subset of this polytope.
virtual std::vector< Point > getVerticesInClockwiseOrder() const
Returns the vertices of this 2D-polytope in clockwise order.
Definition Polytope.cpp:160
virtual std::pair< Point, bool > optimize(Point const &direction) const =0
Finds an optimal point inside this polytope w.r.t.
virtual std::shared_ptr< Polytope< ValueType > > minkowskiSum(std::shared_ptr< Polytope< ValueType > > const &rhs) const =0
Returns the minkowskiSum of this polytope and rhs.
std::vector< std::shared_ptr< Polytope< ValueType > > > setMinus(std::shared_ptr< Polytope< ValueType > > const &rhs) const
Computes the set {x \in this | x \notin rhs}.
Definition Polytope.cpp:178
static std::shared_ptr< Polytope< ValueType > > create(std::vector< Halfspace< ValueType > > const &halfspaces)
Creates a polytope from the given halfspaces.
virtual std::vector< storm::expressions::Expression > getConstraints(storm::expressions::ExpressionManager const &manager, std::vector< storm::expressions::Variable > const &variables) const
Returns the constrains defined by this polytope as an expression over the given variables.
Definition Polytope.cpp:210
virtual std::shared_ptr< Polytope< ValueType > > intersection(Halfspace< ValueType > const &halfspace) const =0
virtual std::shared_ptr< Polytope< ValueType > > downwardClosure() const
Returns the downward closure of this, i.e., the set { x | ex.
Definition Polytope.cpp:197
std::shared_ptr< Polytope< TargetType > > convertNumberRepresentation() const
converts the intern number representation of the polytope to the given target type
Definition Polytope.cpp:219
virtual bool isNativePolytope() const
Definition Polytope.cpp:246
virtual std::shared_ptr< Polytope< ValueType > > clean()
Performs cleaning operations, e.g., deleting redundant halfspaces.
Definition Polytope.cpp:251
static std::shared_ptr< Polytope< ValueType > > createUniversalPolytope()
Creates the universal polytope (i.e., the set R^n)
Definition Polytope.cpp:27
virtual std::string toString(bool numbersAsDouble=false) const
Definition Polytope.cpp:235
virtual bool isUniversal() const =0
Returns whether this polytope is universal (i.e., equals R^n).
virtual bool isEmpty() const =0
Returns whether this polytope is the empty set.
virtual std::shared_ptr< Polytope< ValueType > > convexUnion(std::shared_ptr< Polytope< ValueType > > const &rhs) const =0
Returns the convex union of this polytope and rhs.
virtual std::vector< Halfspace< ValueType > > getHalfspaces() const =0
Returns the halfspaces of this polytope.
virtual bool contains(Point const &point) const =0
Returns true iff the given point is inside of the polytope.
virtual std::vector< Point > getVertices() const =0
Returns the vertices of this polytope.
static std::shared_ptr< Polytope< ValueType > > createEmptyPolytope()
Creates the empty polytope (i.e., emptyset)
Definition Polytope.cpp:32
virtual std::shared_ptr< Polytope< ValueType > > intersection(std::shared_ptr< Polytope< ValueType > > const &rhs) const =0
Intersects this polytope with rhs and returns the result.
static std::shared_ptr< Polytope< ValueType > > createSelectiveDownwardClosure(std::vector< Point > const &points, storm::storage::BitVector const &selectedDimensions)
Creates the downward closure of the given points but only with respect to the selected dimensions,...
Definition Polytope.cpp:54
std::shared_ptr< Polytope< ValueType > > shift(Point const &b) const
Returns the Polytope described by the set {x+b | x \in this}.
Definition Polytope.cpp:168
virtual std::vector< storm::expressions::Variable > declareVariables(storm::expressions::ExpressionManager &manager, std::string const &namePrefix) const
Declares one variable for each dimension and returns the obtained variables.
Definition Polytope.cpp:202
LabParser.cpp.
Definition cli.cpp:18