16namespace transformer {
18template<
typename SparseModelType>
24template<
typename SparseModelType>
33 STORM_LOG_DEBUG(
"Can not simplify when Until-formula has non-propositional subformula(s). Formula: " << formula);
40 std::pair<storm::storage::BitVector, storm::storage::BitVector> statesWithProbability01 =
46 this->originalModel.getTransitionMatrix(), this->originalModel.getInitialStates() & ~statesWithProbability01.first, ~statesWithProbability01.first,
47 statesWithProbability01.second);
53 goalStateMerger.
mergeTargetAndSinkStates(maybeStates, statesWithProbability01.second, statesWithProbability01.first);
54 this->simplifiedModel = mergerResult.
model;
57 statesWithProbability01.first.set(mergerResult.
sinkState.get(),
true);
59 std::string sinkLabel =
"sink";
60 while (this->simplifiedModel->hasLabel(sinkLabel)) {
61 sinkLabel =
"_" + sinkLabel;
63 this->simplifiedModel->getStateLabeling().addLabel(sinkLabel, std::move(statesWithProbability01.first));
66 statesWithProbability01.second.set(mergerResult.
targetState.get(),
true);
68 std::string targetLabel =
"target";
69 while (this->simplifiedModel->hasLabel(targetLabel)) {
70 targetLabel =
"_" + targetLabel;
72 this->simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(statesWithProbability01.second));
75 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
77 this->simplifiedFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula const>(eventuallyFormula, formula.
getOperatorInformation());
85 considerForElimination.
set(*mergerResult.
sinkState,
false);
87 this->simplifiedModel = this->eliminateConstantDeterministicStates(*this->simplifiedModel, considerForElimination);
91 this->simplifiedModel = this->eliminateNeutralEndComponents(
92 *this->simplifiedModel, this->simplifiedModel->getStates(targetLabel) | this->simplifiedModel->getStates(sinkLabel));
98template<
typename SparseModelType>
101 "Lower step bounds are not supported.");
103 "Expected a bounded until formula with an upper bound.");
105 storm::exceptions::UnexpectedException,
"Expected a bounded until formula with integral bounds.");
111 STORM_LOG_THROW(upperStepBound > 0, storm::exceptions::UnexpectedException,
"Expected a strict upper bound that is greater than zero.");
119 STORM_LOG_DEBUG(
"Can not simplify when Until-formula has non-propositional subformula(s). Formula: " << formula);
123 ->asExplicitQualitativeCheckResult()
124 .getTruthValuesVector());
126 ->asExplicitQualitativeCheckResult()
127 .getTruthValuesVector());
130 this->originalModel.getTransitionMatrix().getRowGroupIndices(),
131 this->originalModel.getBackwardTransitions(), phiStates, psiStates,
true, upperStepBound)
138 probGreater0States, psiStates,
true, upperStepBound);
146 this->simplifiedModel = mergerResult.
model;
151 std::string targetLabel =
"target";
152 while (this->simplifiedModel->hasLabel(targetLabel)) {
153 targetLabel =
"_" + targetLabel;
155 this->simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(psiStates));
158 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
159 auto boundedUntilFormula =
164 this->simplifiedFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula const>(boundedUntilFormula, formula.
getOperatorInformation());
169template<
typename SparseModelType>
171 typename SparseModelType::RewardModelType
const& originalRewardModel =
180 STORM_LOG_DEBUG(
"Can not simplify when reachability reward formula has non-propositional subformula(s). Formula: " << formula);
189 originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()), targetStates)
191 originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()), targetStates);
200 this->originalModel.getTransitionMatrix(), this->originalModel.getInitialStates() & statesWithProb1, statesWithProb1, targetStates);
204 std::vector<std::string> rewardModelNameAsVector(
208 goalStateMerger.mergeTargetAndSinkStates(maybeStates, targetStates, infinityStates, rewardModelNameAsVector);
209 this->simplifiedModel = mergerResult.
model;
214 std::string sinkLabel =
"sink";
215 while (this->simplifiedModel->hasLabel(sinkLabel)) {
216 sinkLabel =
"_" + sinkLabel;
218 this->simplifiedModel->getStateLabeling().addLabel(sinkLabel, std::move(infinityStates));
224 std::string targetLabel =
"target";
225 while (this->simplifiedModel->hasLabel(targetLabel)) {
226 targetLabel =
"_" + targetLabel;
228 this->simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(targetStates));
231 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
233 this->simplifiedFormula =
234 std::make_shared<storm::logic::RewardOperatorFormula const>(eventuallyFormula, rewardModelNameAsVector.front(), formula.
getOperatorInformation());
242 considerForElimination.
set(*mergerResult.
sinkState,
false);
244 this->simplifiedModel = this->eliminateConstantDeterministicStates(*this->simplifiedModel, considerForElimination, rewardModelNameAsVector.front());
248 this->simplifiedModel = this->eliminateNeutralEndComponents(*this->simplifiedModel,
249 this->simplifiedModel->getStates(targetLabel) | this->simplifiedModel->getStates(sinkLabel),
250 rewardModelNameAsVector.front());
255template<
typename SparseModelType>
258 storm::exceptions::UnexpectedException,
"Expected a cumulative reward formula with integral bound.");
260 typename SparseModelType::RewardModelType
const& originalRewardModel =
267 STORM_LOG_THROW(stepBound > 0, storm::exceptions::UnexpectedException,
"Expected a strict upper bound that is greater than zero.");
274 this->originalModel.getTransitionMatrix(), this->originalModel.getTransitionMatrix().getRowGroupIndices(),
276 ~originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()),
true, stepBound)
279 ~originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()),
true, stepBound);
284 std::vector<std::string> rewardModelNameAsVector(
288 goalStateMerger.mergeTargetAndSinkStates(maybeStates, noStates, zeroRewardStates, rewardModelNameAsVector);
289 this->simplifiedModel = mergerResult.
model;
297template<
typename SparseModelType>
299 SparseModelType
const& model,
storm::storage::BitVector const& ignoredStates, boost::optional<std::string>
const& rewardModelName) {
302 for (
auto const& state : ignoredStates) {
303 for (uint_fast64_t actionIndex = model.getTransitionMatrix().getRowGroupIndices()[state];
304 actionIndex < model.getTransitionMatrix().getRowGroupIndices()[state + 1]; ++actionIndex) {
305 possibleECActions.
set(actionIndex,
false);
310 std::vector<typename SparseModelType::ValueType> actionRewards;
311 if (rewardModelName) {
312 actionRewards = model.getRewardModel(*rewardModelName).getTotalRewardVector(model.getTransitionMatrix());
313 uint_fast64_t actionIndex = 0;
314 for (
auto const& actionReward : actionRewards) {
316 possibleECActions.
set(actionIndex,
false);
328 std::unordered_map<std::string, typename SparseModelType::RewardModelType> rewardModels;
329 if (rewardModelName) {
330 std::vector<typename SparseModelType::ValueType> newActionRewards(ecEliminatorResult.matrix.getRowCount());
332 rewardModels.insert(std::make_pair(*rewardModelName,
typename SparseModelType::RewardModelType(std::nullopt, std::move(actionRewards))));
337 for (
auto const& label : model.getStateLabeling().getLabels()) {
338 auto const& origStatesWithLabel = model.getStates(label);
340 for (
auto const& origState : origStatesWithLabel) {
341 newStatesWithLabel.
set(ecEliminatorResult.oldToNewStateMapping[origState],
true);
343 labeling.
addLabel(label, std::move(newStatesWithLabel));
346 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
Determines whether the model checker can handle the given verification task.
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