1#ifndef STORM_MODELCHECKER_CHECKTASK_H_
2#define STORM_MODELCHECKER_CHECKTASK_H_
4#include <boost/optional.hpp>
23namespace modelchecker {
30template<
typename FormulaType = storm::logic::Formula,
typename ValueType =
double>
33 template<
typename OtherFormulaType,
typename OtherValueType>
41 this->onlyInitialStatesRelevant = onlyInitialStatesRelevant;
42 this->produceSchedulers =
false;
43 this->qualitative =
false;
44 this->uncertaintyResolutionMode = UncertaintyResolutionMode::Unset;
53 template<
typename NewFormulaType>
56 this->onlyInitialStatesRelevant, this->bound, this->qualitative, this->produceSchedulers, this->hint,
57 this->uncertaintyResolutionMode);
67 if (formula.get().isOperatorFormula()) {
74 this->bound = operatorFormula.
getBound();
79 }
else if (operatorFormula.
hasBound()) {
82 ? OptimizationDirection::Maximize
83 : OptimizationDirection::Minimize;
86 if (formula.get().isProbabilityOperatorFormula()) {
89 if (probabilityOperatorFormula.
hasBound()) {
92 this->qualitative =
true;
95 }
else if (formula.get().isRewardOperatorFormula()) {
99 if (rewardOperatorFormula.
hasBound()) {
101 this->qualitative =
true;
132 template<
typename NewValueType>
135 this->onlyInitialStatesRelevant, this->bound, this->qualitative, this->produceSchedulers, this->hint,
136 this->uncertaintyResolutionMode);
143 return formula.get();
150 return static_cast<bool>(optimizationDirection);
157 return optimizationDirection.get();
164 optimizationDirection = dir;
171 return static_cast<bool>(playerCoalition);
178 return playerCoalition.get();
185 playerCoalition = coalition;
193 return static_cast<bool>(rewardModel);
200 return rewardModel.get();
207 return onlyInitialStatesRelevant;
214 this->onlyInitialStatesRelevant = value;
222 return static_cast<bool>(bound);
229 STORM_LOG_THROW(!bound.get().threshold.containsVariables(), storm::exceptions::InvalidOperationException,
230 "Cannot evaluate threshold '" << bound.get().threshold <<
"' as it contains undefined constants.");
231 return bound.get().template evaluateThresholdAs<ValueType>();
238 return bound.get().comparisonType;
275 this->produceSchedulers = produceSchedulers;
282 return produceSchedulers;
288 void setHint(std::shared_ptr<ModelCheckerHint>
const& hint) {
307 return uncertaintyResolutionMode;
314 this->uncertaintyResolutionMode = uncertaintyResolutionMode;
321 return isSet(this->uncertaintyResolutionMode);
328 return this->
template substituteFormula<storm::logic::Formula>(this->
getFormula());
347 CheckTask(std::reference_wrapper<FormulaType const>
const& formula, boost::optional<storm::OptimizationDirection>
const& optimizationDirection,
348 boost::optional<storm::logic::PlayerCoalition> playerCoalition, boost::optional<std::string>
const& rewardModel,
bool onlyInitialStatesRelevant,
349 boost::optional<storm::logic::Bound>
const& bound,
bool qualitative,
bool produceSchedulers, std::shared_ptr<ModelCheckerHint>
const& hint,
352 optimizationDirection(optimizationDirection),
353 playerCoalition(playerCoalition),
354 rewardModel(rewardModel),
355 onlyInitialStatesRelevant(onlyInitialStatesRelevant),
357 qualitative(qualitative),
358 produceSchedulers(produceSchedulers),
360 uncertaintyResolutionMode(uncertaintyResolutionMode) {
365 std::reference_wrapper<FormulaType const> formula;
368 boost::optional<storm::OptimizationDirection> optimizationDirection;
371 boost::optional<storm::logic::PlayerCoalition> playerCoalition;
374 boost::optional<std::string> rewardModel;
377 bool onlyInitialStatesRelevant;
380 boost::optional<storm::logic::Bound> bound;
387 bool produceSchedulers;
390 std::shared_ptr<ModelCheckerHint> hint;
bool isBoundSet() const
Retrieves whether there is a bound with which the values for the states will be compared.
CheckTask< FormulaType, ValueType > & setOnlyInitialStatesRelevant(bool value=true)
Sets whether only initial states are relevant.
void setOptimizationDirection(storm::OptimizationDirection const &dir)
Sets the optimization direction.
ValueType getBoundThreshold() const
Retrieves the value of the bound (if set).
ModelCheckerHint & getHint()
storm::logic::ComparisonType const & getBoundComparisonType() const
Retrieves the comparison type of the bound (if set).
void setUncertaintyResolutionMode(UncertaintyResolutionMode uncertaintyResolutionMode)
Sets the mode which decides how the uncertainty will be resolved.
bool isOptimizationDirectionSet() const
Retrieves whether an optimization direction was set.
CheckTask< NewFormulaType, ValueType > substituteFormula(NewFormulaType const &newFormula) const
Copies the check task from the source while replacing the formula with the new one.
CheckTask< FormulaType, ValueType > & setPlayerCoalition(storm::logic::PlayerCoalition const &coalition)
Sets the player coalition.
bool isRewardModelSet() const
Retrieves whether a reward model was set.
boost::optional< storm::logic::Bound > const & getOptionalBound() const
Retrieves the bound.
bool isQualitativeSet() const
Retrieves whether the computation only needs to be performed qualitatively, because the values will o...
std::string const & getRewardModel() const
Retrieves the reward model over which to perform the checking (if set).
FormulaType const & getFormula() const
Retrieves the formula from this task.
ModelCheckerHint const & getHint() const
Retrieves a hint that might contain information that speeds up the modelchecking process (if supporte...
CheckTask negate() const
Negate the optimization direction and the bound threshold, if those exist.
bool isUncertaintyResolutionModeSet() const
Returns whether the mode, which decides how the uncertainty will be resolved, is set.
CheckTask(FormulaType const &formula, bool onlyInitialStatesRelevant=false, UncertaintyResolutionMode=UncertaintyResolutionMode::Unset)
Creates a task object with the default options for the given formula.
CheckTask< FormulaType, NewValueType > convertValueType() const
Copies the check task from the source while replacing the considered ValueType the new one.
void setHint(std::shared_ptr< ModelCheckerHint > const &hint)
sets a hint that might contain information that speeds up the modelchecking process (if supported by ...
bool isProduceSchedulersSet() const
Retrieves whether scheduler(s) are to be produced (if supported).
void setProduceSchedulers(bool produceSchedulers=true)
Sets whether to produce schedulers (if supported).
storm::logic::PlayerCoalition const & getPlayerCoalition() const
Retrieves the player coalition (if set).
storm::logic::Bound const & getBound() const
Retrieves the bound (if set).
storm::OptimizationDirection const & getOptimizationDirection() const
Retrieves the optimization direction (if set).
bool isPlayerCoalitionSet() const
Retrieves whether a player coalition was set.
bool isOnlyInitialStatesRelevantSet() const
Retrieves whether only the initial states are relevant in the computation.
UncertaintyResolutionMode getUncertaintyResolutionMode() const
Retrieves the mode which decides how the uncertainty will be resolved.
void updateOperatorInformation()
If the currently specified formula is an OperatorFormula, this method updates the information that is...
void setQualitative(bool value)
sets whether the computation only needs to be performed qualitatively, because the values will only b...
This class contains information that might accelerate the model checking process.
#define STORM_LOG_THROW(cond, exception, message)
ComparisonType invertPreserveStrictness(ComparisonType t)
UncertaintyResolutionMode
bool isOne(ValueType const &a)
bool isZero(ValueType const &a)