Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
HyperplaneCollector.cpp
Go to the documentation of this file.
2
3namespace storm {
4namespace storage {
5namespace geometry {
6
7template<typename ValueType>
8bool HyperplaneCollector<ValueType>::insert(EigenVector const& normal, ValueType const& offset, std::vector<uint_fast64_t> const* indexList) {
9 EigenVector copyNormal(normal);
10 ValueType copyOffset(offset);
11 return this->insert(std::move(copyNormal), std::move(copyOffset), indexList);
12}
13
14template<typename ValueType>
15bool HyperplaneCollector<ValueType>::insert(EigenVector&& normal, ValueType&& offset, std::vector<uint_fast64_t> const* indexList) {
16 // Normalize
17 ValueType infinityNorm = normal.template lpNorm<Eigen::Infinity>();
18 if (infinityNorm != (ValueType)0) {
19 normal /= infinityNorm;
20 offset /= infinityNorm;
21 }
22
23 if (indexList == nullptr) {
24 // insert with empty list
25 return map.insert(MapValueType(MapKeyType(normal, offset), std::vector<uint_fast64_t>())).second;
26 } else {
27 auto inserted = map.insert(MapValueType(MapKeyType(normal, offset), *indexList));
28 if (!inserted.second) {
29 // Append vertex list
30 inserted.first->second.insert(inserted.first->second.end(), indexList->begin(), indexList->end());
31 }
32 return inserted.second;
33 }
34}
35
36template<typename ValueType>
37std::pair<typename HyperplaneCollector<ValueType>::EigenMatrix, typename HyperplaneCollector<ValueType>::EigenVector>
39 if (map.empty()) {
40 return std::pair<EigenMatrix, EigenVector>();
41 }
42
43 EigenMatrix A(map.size(), map.begin()->first.first.rows());
44 EigenVector b(map.size());
45
46 uint_fast64_t row = 0;
47 for (auto const& mapEntry : map) {
48 A.row(row) = mapEntry.first.first;
49 b(row) = mapEntry.first.second;
50 ++row;
51 }
52 return std::pair<EigenMatrix, EigenVector>(std::move(A), std::move(b));
53}
54
55template<typename ValueType>
56std::vector<std::vector<uint_fast64_t>> HyperplaneCollector<ValueType>::getIndexLists() const {
57 std::vector<std::vector<uint_fast64_t>> result(map.size());
58
59 auto resultIt = result.begin();
60 for (auto const& mapEntry : map) {
61 *resultIt = mapEntry.second;
62 ++resultIt;
63 }
64 return result;
65}
66
67template<typename ValueType>
69 return map.size();
70}
71
72template class HyperplaneCollector<double>;
74
75} // namespace geometry
76} // namespace storage
77} // namespace storm
This class can be used to collect a set of hyperplanes (without duplicates).
bool insert(EigenVector const &normal, ValueType const &offset, std::vector< uint_fast64_t > const *indexList=nullptr)
Eigen::Matrix< ValueType, Eigen::Dynamic, 1 > EigenVector
std::vector< std::vector< uint_fast64_t > > getIndexLists() const
std::pair< EigenMatrix, EigenVector > getCollectedHyperplanesAsMatrixVector() const
Eigen::Matrix< ValueType, Eigen::Dynamic, Eigen::Dynamic > EigenMatrix
LabParser.cpp.
Definition cli.cpp:18