Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparsePcaaParetoQuery.cpp
Go to the documentation of this file.
2
12
13namespace storm {
14namespace modelchecker {
15namespace multiobjective {
16
17template<class SparseModelType, typename GeometryValueType>
24
25template<class SparseModelType, typename GeometryValueType>
28 storm::exceptions::IllegalArgumentException, "Unhandled multiobjective precision type.");
29
30 // Set the precision of the weight vector checker
31 typename SparseModelType::ValueType weightedPrecision =
32 storm::utility::convertNumber<typename SparseModelType::ValueType>(env.modelchecker().multi().getPrecision());
33 weightedPrecision /= storm::utility::sqrt(storm::utility::convertNumber<typename SparseModelType::ValueType, uint_fast64_t>(this->objectives.size()));
34 // multiobjPrecision / sqrt(numObjectives) is the largest possible value for which termination is guaranteed.
35 // To see this, assume that for both weight vectors <1,0> and <0,1> we get the same point <a,b> for the under-approximation and <a+weightedPrecision,b>
36 // resp. <a,b+weightedPrecision> for the over-approximation. Then, the over-approx. point <a+weightedPrecision,b+weightedPrecision> has a distance to the
37 // under-approximation of weightedPrecision * sqrt(numObjectives). Lets be a little bit more precise to reduce the number of required iterations.
38 weightedPrecision *= storm::utility::convertNumber<typename SparseModelType::ValueType>(0.9);
39 this->weightVectorChecker->setWeightedPrecision(weightedPrecision);
40
41 // refine the approximation
42 exploreSetOfAchievablePoints(env);
43
44 // obtain the data for the checkresult
45 std::vector<std::vector<typename SparseModelType::ValueType>> paretoOptimalPoints;
46 std::vector<Point> vertices = this->underApproximation->getVertices();
47 paretoOptimalPoints.reserve(vertices.size());
48 for (auto const& vertex : vertices) {
49 paretoOptimalPoints.push_back(
50 storm::utility::vector::convertNumericVector<typename SparseModelType::ValueType>(transformObjectiveValuesToOriginal(this->objectives, vertex)));
51 }
52 return std::unique_ptr<CheckResult>(new ExplicitParetoCurveCheckResult<typename SparseModelType::ValueType>(
53 this->originalModel.getInitialStates().getNextSetIndex(0), std::move(paretoOptimalPoints),
54 transformObjectivePolytopeToOriginal(this->objectives, this->underApproximation)
55 ->template convertNumberRepresentation<typename SparseModelType::ValueType>(),
56 transformObjectivePolytopeToOriginal(this->objectives, this->overApproximation)
57 ->template convertNumberRepresentation<typename SparseModelType::ValueType>()));
58}
59
60template<class SparseModelType, typename GeometryValueType>
63 storm::exceptions::IllegalArgumentException, "Unhandled multiobjective precision type.");
64
65 // First consider the objectives individually
66 for (uint_fast64_t objIndex = 0; objIndex < this->objectives.size() && !this->maxStepsPerformed(env); ++objIndex) {
67 WeightVector direction(this->objectives.size(), storm::utility::zero<GeometryValueType>());
68 direction[objIndex] = storm::utility::one<GeometryValueType>();
69 this->performRefinementStep(env, std::move(direction));
71 break;
72 }
73 }
74
75 while (!this->maxStepsPerformed(env) && !storm::utility::resources::isTerminate()) {
76 // Get the halfspace of the underApproximation with maximal distance to a vertex of the overApproximation
77 std::vector<storm::storage::geometry::Halfspace<GeometryValueType>> underApproxHalfspaces = this->underApproximation->getHalfspaces();
78 std::vector<Point> overApproxVertices = this->overApproximation->getVertices();
79 uint_fast64_t farestHalfspaceIndex = underApproxHalfspaces.size();
80 GeometryValueType farestDistance = storm::utility::zero<GeometryValueType>();
81 for (uint_fast64_t halfspaceIndex = 0; halfspaceIndex < underApproxHalfspaces.size(); ++halfspaceIndex) {
82 for (auto const& vertex : overApproxVertices) {
83 GeometryValueType distance = underApproxHalfspaces[halfspaceIndex].euclideanDistance(vertex);
84 if (distance > farestDistance) {
85 farestHalfspaceIndex = halfspaceIndex;
86 farestDistance = distance;
87 }
88 }
89 }
90 if (farestDistance < storm::utility::convertNumber<GeometryValueType>(env.modelchecker().multi().getPrecision())) {
91 // Goal precision reached!
92 return;
93 }
94 STORM_LOG_INFO("Current precision of the approximation of the pareto curve is ~" << storm::utility::convertNumber<double>(farestDistance));
95 WeightVector direction = underApproxHalfspaces[farestHalfspaceIndex].normalVector();
96 this->performRefinementStep(env, std::move(direction));
97 }
98 STORM_LOG_ERROR("Could not reach the desired precision: Termination requested or maximum number of refinement steps exceeded.");
99}
100
101#ifdef STORM_HAVE_CARL
102template class SparsePcaaParetoQuery<storm::models::sparse::Mdp<double>, storm::RationalNumber>;
103template class SparsePcaaParetoQuery<storm::models::sparse::MarkovAutomaton<double>, storm::RationalNumber>;
104
105template class SparsePcaaParetoQuery<storm::models::sparse::Mdp<storm::RationalNumber>, storm::RationalNumber>;
106template class SparsePcaaParetoQuery<storm::models::sparse::MarkovAutomaton<storm::RationalNumber>, storm::RationalNumber>;
107#endif
108} // namespace multiobjective
109} // namespace modelchecker
110} // namespace storm
ModelCheckerEnvironment & modelchecker()
MultiObjectiveModelCheckerEnvironment & multi()
SparsePcaaParetoQuery(preprocessing::SparseMultiObjectivePreprocessorResult< SparseModelType > &preprocessorResult)
virtual std::unique_ptr< CheckResult > check(Environment const &env) override
#define STORM_LOG_INFO(message)
Definition logging.h:29
#define STORM_LOG_ERROR(message)
Definition logging.h:31
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
std::vector< GeometryValueType > transformObjectiveValuesToOriginal(std::vector< Objective< ValueType > > objectives, std::vector< GeometryValueType > const &point)
std::shared_ptr< storm::storage::geometry::Polytope< GeometryValueType > > transformObjectivePolytopeToOriginal(std::vector< Objective< ValueType > > objectives, std::shared_ptr< storm::storage::geometry::Polytope< GeometryValueType > > const &polytope)
bool isTerminate()
Check whether the program should terminate (due to some abort signal).
ValueType sqrt(ValueType const &number)
LabParser.cpp.
Definition cli.cpp:18