17namespace transformer {
19template<
typename SparseModelType>
25template<
typename SparseModelType>
34 STORM_LOG_DEBUG(
"Can not simplify when Until-formula has non-propositional subformula(s). Formula: " << formula);
41 std::pair<storm::storage::BitVector, storm::storage::BitVector> statesWithProbability01 =
47 this->originalModel.getTransitionMatrix(), this->originalModel.getInitialStates() & ~statesWithProbability01.first, ~statesWithProbability01.first,
48 statesWithProbability01.second);
54 goalStateMerger.
mergeTargetAndSinkStates(maybeStates, statesWithProbability01.second, statesWithProbability01.first);
55 this->simplifiedModel = mergerResult.
model;
58 statesWithProbability01.first.set(mergerResult.
sinkState.get(),
true);
60 std::string sinkLabel =
"sink";
61 while (this->simplifiedModel->hasLabel(sinkLabel)) {
62 sinkLabel =
"_" + sinkLabel;
64 this->simplifiedModel->getStateLabeling().addLabel(sinkLabel, std::move(statesWithProbability01.first));
67 statesWithProbability01.second.set(mergerResult.
targetState.get(),
true);
69 std::string targetLabel =
"target";
70 while (this->simplifiedModel->hasLabel(targetLabel)) {
71 targetLabel =
"_" + targetLabel;
73 this->simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(statesWithProbability01.second));
76 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
78 this->simplifiedFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula const>(eventuallyFormula, formula.
getOperatorInformation());
86 considerForElimination.
set(*mergerResult.
sinkState,
false);
88 this->simplifiedModel = this->eliminateConstantDeterministicStates(*this->simplifiedModel, considerForElimination);
92 this->simplifiedModel = this->eliminateNeutralEndComponents(
93 *this->simplifiedModel, this->simplifiedModel->getStates(targetLabel) | this->simplifiedModel->getStates(sinkLabel));
99template<
typename SparseModelType>
102 "Lower step bounds are not supported.");
104 "Expected a bounded until formula with an upper bound.");
106 storm::exceptions::UnexpectedException,
"Expected a bounded until formula with integral bounds.");
112 STORM_LOG_THROW(upperStepBound > 0, storm::exceptions::UnexpectedException,
"Expected a strict upper bound that is greater than zero.");
120 STORM_LOG_DEBUG(
"Can not simplify when Until-formula has non-propositional subformula(s). Formula: " << formula);
124 ->asExplicitQualitativeCheckResult()
125 .getTruthValuesVector());
127 ->asExplicitQualitativeCheckResult()
128 .getTruthValuesVector());
131 this->originalModel.getTransitionMatrix().getRowGroupIndices(),
132 this->originalModel.getBackwardTransitions(), phiStates, psiStates,
true, upperStepBound)
139 probGreater0States, psiStates,
true, upperStepBound);
147 this->simplifiedModel = mergerResult.
model;
152 std::string targetLabel =
"target";
153 while (this->simplifiedModel->hasLabel(targetLabel)) {
154 targetLabel =
"_" + targetLabel;
156 this->simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(psiStates));
159 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
160 auto boundedUntilFormula =
165 this->simplifiedFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula const>(boundedUntilFormula, formula.
getOperatorInformation());
170template<
typename SparseModelType>
172 typename SparseModelType::RewardModelType
const& originalRewardModel =
181 STORM_LOG_DEBUG(
"Can not simplify when reachability reward formula has non-propositional subformula(s). Formula: " << formula);
190 originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()), targetStates)
192 originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()), targetStates);
201 this->originalModel.getTransitionMatrix(), this->originalModel.getInitialStates() & statesWithProb1, statesWithProb1, targetStates);
205 std::vector<std::string> rewardModelNameAsVector(
209 goalStateMerger.mergeTargetAndSinkStates(maybeStates, targetStates, infinityStates, rewardModelNameAsVector);
210 this->simplifiedModel = mergerResult.
model;
215 std::string sinkLabel =
"sink";
216 while (this->simplifiedModel->hasLabel(sinkLabel)) {
217 sinkLabel =
"_" + sinkLabel;
219 this->simplifiedModel->getStateLabeling().addLabel(sinkLabel, std::move(infinityStates));
225 std::string targetLabel =
"target";
226 while (this->simplifiedModel->hasLabel(targetLabel)) {
227 targetLabel =
"_" + targetLabel;
229 this->simplifiedModel->getStateLabeling().addLabel(targetLabel, std::move(targetStates));
232 auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula const>(targetLabel);
234 this->simplifiedFormula =
235 std::make_shared<storm::logic::RewardOperatorFormula const>(eventuallyFormula, rewardModelNameAsVector.front(), formula.
getOperatorInformation());
243 considerForElimination.
set(*mergerResult.
sinkState,
false);
245 this->simplifiedModel = this->eliminateConstantDeterministicStates(*this->simplifiedModel, considerForElimination, rewardModelNameAsVector.front());
249 this->simplifiedModel = this->eliminateNeutralEndComponents(*this->simplifiedModel,
250 this->simplifiedModel->getStates(targetLabel) | this->simplifiedModel->getStates(sinkLabel),
251 rewardModelNameAsVector.front());
256template<
typename SparseModelType>
259 storm::exceptions::UnexpectedException,
"Expected a cumulative reward formula with integral bound.");
261 typename SparseModelType::RewardModelType
const& originalRewardModel =
268 STORM_LOG_THROW(stepBound > 0, storm::exceptions::UnexpectedException,
"Expected a strict upper bound that is greater than zero.");
275 this->originalModel.getTransitionMatrix(), this->originalModel.getTransitionMatrix().getRowGroupIndices(),
277 ~originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()),
true, stepBound)
280 ~originalRewardModel.getStatesWithZeroReward(this->originalModel.getTransitionMatrix()),
true, stepBound);
285 std::vector<std::string> rewardModelNameAsVector(
289 goalStateMerger.mergeTargetAndSinkStates(maybeStates, noStates, zeroRewardStates, rewardModelNameAsVector);
290 this->simplifiedModel = mergerResult.
model;
298template<
typename SparseModelType>
300 SparseModelType
const& model,
storm::storage::BitVector const& ignoredStates, boost::optional<std::string>
const& rewardModelName) {
303 for (
auto const& state : ignoredStates) {
304 for (uint_fast64_t actionIndex = model.getTransitionMatrix().getRowGroupIndices()[state];
305 actionIndex < model.getTransitionMatrix().getRowGroupIndices()[state + 1]; ++actionIndex) {
306 possibleECActions.
set(actionIndex,
false);
311 std::vector<typename SparseModelType::ValueType> actionRewards;
312 if (rewardModelName) {
313 actionRewards = model.getRewardModel(*rewardModelName).getTotalRewardVector(model.getTransitionMatrix());
314 uint_fast64_t actionIndex = 0;
315 for (
auto const& actionReward : actionRewards) {
317 possibleECActions.
set(actionIndex,
false);
329 std::unordered_map<std::string, typename SparseModelType::RewardModelType> rewardModels;
330 if (rewardModelName) {
331 std::vector<typename SparseModelType::ValueType> newActionRewards(ecEliminatorResult.matrix.getRowCount());
333 rewardModels.insert(std::make_pair(*rewardModelName,
typename SparseModelType::RewardModelType(std::nullopt, std::move(actionRewards))));
338 for (
auto const& label : model.getStateLabeling().getLabels()) {
339 auto const& origStatesWithLabel = model.getStates(label);
341 for (
auto const& origState : origStatesWithLabel) {
342 newStatesWithLabel.
set(ecEliminatorResult.oldToNewStateMapping[origState],
true);
344 labeling.
addLabel(label, std::move(newStatesWithLabel));
347 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(uint_fast64_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