20template<
typename SparseModelType>
26template<
typename SparseModelType>
35 STORM_LOG_DEBUG(
"Can not simplify when Until-formula has non-propositional subformula(s). Formula: " << formula);
39 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
40 .getTruthValuesVector());
42 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
43 .getTruthValuesVector());
44 std::pair<storm::storage::BitVector, storm::storage::BitVector> statesWithProbability01 =
50 this->
originalModel.getTransitionMatrix(), this->originalModel.getInitialStates() & ~statesWithProbability01.first, ~statesWithProbability01.first,
51 statesWithProbability01.second);
57 goalStateMerger.
mergeTargetAndSinkStates(maybeStates, statesWithProbability01.second, statesWithProbability01.first);
61 statesWithProbability01.first.set(mergerResult.
sinkState.get(),
true);
63 std::string sinkLabel =
"sink";
65 sinkLabel =
"_" + sinkLabel;
67 this->
simplifiedModel->getStateLabeling().addLabel(sinkLabel, std::move(statesWithProbability01.first));
70 statesWithProbability01.second.set(mergerResult.
targetState.get(),
true);
72 std::string targetLabel =
"target";
74 targetLabel =
"_" + targetLabel;
76 this->
simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(statesWithProbability01.second));
79 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
89 considerForElimination.
set(*mergerResult.
sinkState,
false);
102template<
typename SparseModelType>
105 "Lower step bounds are not supported.");
107 "Expected a bounded until formula with an upper bound.");
109 storm::exceptions::UnexpectedException,
"Expected a bounded until formula with integral bounds.");
115 STORM_LOG_THROW(upperStepBound > 0, storm::exceptions::UnexpectedException,
"Expected a strict upper bound that is greater than zero.");
123 STORM_LOG_DEBUG(
"Can not simplify when Until-formula has non-propositional subformula(s). Formula: " << formula);
127 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
128 .getTruthValuesVector());
130 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
131 .getTruthValuesVector());
134 this->originalModel.getTransitionMatrix().getRowGroupIndices(),
135 this->originalModel.getBackwardTransitions(), phiStates, psiStates,
true, upperStepBound)
142 probGreater0States, psiStates,
true, upperStepBound);
155 std::string targetLabel =
"target";
157 targetLabel =
"_" + targetLabel;
159 this->
simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(psiStates));
162 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
163 auto boundedUntilFormula =
173template<
typename SparseModelType>
175 typename SparseModelType::RewardModelType
const& originalRewardModel =
184 STORM_LOG_DEBUG(
"Can not simplify when reachability reward formula has non-propositional subformula(s). Formula: " << formula);
188 ->template asExplicitQualitativeCheckResult<typename SparseModelType::ValueType>()
189 .getTruthValuesVector());
194 originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()), targetStates)
196 originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()), targetStates);
205 this->
originalModel.getTransitionMatrix(), this->originalModel.getInitialStates() & statesWithProb1, statesWithProb1, targetStates);
209 std::vector<std::string> rewardModelNameAsVector(
219 std::string sinkLabel =
"sink";
221 sinkLabel =
"_" + sinkLabel;
223 this->
simplifiedModel->getStateLabeling().addLabel(sinkLabel, std::move(infinityStates));
229 std::string targetLabel =
"target";
231 targetLabel =
"_" + targetLabel;
233 this->
simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(targetStates));
236 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
239 std::make_shared<storm::logic::RewardOperatorFormula const>(eventuallyFormula, rewardModelNameAsVector.front(), formula.
getOperatorInformation());
247 considerForElimination.
set(*mergerResult.
sinkState,
false);
255 rewardModelNameAsVector.front());
260template<
typename SparseModelType>
263 storm::exceptions::UnexpectedException,
"Expected a cumulative reward formula with integral bound.");
265 typename SparseModelType::RewardModelType
const& originalRewardModel =
272 STORM_LOG_THROW(stepBound > 0, storm::exceptions::UnexpectedException,
"Expected a strict upper bound that is greater than zero.");
279 this->
originalModel.getTransitionMatrix(), this->originalModel.getTransitionMatrix().getRowGroupIndices(),
281 ~originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()),
true, stepBound)
284 ~originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()),
true, stepBound);
289 std::vector<std::string> rewardModelNameAsVector(
302template<
typename SparseModelType>
304 SparseModelType
const& model,
storm::storage::BitVector const& ignoredStates, boost::optional<std::string>
const& rewardModelName) {
307 for (uint64_t state : ignoredStates) {
308 for (uint_fast64_t actionIndex = model.getTransitionMatrix().getRowGroupIndices()[state];
309 actionIndex < model.getTransitionMatrix().getRowGroupIndices()[state + 1]; ++actionIndex) {
310 possibleECActions.
set(actionIndex,
false);
315 std::vector<typename SparseModelType::ValueType> actionRewards;
316 if (rewardModelName) {
317 actionRewards = model.getRewardModel(*rewardModelName).getTotalRewardVector(model.getTransitionMatrix());
318 uint_fast64_t actionIndex = 0;
319 for (
auto const& actionReward : actionRewards) {
321 possibleECActions.
set(actionIndex,
false);
333 std::unordered_map<std::string, typename SparseModelType::RewardModelType> rewardModels;
334 if (rewardModelName) {
335 std::vector<typename SparseModelType::ValueType> newActionRewards(ecEliminatorResult.matrix.getRowCount());
337 rewardModels.insert(std::make_pair(*rewardModelName,
typename SparseModelType::RewardModelType(std::nullopt, std::move(actionRewards))));
342 for (
auto const& label : model.getStateLabeling().getLabels()) {
343 auto const& origStatesWithLabel = model.getStates(label);
345 for (
auto const& origState : origStatesWithLabel) {
346 newStatesWithLabel.
set(ecEliminatorResult.oldToNewStateMapping[origState],
true);
348 labeling.
addLabel(label, std::move(newStatesWithLabel));
351 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