Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DeterministicSchedsAchievabilityChecker.cpp
Go to the documentation of this file.
2
12
14
15template<class SparseModelType, typename GeometryValueType>
18 : model(preprocessorResult.preprocessedModel), originalModelInitialState(*preprocessorResult.originalModel.getInitialStates().begin()) {
19 for (auto const& obj : preprocessorResult.objectives) {
20 objectiveHelper.emplace_back(*model, obj);
21 if (!objectiveHelper.back().hasThreshold()) {
22 STORM_LOG_ASSERT(!optimizingObjectiveIndex.has_value(),
23 "Unexpected input: got a (quantitative) achievability query but there are more than one objectives without a threshold.");
24 optimizingObjectiveIndex = objectiveHelper.size() - 1;
25 }
26 }
27 lpChecker = std::make_shared<DeterministicSchedsLpChecker<SparseModelType, GeometryValueType>>(*model, objectiveHelper);
28}
29
30template<class SparseModelType, typename GeometryValueType>
32 uint64_t const numObj = objectiveHelper.size();
33 // Create a polytope that contains all the points that would certify achievability of the point induced by the objective threshold
34 std::vector<storm::storage::geometry::Halfspace<GeometryValueType>> thresholdHalfspaces;
35 std::vector<GeometryValueType> objVector;
36 for (uint64_t objIndex = 0; objIndex < numObj; ++objIndex) {
37 auto& obj = objectiveHelper[objIndex];
38 obj.computeLowerUpperBounds(env);
39 if (!optimizingObjectiveIndex.has_value() || *optimizingObjectiveIndex != objIndex) {
40 objVector.assign(numObj, storm::utility::zero<GeometryValueType>());
41 objVector[objIndex] = -storm::utility::one<GeometryValueType>();
42 thresholdHalfspaces.emplace_back(objVector, storm::utility::convertNumber<GeometryValueType, ModelValueType>(-obj.getThreshold()));
43 }
44 }
45 auto thresholdPolytope = storm::storage::geometry::Polytope<GeometryValueType>::create(std::move(thresholdHalfspaces));
46
47 // Set objective weights (none if this is a qualitative achievability query)
48 objVector.assign(numObj, storm::utility::zero<GeometryValueType>());
49 auto eps = objVector;
50 if (optimizingObjectiveIndex.has_value()) {
51 objVector[*optimizingObjectiveIndex] = storm::utility::one<GeometryValueType>();
52 eps[*optimizingObjectiveIndex] = env.modelchecker().multi().getPrecision() * storm::utility::convertNumber<GeometryValueType, uint64_t>(2u);
54 eps[*optimizingObjectiveIndex] *= storm::utility::convertNumber<GeometryValueType, ModelValueType>(
55 objectiveHelper[*optimizingObjectiveIndex].getUpperValueBoundAtState(originalModelInitialState) -
56 objectiveHelper[*optimizingObjectiveIndex].getLowerValueBoundAtState(originalModelInitialState));
57 }
58 STORM_LOG_INFO("Computing quantitative achievability value with precision " << eps[*optimizingObjectiveIndex] << ".");
59 }
60 lpChecker->setCurrentWeightVector(env, objVector);
61
62 // Search achieving point
63 auto achievingPoint = lpChecker->check(env, thresholdPolytope, eps);
64 bool const isAchievable = achievingPoint.has_value();
65 if (isAchievable) {
67 "Found achievable point: " << storm::utility::vector::toString(achievingPoint->first) << " ( approx. "
68 << storm::utility::vector::toString(storm::utility::vector::convertNumericVector<double>(achievingPoint->first))
69 << " ).");
70 if (optimizingObjectiveIndex.has_value()) {
71 using ValueType = typename SparseModelType::ValueType;
72 // Average between obtained lower- and upper bounds
73 auto result =
74 storm::utility::convertNumber<ValueType, GeometryValueType>(achievingPoint->first[*optimizingObjectiveIndex] + achievingPoint->second);
75 result /= storm::utility::convertNumber<ValueType, uint64_t>(2u);
76 if (objectiveHelper[*optimizingObjectiveIndex].minimizing()) {
77 result *= -storm::utility::one<ValueType>();
78 }
79 return std::make_unique<storm::modelchecker::ExplicitQuantitativeCheckResult<ValueType>>(originalModelInitialState, result);
80 }
81 }
82 return std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult>(originalModelInitialState, isAchievable);
83}
84
89} // namespace storm::modelchecker::multiobjective
ModelCheckerEnvironment & modelchecker()
MultiObjectiveModelCheckerEnvironment & multi()
DeterministicSchedsAchievabilityChecker(preprocessing::SparseMultiObjectivePreprocessorResult< SparseModelType > &preprocessorResult)
static std::shared_ptr< Polytope< ValueType > > create(std::vector< Halfspace< ValueType > > const &halfspaces)
Creates a polytope from the given halfspaces.
#define STORM_LOG_INFO(message)
Definition logging.h:24
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
std::string toString(std::vector< ValueType > const &vector)
Output vector as string.
Definition vector.h:1145