@ -7,20 +7,20 @@
# include "src/utility/vector.h"
# include "src/utility/graph.h"
# include "src/modelchecker/ExplicitQualitativeCheckResult.h"
# include "src/modelchecker/ExplicitQuantitativeCheckResult.h"
# include "src/modelchecker/results/ ExplicitQualitativeCheckResult.h"
# include "src/modelchecker/results/ ExplicitQuantitativeCheckResult.h"
# include "src/exceptions/InvalidPropertyException.h"
namespace storm {
namespace modelchecker {
template < typename ValueType >
SparseMdpPrctlModelChecker < ValueType > : : SparseMdpPrctlModelChecker ( storm : : models : : Mdp < ValueType > const & model ) : model ( model ) , nondeterministicLinearEquationSolver ( storm : : utility : : solver : : getNondeterministicLinearEquationSolver < ValueType > ( ) ) {
SparseMdpPrctlModelChecker < ValueType > : : SparseMdpPrctlModelChecker ( storm : : models : : Mdp < ValueType > const & model ) : SparsePropositionalModelChecker < ValueType > ( model ) , nondeterministicLinearEquationSolver ( storm : : utility : : solver : : getNondeterministicLinearEquationSolver < ValueType > ( ) ) {
// Intentionally left empty.
}
template < typename ValueType >
SparseMdpPrctlModelChecker < ValueType > : : SparseMdpPrctlModelChecker ( storm : : models : : Mdp < ValueType > const & model , std : : shared_ptr < storm : : solver : : NondeterministicLinearEquationSolver < ValueType > > nondeterministicLinearEquationSolver ) : model ( model ) , nondeterministicLinearEquationSolver ( nondeterministicLinearEquationSolver ) {
SparseMdpPrctlModelChecker < ValueType > : : SparseMdpPrctlModelChecker ( storm : : models : : Mdp < ValueType > const & model , std : : shared_ptr < storm : : solver : : NondeterministicLinearEquationSolver < ValueType > > nondeterministicLinearEquationSolver ) : SparsePropositionalModelChecker < ValueType > ( model ) , nondeterministicLinearEquationSolver ( nondeterministicLinearEquationSolver ) {
// Intentionally left empty.
}
@ -31,20 +31,20 @@ namespace storm {
template < typename ValueType >
std : : vector < ValueType > SparseMdpPrctlModelChecker < ValueType > : : computeBoundedUntilProbabilitiesHelper ( bool minimize , storm : : storage : : BitVector const & phiStates , storm : : storage : : BitVector const & psiStates , uint_fast64_t stepBound ) const {
std : : vector < ValueType > result ( model . getNumberOfStates ( ) , storm : : utility : : zero < ValueType > ( ) ) ;
std : : vector < ValueType > result ( this - > getModel ( ) . getNumberOfStates ( ) , storm : : utility : : zero < ValueType > ( ) ) ;
// Determine the states that have 0 probability of reaching the target states.
storm : : storage : : BitVector statesWithProbabilityGreater0 ;
if ( minimize ) {
statesWithProbabilityGreater0 = storm : : utility : : graph : : performProbGreater0A ( model . getTransitionMatrix ( ) , model . getTransitionMatrix ( ) . getRowGroupIndices ( ) , model . getBackwardTransitions ( ) , phiStates , psiStates , true , stepBound ) ;
statesWithProbabilityGreater0 = storm : : utility : : graph : : performProbGreater0A ( this - > getModel ( ) . getTransitionMatrix ( ) , this - > getModel ( ) . getTransitionMatrix ( ) . getRowGroupIndices ( ) , this - > getModel ( ) . getBackwardTransitions ( ) , phiStates , psiStates , true , stepBound ) ;
} else {
statesWithProbabilityGreater0 = storm : : utility : : graph : : performProbGreater0E ( model . getTransitionMatrix ( ) , model . getTransitionMatrix ( ) . getRowGroupIndices ( ) , model . getBackwardTransitions ( ) , phiStates , psiStates , true , stepBound ) ;
statesWithProbabilityGreater0 = storm : : utility : : graph : : performProbGreater0E ( this - > getModel ( ) . getTransitionMatrix ( ) , this - > getModel ( ) . getTransitionMatrix ( ) . getRowGroupIndices ( ) , this - > getModel ( ) . getBackwardTransitions ( ) , phiStates , psiStates , true , stepBound ) ;
}
STORM_LOG_INFO ( " Found " < < statesWithProbabilityGreater0 . getNumberOfSetBits ( ) < < " 'maybe' states. " ) ;
if ( ! statesWithProbabilityGreater0 . empty ( ) ) {
// We can eliminate the rows and columns from the original transition probability matrix that have probability 0.
storm : : storage : : SparseMatrix < ValueType > submatrix = model . getTransitionMatrix ( ) . getSubmatrix ( true , statesWithProbabilityGreater0 , statesWithProbabilityGreater0 , false ) ;
storm : : storage : : SparseMatrix < ValueType > submatrix = this - > getModel ( ) . getTransitionMatrix ( ) . getSubmatrix ( true , statesWithProbabilityGreater0 , statesWithProbabilityGreater0 , false ) ;
// Compute the new set of target states in the reduced system.
storm : : storage : : BitVector rightStatesInReducedSystem = psiStates % statesWithProbabilityGreater0 ;
@ -69,7 +69,7 @@ namespace storm {
template < typename ValueType >
std : : unique_ptr < CheckResult > SparseMdpPrctlModelChecker < ValueType > : : computeBoundedUntilProbabilities ( storm : : logic : : BoundedUntilFormula const & pathFormula , bool qualitative , boost : : optional < storm : : logic : : OptimalityType > const & optimalityType ) {
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model . " ) ;
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic this->getModel() . " ) ;
std : : unique_ptr < CheckResult > leftResultPointer = this - > check ( pathFormula . getLeftSubformula ( ) ) ;
std : : unique_ptr < CheckResult > rightResultPointer = this - > check ( pathFormula . getRightSubformula ( ) ) ;
ExplicitQualitativeCheckResult const & leftResult = leftResultPointer - > asExplicitQualitativeCheckResult ( ) ;
@ -81,23 +81,28 @@ namespace storm {
template < typename ValueType >
std : : vector < ValueType > SparseMdpPrctlModelChecker < ValueType > : : computeNextProbabilitiesHelper ( bool minimize , storm : : storage : : BitVector const & nextStates ) {
// Create the vector with which to multiply and initialize it correctly.
std : : vector < ValueType > result ( model . getNumberOfStates ( ) ) ;
std : : vector < ValueType > result ( this - > getModel ( ) . getNumberOfStates ( ) ) ;
storm : : utility : : vector : : setVectorValues ( result , nextStates , storm : : utility : : one < ValueType > ( ) ) ;
STORM_LOG_THROW ( nondeterministicLinearEquationSolver ! = nullptr , storm : : exceptions : : InvalidStateException , " No valid equation solver available. " ) ;
this - > nondeterministicLinearEquationSolver - > performMatrixVectorMultiplication ( minimize , model . getTransitionMatrix ( ) , result ) ;
this - > nondeterministicLinearEquationSolver - > performMatrixVectorMultiplication ( minimize , this - > getModel ( ) . getTransitionMatrix ( ) , result ) ;
return result ;
}
template < typename ValueType >
std : : unique_ptr < CheckResult > SparseMdpPrctlModelChecker < ValueType > : : computeNextProbabilities ( storm : : logic : : NextFormula const & pathFormula , bool qualitative , boost : : optional < storm : : logic : : OptimalityType > const & optimalityType ) {
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model . " ) ;
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic this->getModel() . " ) ;
std : : unique_ptr < CheckResult > subResultPointer = this - > check ( pathFormula . getSubformula ( ) ) ;
ExplicitQualitativeCheckResult const & subResult = subResultPointer - > asExplicitQualitativeCheckResult ( ) ;
return std : : unique_ptr < CheckResult > ( new ExplicitQuantitativeCheckResult < ValueType > ( this - > computeNextProbabilitiesHelper ( optimalityType . get ( ) = = storm : : logic : : OptimalityType : : Minimize , subResult . getTruthValuesVector ( ) ) ) ) ;
}
template < typename ValueType >
std : : vector < ValueType > SparseMdpPrctlModelChecker < ValueType > : : computeUntilProbabilitiesHelper ( bool minimize , storm : : storage : : BitVector const & phiStates , storm : : storage : : BitVector const & psiStates , bool qualitative ) const {
return computeUntilProbabilitiesHelper ( minimize , this - > getModel ( ) . getTransitionMatrix ( ) , this - > getModel ( ) . getBackwardTransitions ( ) , phiStates , psiStates , nondeterministicLinearEquationSolver , qualitative ) ;
}
template < typename ValueType >
std : : vector < ValueType > SparseMdpPrctlModelChecker < ValueType > : : computeUntilProbabilitiesHelper ( bool minimize , storm : : storage : : SparseMatrix < ValueType > const & transitionMatrix , storm : : storage : : SparseMatrix < ValueType > const & backwardTransitions , storm : : storage : : BitVector const & phiStates , storm : : storage : : BitVector const & psiStates , std : : shared_ptr < storm : : solver : : NondeterministicLinearEquationSolver < ValueType > > nondeterministicLinearEquationSolver , bool qualitative ) {
size_t numberOfStates = phiStates . size ( ) ;
@ -156,81 +161,81 @@ namespace storm {
template < typename ValueType >
std : : unique_ptr < CheckResult > SparseMdpPrctlModelChecker < ValueType > : : computeUntilProbabilities ( storm : : logic : : UntilFormula const & pathFormula , bool qualitative , boost : : optional < storm : : logic : : OptimalityType > const & optimalityType ) {
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model . " ) ;
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic this->getModel() . " ) ;
std : : unique_ptr < CheckResult > leftResultPointer = this - > check ( pathFormula . getLeftSubformula ( ) ) ;
std : : unique_ptr < CheckResult > rightResultPointer = this - > check ( pathFormula . getRightSubformula ( ) ) ;
ExplicitQualitativeCheckResult const & leftResult = leftResultPointer - > asExplicitQualitativeCheckResult ( ) ;
ExplicitQualitativeCheckResult const & rightResult = rightResultPointer - > asExplicitQualitativeCheckResult ( ) ;
return std : : unique_ptr < CheckResult > ( new ExplicitQuantitativeCheckResult < ValueType > ( SparseMdpPrctlModelChecker < ValueType > : : computeUntilProbabilitiesHelper ( optimalityType . get ( ) = = storm : : logic : : OptimalityType : : Minimize , model . getTransitionMatrix ( ) , model . getBackwardTransitions ( ) , leftResult . getTruthValuesVector ( ) , rightResult . getTruthValuesVector ( ) , nondeterministicLinearEquationSolver , qualitative ) ) ) ;
return std : : unique_ptr < CheckResult > ( new ExplicitQuantitativeCheckResult < ValueType > ( SparseMdpPrctlModelChecker < ValueType > : : computeUntilProbabilitiesHelper ( optimalityType . get ( ) = = storm : : logic : : OptimalityType : : Minimize , this - > getModel ( ) . getTransitionMatrix ( ) , this - > getModel ( ) . getBackwardTransitions ( ) , leftResult . getTruthValuesVector ( ) , rightResult . getTruthValuesVector ( ) , nondeterministicLinearEquationSolver , qualitative ) ) ) ;
}
template < typename ValueType >
std : : vector < ValueType > SparseMdpPrctlModelChecker < ValueType > : : computeCumulativeRewardsHelper ( bool minimize , uint_fast64_t stepBound ) const {
// Only compute the result if the model has at least one reward model .
STORM_LOG_THROW ( model . hasStateRewards ( ) | | model . hasTransitionRewards ( ) , storm : : exceptions : : InvalidPropertyException , " Missing reward model for formula. Skipping formula. " ) ;
// Only compute the result if the model has at least one reward this->getModel() .
STORM_LOG_THROW ( this - > getModel ( ) . hasStateRewards ( ) | | this - > getModel ( ) . hasTransitionRewards ( ) , storm : : exceptions : : InvalidPropertyException , " Missing reward model for formula. Skipping formula. " ) ;
// Compute the reward vector to add in each step based on the available reward models.
std : : vector < ValueType > totalRewardVector ;
if ( model . hasTransitionRewards ( ) ) {
totalRewardVector = model . getTransitionMatrix ( ) . getPointwiseProductRowSumVector ( model . getTransitionRewardMatrix ( ) ) ;
if ( model . hasStateRewards ( ) ) {
storm : : utility : : vector : : addVectorsInPlace ( totalRewardVector , model . getStateRewardVector ( ) ) ;
if ( this - > getModel ( ) . hasTransitionRewards ( ) ) {
totalRewardVector = this - > getModel ( ) . getTransitionMatrix ( ) . getPointwiseProductRowSumVector ( this - > getModel ( ) . getTransitionRewardMatrix ( ) ) ;
if ( this - > getModel ( ) . hasStateRewards ( ) ) {
storm : : utility : : vector : : addVectorsInPlace ( totalRewardVector , this - > getModel ( ) . getStateRewardVector ( ) ) ;
}
} else {
totalRewardVector = std : : vector < ValueType > ( model . getStateRewardVector ( ) ) ;
totalRewardVector = std : : vector < ValueType > ( this - > getModel ( ) . getStateRewardVector ( ) ) ;
}
// Initialize result to either the state rewards of the model or the null vector.
std : : vector < ValueType > result ;
if ( model . hasStateRewards ( ) ) {
result = std : : vector < ValueType > ( model . getStateRewardVector ( ) ) ;
if ( this - > getModel ( ) . hasStateRewards ( ) ) {
result = std : : vector < ValueType > ( this - > getModel ( ) . getStateRewardVector ( ) ) ;
} else {
result . resize ( model . getNumberOfStates ( ) ) ;
result . resize ( this - > getModel ( ) . getNumberOfStates ( ) ) ;
}
this - > nondeterministicLinearEquationSolver - > performMatrixVectorMultiplication ( minimize , model . getTransitionMatrix ( ) , result , & totalRewardVector , stepBound ) ;
this - > nondeterministicLinearEquationSolver - > performMatrixVectorMultiplication ( minimize , this - > getModel ( ) . getTransitionMatrix ( ) , result , & totalRewardVector , stepBound ) ;
return result ;
}
template < typename ValueType >
std : : unique_ptr < CheckResult > SparseMdpPrctlModelChecker < ValueType > : : computeCumulativeRewards ( storm : : logic : : CumulativeRewardFormula const & rewardPathFormula , bool qualitative , boost : : optional < storm : : logic : : OptimalityType > const & optimalityType ) {
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model . " ) ;
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic this->getModel() . " ) ;
return std : : unique_ptr < CheckResult > ( new ExplicitQuantitativeCheckResult < ValueType > ( this - > computeCumulativeRewardsHelper ( optimalityType . get ( ) = = storm : : logic : : OptimalityType : : Minimize , rewardPathFormula . getStepBound ( ) ) ) ) ;
}
template < typename ValueType >
std : : vector < ValueType > SparseMdpPrctlModelChecker < ValueType > : : computeInstantaneousRewardsHelper ( bool minimize , uint_fast64_t stepCount ) const {
// Only compute the result if the model has a state-based reward model .
STORM_LOG_THROW ( model . hasStateRewards ( ) , storm : : exceptions : : InvalidPropertyException , " Missing reward model for formula. Skipping formula. " ) ;
// Only compute the result if the model has a state-based reward this->getModel() .
STORM_LOG_THROW ( this - > getModel ( ) . hasStateRewards ( ) , storm : : exceptions : : InvalidPropertyException , " Missing reward model for formula. Skipping formula. " ) ;
// Initialize result to state rewards of the model .
std : : vector < ValueType > result ( model . getStateRewardVector ( ) ) ;
// Initialize result to state rewards of the this->getModel() .
std : : vector < ValueType > result ( this - > getModel ( ) . getStateRewardVector ( ) ) ;
STORM_LOG_THROW ( nondeterministicLinearEquationSolver ! = nullptr , storm : : exceptions : : InvalidStateException , " No valid linear equation solver available. " ) ;
this - > nondeterministicLinearEquationSolver - > performMatrixVectorMultiplication ( minimize , model . getTransitionMatrix ( ) , result , nullptr , stepCount ) ;
this - > nondeterministicLinearEquationSolver - > performMatrixVectorMultiplication ( minimize , this - > getModel ( ) . getTransitionMatrix ( ) , result , nullptr , stepCount ) ;
return result ;
}
template < typename ValueType >
std : : unique_ptr < CheckResult > SparseMdpPrctlModelChecker < ValueType > : : computeInstantaneousRewards ( storm : : logic : : InstantaneousRewardFormula const & rewardPathFormula , bool qualitative , boost : : optional < storm : : logic : : OptimalityType > const & optimalityType ) {
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model . " ) ;
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic this->getModel() . " ) ;
return std : : unique_ptr < CheckResult > ( new ExplicitQuantitativeCheckResult < ValueType > ( this - > computeInstantaneousRewardsHelper ( optimalityType . get ( ) = = storm : : logic : : OptimalityType : : Minimize , rewardPathFormula . getStepCount ( ) ) ) ) ;
}
template < typename ValueType >
std : : vector < ValueType > SparseMdpPrctlModelChecker < ValueType > : : computeReachabilityRewardsHelper ( bool minimize , storm : : storage : : BitVector const & targetStates , bool qualitative ) const {
// Only compute the result if the model has at least one reward model .
STORM_LOG_THROW ( model . hasStateRewards ( ) | | model . hasTransitionRewards ( ) , storm : : exceptions : : InvalidPropertyException , " Missing reward model for formula. Skipping formula. " ) ;
// Only compute the result if the model has at least one reward this->getModel() .
STORM_LOG_THROW ( this - > getModel ( ) . hasStateRewards ( ) | | this - > getModel ( ) . hasTransitionRewards ( ) , storm : : exceptions : : InvalidPropertyException , " Missing reward model for formula. Skipping formula. " ) ;
// Determine which states have a reward of infinity by definition.
storm : : storage : : BitVector infinityStates ;
storm : : storage : : BitVector trueStates ( model . getNumberOfStates ( ) , true ) ;
storm : : storage : : BitVector trueStates ( this - > getModel ( ) . getNumberOfStates ( ) , true ) ;
if ( minimize ) {
infinityStates = std : : move ( storm : : utility : : graph : : performProb1A ( model . getTransitionMatrix ( ) , model . getTransitionMatrix ( ) . getRowGroupIndices ( ) , model . getBackwardTransitions ( ) , trueStates , targetStates ) ) ;
infinityStates = std : : move ( storm : : utility : : graph : : performProb1A ( this - > getModel ( ) . getTransitionMatrix ( ) , this - > getModel ( ) . getTransitionMatrix ( ) . getRowGroupIndices ( ) , this - > getModel ( ) . getBackwardTransitions ( ) , trueStates , targetStates ) ) ;
} else {
infinityStates = std : : move ( storm : : utility : : graph : : performProb1E ( model . getTransitionMatrix ( ) , model . getTransitionMatrix ( ) . getRowGroupIndices ( ) , model . getBackwardTransitions ( ) , trueStates , targetStates ) ) ;
infinityStates = std : : move ( storm : : utility : : graph : : performProb1E ( this - > getModel ( ) . getTransitionMatrix ( ) , this - > getModel ( ) . getTransitionMatrix ( ) . getRowGroupIndices ( ) , this - > getModel ( ) . getBackwardTransitions ( ) , trueStates , targetStates ) ) ;
}
infinityStates . complement ( ) ;
storm : : storage : : BitVector maybeStates = ~ targetStates & ~ infinityStates ;
@ -239,10 +244,10 @@ namespace storm {
LOG4CPLUS_INFO ( logger , " Found " < < maybeStates . getNumberOfSetBits ( ) < < " 'maybe' states. " ) ;
// Create resulting vector.
std : : vector < ValueType > result ( model . getNumberOfStates ( ) ) ;
std : : vector < ValueType > result ( this - > getModel ( ) . getNumberOfStates ( ) ) ;
// Check whether we need to compute exact rewards for some states.
if ( model . getInitialStates ( ) . isDisjointFrom ( maybeStates ) ) {
if ( this - > getModel ( ) . getInitialStates ( ) . isDisjointFrom ( maybeStates ) ) {
LOG4CPLUS_INFO ( logger , " The rewards for the initial states were determined in a preprocessing step. "
< < " No exact rewards were computed. " ) ;
// Set the values for all maybe-states to 1 to indicate that their reward values
@ -253,26 +258,26 @@ namespace storm {
// We can eliminate the rows and columns from the original transition probability matrix for states
// whose reward values are already known.
storm : : storage : : SparseMatrix < ValueType > submatrix = model . getTransitionMatrix ( ) . getSubmatrix ( true , maybeStates , maybeStates , false ) ;
storm : : storage : : SparseMatrix < ValueType > submatrix = this - > getModel ( ) . getTransitionMatrix ( ) . getSubmatrix ( true , maybeStates , maybeStates , false ) ;
// Prepare the right-hand side of the equation system. For entry i this corresponds to
// the accumulated probability of going from state i to some 'yes' state.
std : : vector < ValueType > b ( submatrix . getRowCount ( ) ) ;
if ( model . hasTransitionRewards ( ) ) {
if ( this - > getModel ( ) . hasTransitionRewards ( ) ) {
// If a transition-based reward model is available, we initialize the right-hand
// side to the vector resulting from summing the rows of the pointwise product
// of the transition probability matrix and the transition reward matrix.
std : : vector < ValueType > pointwiseProductRowSumVector = model . getTransitionMatrix ( ) . getPointwiseProductRowSumVector ( model . getTransitionRewardMatrix ( ) ) ;
storm : : utility : : vector : : selectVectorValues ( b , maybeStates , model . getTransitionMatrix ( ) . getRowGroupIndices ( ) , pointwiseProductRowSumVector ) ;
std : : vector < ValueType > pointwiseProductRowSumVector = this - > getModel ( ) . getTransitionMatrix ( ) . getPointwiseProductRowSumVector ( this - > getModel ( ) . getTransitionRewardMatrix ( ) ) ;
storm : : utility : : vector : : selectVectorValues ( b , maybeStates , this - > getModel ( ) . getTransitionMatrix ( ) . getRowGroupIndices ( ) , pointwiseProductRowSumVector ) ;
if ( model . hasStateRewards ( ) ) {
if ( this - > getModel ( ) . hasStateRewards ( ) ) {
// If a state-based reward model is also available, we need to add this vector
// as well. As the state reward vector contains entries not just for the states
// that we still consider (i.e. maybeStates), we need to extract these values
// first.
std : : vector < ValueType > subStateRewards ( b . size ( ) ) ;
storm : : utility : : vector : : selectVectorValuesRepeatedly ( subStateRewards , maybeStates , model . getTransitionMatrix ( ) . getRowGroupIndices ( ) , model . getStateRewardVector ( ) ) ;
storm : : utility : : vector : : selectVectorValuesRepeatedly ( subStateRewards , maybeStates , this - > getModel ( ) . getTransitionMatrix ( ) . getRowGroupIndices ( ) , this - > getModel ( ) . getStateRewardVector ( ) ) ;
storm : : utility : : vector : : addVectorsInPlace ( b , subStateRewards ) ;
}
} else {
@ -280,7 +285,7 @@ namespace storm {
// right-hand side. As the state reward vector contains entries not just for the
// states that we still consider (i.e. maybeStates), we need to extract these values
// first.
storm : : utility : : vector : : selectVectorValuesRepeatedly ( b , maybeStates , model . getTransitionMatrix ( ) . getRowGroupIndices ( ) , model . getStateRewardVector ( ) ) ;
storm : : utility : : vector : : selectVectorValuesRepeatedly ( b , maybeStates , this - > getModel ( ) . getTransitionMatrix ( ) . getRowGroupIndices ( ) , this - > getModel ( ) . getStateRewardVector ( ) ) ;
}
// Create vector for results for maybe states.
@ -302,27 +307,17 @@ namespace storm {
template < typename ValueType >
std : : unique_ptr < CheckResult > SparseMdpPrctlModelChecker < ValueType > : : computeReachabilityRewards ( storm : : logic : : ReachabilityRewardFormula const & rewardPathFormula , bool qualitative , boost : : optional < storm : : logic : : OptimalityType > const & optimalityType ) {
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model . " ) ;
STORM_LOG_THROW ( optimalityType , storm : : exceptions : : InvalidArgumentException , " Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic this->getModel() . " ) ;
std : : unique_ptr < CheckResult > subResultPointer = this - > check ( rewardPathFormula . getSubformula ( ) ) ;
ExplicitQualitativeCheckResult const & subResult = subResultPointer - > asExplicitQualitativeCheckResult ( ) ;
return std : : unique_ptr < CheckResult > ( new ExplicitQuantitativeCheckResult < ValueType > ( this - > computeReachabilityRewardsHelper ( optimalityType . get ( ) = = storm : : logic : : OptimalityType : : Minimize , subResult . getTruthValuesVector ( ) , qualitative ) ) ) ;
}
template < typename ValueType >
std : : unique_ptr < CheckResult > SparseMdpPrctlModelChecker < ValueType > : : checkBooleanLiteralFormula ( storm : : logic : : BooleanLiteralFormula const & stateFormula ) {
if ( stateFormula . isTrueFormula ( ) ) {
return std : : unique_ptr < CheckResult > ( new ExplicitQualitativeCheckResult ( storm : : storage : : BitVector ( model . getNumberOfStates ( ) , true ) ) ) ;
} else {
return std : : unique_ptr < CheckResult > ( new ExplicitQualitativeCheckResult ( storm : : storage : : BitVector ( model . getNumberOfStates ( ) ) ) ) ;
}
}
template < typename ValueType >
std : : unique_ptr < CheckResult > SparseMdpPrctlModelChecker < ValueType > : : checkAtomicLabelFormula ( storm : : logic : : AtomicLabelFormula const & stateFormula ) {
STORM_LOG_THROW ( model . hasAtomicProposition ( stateFormula . getLabel ( ) ) , storm : : exceptions : : InvalidPropertyException , " The property refers to unknown label ' " < < stateFormula . getLabel ( ) < < " '. " ) ;
return std : : unique_ptr < CheckResult > ( new ExplicitQualitativeCheckResult ( model . getLabeledStates ( stateFormula . getLabel ( ) ) ) ) ;
storm : : models : : Mdp < ValueType > const & SparseMdpPrctlModelChecker < ValueType > : : getModel ( ) const {
return this - > template getModelAs < storm : : models : : Mdp < ValueType > > ( ) ;
}
template class SparseMdpPrctlModelChecker < double > ;
}
}