18template<
typename SparseModelType>
24template<
typename SparseModelType>
33 STORM_LOG_DEBUG(
"Can not simplify when Until-formula has non-propositional subformula(s). Formula: " << formula);
37 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
38 .getTruthValuesVector());
40 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
41 .getTruthValuesVector());
42 std::pair<storm::storage::BitVector, storm::storage::BitVector> statesWithProbability01 =
48 this->
originalModel.getTransitionMatrix(), this->originalModel.getInitialStates() & ~statesWithProbability01.first, ~statesWithProbability01.first,
49 statesWithProbability01.second);
55 goalStateMerger.
mergeTargetAndSinkStates(maybeStates, statesWithProbability01.second, statesWithProbability01.first);
59 statesWithProbability01.first.set(mergerResult.
sinkState.get(),
true);
61 std::string sinkLabel =
"sink";
63 sinkLabel =
"_" + sinkLabel;
65 this->
simplifiedModel->getStateLabeling().addLabel(sinkLabel, std::move(statesWithProbability01.first));
68 statesWithProbability01.second.set(mergerResult.
targetState.get(),
true);
70 std::string targetLabel =
"target";
72 targetLabel =
"_" + targetLabel;
74 this->
simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(statesWithProbability01.second));
77 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
87 considerForElimination.
set(*mergerResult.
sinkState,
false);
100template<
typename SparseModelType>
103 "Lower step bounds are not supported.");
105 "Expected a bounded until formula with an upper bound.");
107 storm::exceptions::UnexpectedException,
"Expected a bounded until formula with integral bounds.");
113 STORM_LOG_THROW(upperStepBound > 0, storm::exceptions::UnexpectedException,
"Expected a strict upper bound that is greater than zero.");
121 STORM_LOG_DEBUG(
"Can not simplify when Until-formula has non-propositional subformula(s). Formula: " << formula);
125 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
126 .getTruthValuesVector());
128 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
129 .getTruthValuesVector());
132 this->originalModel.getTransitionMatrix().getRowGroupIndices(),
133 this->originalModel.getBackwardTransitions(), phiStates, psiStates,
true, upperStepBound)
140 probGreater0States, psiStates,
true, upperStepBound);
153 std::string targetLabel =
"target";
155 targetLabel =
"_" + targetLabel;
157 this->
simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(psiStates));
160 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
161 auto boundedUntilFormula =
171template<
typename SparseModelType>
173 typename SparseModelType::RewardModelType
const& originalRewardModel =
182 STORM_LOG_DEBUG(
"Can not simplify when reachability reward formula has non-propositional subformula(s). Formula: " << formula);
186 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
187 .getTruthValuesVector());
192 originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()), targetStates)
194 originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()), targetStates);
203 this->
originalModel.getTransitionMatrix(), this->originalModel.getInitialStates() & statesWithProb1, statesWithProb1, targetStates);
207 std::vector<std::string> rewardModelNameAsVector(
217 std::string sinkLabel =
"sink";
219 sinkLabel =
"_" + sinkLabel;
221 this->
simplifiedModel->getStateLabeling().addLabel(sinkLabel, std::move(infinityStates));
227 std::string targetLabel =
"target";
229 targetLabel =
"_" + targetLabel;
231 this->
simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(targetStates));
234 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
237 std::make_shared<storm::logic::RewardOperatorFormula const>(eventuallyFormula, rewardModelNameAsVector.front(), formula.
getOperatorInformation());
245 considerForElimination.
set(*mergerResult.
sinkState,
false);
252 this->
simplifiedModel->getStates(targetLabel) | this->simplifiedModel->getStates(sinkLabel),
253 rewardModelNameAsVector.front());
258template<
typename SparseModelType>
261 storm::exceptions::UnexpectedException,
"Expected a cumulative reward formula with integral bound.");
263 typename SparseModelType::RewardModelType
const& originalRewardModel =
270 STORM_LOG_THROW(stepBound > 0, storm::exceptions::UnexpectedException,
"Expected a strict upper bound that is greater than zero.");
277 this->
originalModel.getTransitionMatrix(), this->originalModel.getTransitionMatrix().getRowGroupIndices(),
279 ~originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()),
true, stepBound)
282 ~originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()),
true, stepBound);
287 std::vector<std::string> rewardModelNameAsVector(
300template<
typename SparseModelType>
302 SparseModelType
const& model,
storm::storage::BitVector const& ignoredStates, boost::optional<std::string>
const& rewardModelName) {
305 for (
auto const& state : ignoredStates) {
306 for (uint_fast64_t actionIndex = model.getTransitionMatrix().getRowGroupIndices()[state];
307 actionIndex < model.getTransitionMatrix().getRowGroupIndices()[state + 1]; ++actionIndex) {
308 possibleECActions.
set(actionIndex,
false);
313 std::vector<typename SparseModelType::ValueType> actionRewards;
314 if (rewardModelName) {
315 actionRewards = model.getRewardModel(*rewardModelName).getTotalRewardVector(model.getTransitionMatrix());
316 uint_fast64_t actionIndex = 0;
317 for (
auto const& actionReward : actionRewards) {
319 possibleECActions.
set(actionIndex,
false);
331 std::unordered_map<std::string, typename SparseModelType::RewardModelType> rewardModels;
332 if (rewardModelName) {
333 std::vector<typename SparseModelType::ValueType> newActionRewards(ecEliminatorResult.matrix.getRowCount());
335 rewardModels.insert(std::make_pair(*rewardModelName,
typename SparseModelType::RewardModelType(std::nullopt, std::move(actionRewards))));
340 for (
auto const& label : model.getStateLabeling().getLabels()) {
341 auto const& origStatesWithLabel = model.getStates(label);
343 for (
auto const& origState : origStatesWithLabel) {
344 newStatesWithLabel.
set(ecEliminatorResult.oldToNewStateMapping[origState],
true);
346 labeling.
addLabel(label, std::move(newStatesWithLabel));
349 return std::make_shared<SparseModelType>(std::move(ecEliminatorResult.matrix), std::move(labeling), std::move(rewardModels));
virtual bool isIntegerLiteralExpression() const
int_fast64_t evaluateAsInt(Valuation const *valuation=nullptr) const
Evaluates the expression under the valuation of variables given by the valuation and returns the resu...
BaseExpression const & getBaseExpression() const
Retrieves the base expression underlying this expression object.
std::shared_ptr< Formula > clone(Formula const &f) const
virtual std::unique_ptr< CheckResult > check(Environment const &env, CheckTask< storm::logic::Formula, SolutionType > const &checkTask)
Checks the provided formula.
virtual bool canHandle(CheckTask< storm::logic::Formula, SolutionType > const &checkTask) const override
void addLabel(std::string const &label)
Adds a new label to the labelings.
This class manages the labeling of the state space with a number of (atomic) labels.
A bit vector that is internally represented as a vector of 64-bit values.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
#define STORM_LOG_DEBUG(message)
#define STORM_LOG_THROW(cond, exception, message)
bool isLowerBound(ComparisonType t)
bool constexpr minimize(OptimizationDirection d)
std::pair< storm::storage::BitVector, storm::storage::BitVector > performProb01Max(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
storm::storage::BitVector getReachableStates(storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::BitVector const &initialStates, storm::storage::BitVector const &constraintStates, storm::storage::BitVector const &targetStates, bool useStepBound, uint_fast64_t maximalSteps, boost::optional< storm::storage::BitVector > const &choiceFilter)
Performs a forward depth-first search through the underlying graph structure to identify the states t...
storm::storage::BitVector performProbGreater0A(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool useStepBound, uint_fast64_t maximalSteps, boost::optional< storm::storage::BitVector > const &choiceConstraint)
Computes the sets of states that have probability greater 0 of satisfying phi until psi under any pos...
storm::storage::BitVector performProb1A(storm::models::sparse::NondeterministicModel< T, RM > const &model, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Computes the sets of states that have probability 1 of satisfying phi until psi under all possible re...
storm::storage::BitVector performProbGreater0E(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool useStepBound, uint_fast64_t maximalSteps)
Computes the sets of states that have probability greater 0 of satisfying phi until psi under at leas...
std::pair< storm::storage::BitVector, storm::storage::BitVector > performProb01Min(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
storm::storage::BitVector performProb1E(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, boost::optional< storm::storage::BitVector > const &choiceConstraint)
Computes the sets of states that have probability 1 of satisfying phi until psi under at least one po...
void selectVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< T > const &values)
Selects the elements from a vector at the specified positions and writes them consecutively into anot...
bool isZero(ValueType const &a)
ComparisonType comparisonType