Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
PcaaWeightVectorChecker.cpp
Go to the documentation of this file.
2
9
10namespace storm {
11namespace modelchecker {
12namespace multiobjective {
13
14template<typename ModelType>
18
19template<typename ModelType>
21 weightedPrecision = value;
22}
23
24template<typename ModelType>
26 STORM_LOG_THROW(weightedPrecision.has_value(), storm::exceptions::InvalidOperationException, "The weighted precision has not been set.");
27 return weightedPrecision.value();
28}
29
30template<typename ModelType>
34
35template<typename ModelType>
37 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Scheduler generation is not supported in this setting.");
38}
39
40template<class SparseModelType>
41boost::optional<typename SparseModelType::ValueType> PcaaWeightVectorChecker<SparseModelType>::computeWeightedResultBound(
42 bool lower, std::vector<ValueType> const& weightVector, storm::storage::BitVector const& objectiveFilter) const {
44 for (auto objIndex : objectiveFilter) {
45 // get the actual weight for this objective, i.e., negate it if this is a minimizing objective
46 auto const weight = storm::solver::minimize(this->objectives[objIndex].formula->getOptimalityType()) ? -weightVector[objIndex] : weightVector[objIndex];
47 if (storm::utility::isZero(weight)) {
48 continue; // this objective is not relevant for the weighted sum, so we can skip it
49 } else {
50 // Choose the requested, relevant bound (lower or upper). Invert the choice for negative weights.
51 boost::optional<ValueType> const& objBound = (lower == (weight > storm::utility::zero<ValueType>())) ? this->objectives[objIndex].lowerResultBound
52 : this->objectives[objIndex].upperResultBound;
53 if (objBound) {
54 result += objBound.get() * weight;
55 } else {
56 // If there is an objective without the corresponding bound we can not give guarantees for the weighted sum
57 return boost::none;
58 }
59 }
60 }
61 return result;
62}
63
64template<typename ModelType>
65std::unique_ptr<PcaaWeightVectorChecker<ModelType>> createWeightVectorChecker(
67 if constexpr (std::is_same_v<ModelType, storm::models::sparse::Mdp<typename ModelType::ValueType>>) {
68 if (preprocessorResult.containsRewardBoundedObjective()) {
69 return std::make_unique<RewardBoundedMdpPcaaWeightVectorChecker<ModelType>>(preprocessorResult);
70 } else {
71 return std::make_unique<StandardMdpPcaaWeightVectorChecker<ModelType>>(preprocessorResult);
72 }
73 } else {
74 static_assert(std::is_same_v<ModelType, storm::models::sparse::MarkovAutomaton<typename ModelType::ValueType>>);
75 STORM_LOG_THROW(!preprocessorResult.containsRewardBoundedObjective(), storm::exceptions::NotSupportedException,
76 "Reward-bounded objectives are not supported for multi-objective Markov automata.");
77 return std::make_unique<StandardMaPcaaWeightVectorChecker<ModelType>>(preprocessorResult);
78 }
79}
80
81template class PcaaWeightVectorChecker<storm::models::sparse::Mdp<double>>;
82template class PcaaWeightVectorChecker<storm::models::sparse::Mdp<storm::RationalNumber>>;
83template class PcaaWeightVectorChecker<storm::models::sparse::MarkovAutomaton<double>>;
84template class PcaaWeightVectorChecker<storm::models::sparse::MarkovAutomaton<storm::RationalNumber>>;
85
86template std::unique_ptr<PcaaWeightVectorChecker<storm::models::sparse::Mdp<double>>> createWeightVectorChecker(
88template std::unique_ptr<PcaaWeightVectorChecker<storm::models::sparse::Mdp<RationalNumber>>> createWeightVectorChecker(
90template std::unique_ptr<PcaaWeightVectorChecker<storm::models::sparse::MarkovAutomaton<double>>> createWeightVectorChecker(
92template std::unique_ptr<PcaaWeightVectorChecker<storm::models::sparse::MarkovAutomaton<RationalNumber>>> createWeightVectorChecker(
94
95} // namespace multiobjective
96} // namespace modelchecker
97} // namespace storm
PcaaWeightVectorChecker(std::vector< Objective< ValueType > > const &objectives)
boost::optional< ValueType > computeWeightedResultBound(bool lower, std::vector< ValueType > const &weightVector, storm::storage::BitVector const &objectiveFilter) const
Computes the weighted lower or upper bounds for the provided set of objectives.
virtual bool smallPrecisionsAreChallenging() const
Returns whether achieving precise values (i.e.
void setWeightedPrecision(ValueType const &value)
Sets the precision of this weight vector checker.
ValueType const & getWeightedPrecision() const
Returns the current precision of this weight vector checker as specified by setWeightedPrecision().
virtual storm::storage::Scheduler< ValueType > computeScheduler() const
Retrieves a scheduler that induces the current values (if such a scheduler was generated).
This class represents a Markov automaton.
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:13
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
This class defines which action is chosen in a particular state of a non-deterministic model.
Definition Scheduler.h:18
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
std::unique_ptr< PcaaWeightVectorChecker< ModelType > > createWeightVectorChecker(preprocessing::SparseMultiObjectivePreprocessorResult< ModelType > const &preprocessorResult)
bool constexpr minimize(OptimizationDirection d)
bool isZero(ValueType const &a)
Definition constants.cpp:39
ValueType zero()
Definition constants.cpp:24