@ -93,7 +93,7 @@ namespace storm {
}
template < typename ValueType >
std : : shared_ptr < storm : : models : : ModelBase > buildSymbolicModel ( storm : : prism : : Program const & program , boo st: : optional < std : : shared_ptr < storm : : logic : : Formula > > const & formula ) {
std : : shared_ptr < storm : : models : : ModelBase > buildSymbolicModel ( storm : : prism : : Program const & program , std : : vector < std : : shared_ptr < storm : : logic : : Formula > > const & formulas ) {
std : : shared_ptr < storm : : models : : ModelBase > result ( nullptr ) ;
storm : : settings : : modules : : GeneralSettings settings = storm : : settings : : generalSettings ( ) ;
@ -104,9 +104,7 @@ namespace storm {
/ / Customize and perform model - building .
if ( settings . getEngine ( ) = = storm : : settings : : modules : : GeneralSettings : : Engine : : Sparse ) {
typename storm : : builder : : ExplicitPrismModelBuilder < ValueType > : : Options options ;
if ( formula ) {
options = typename storm : : builder : : ExplicitPrismModelBuilder < ValueType > : : Options ( * formula . get ( ) ) ;
}
options = typename storm : : builder : : ExplicitPrismModelBuilder < ValueType > : : Options ( formulas ) ;
options . addConstantDefinitionsFromString ( program , settings . getConstantDefinitionString ( ) ) ;
/ / Generate command labels if we are going to build a counterexample later .
@ -117,9 +115,7 @@ namespace storm {
result = storm : : builder : : ExplicitPrismModelBuilder < ValueType > : : translateProgram ( program , options ) ;
} else if ( settings . getEngine ( ) = = storm : : settings : : modules : : GeneralSettings : : Engine : : Dd | | settings . getEngine ( ) = = storm : : settings : : modules : : GeneralSettings : : Engine : : Hybrid ) {
typename storm : : builder : : DdPrismModelBuilder < storm : : dd : : DdType : : CUDD > : : Options options ;
if ( formula ) {
options = typename storm : : builder : : DdPrismModelBuilder < storm : : dd : : DdType : : CUDD > : : Options ( * formula . get ( ) ) ;
}
options = typename storm : : builder : : DdPrismModelBuilder < storm : : dd : : DdType : : CUDD > : : Options ( formulas ) ;
options . addConstantDefinitionsFromString ( program , settings . getConstantDefinitionString ( ) ) ;
result = storm : : builder : : DdPrismModelBuilder < storm : : dd : : DdType : : CUDD > : : translateProgram ( program , options ) ;
@ -130,7 +126,7 @@ namespace storm {
}
template < typename ValueType >
std : : shared_ptr < storm : : models : : ModelBase > preprocessModel ( std : : shared_ptr < storm : : models : : ModelBase > model , boo st: : optional < std : : shared_ptr < storm : : logic : : Formula > > const & formula ) {
std : : shared_ptr < storm : : models : : ModelBase > preprocessModel ( std : : shared_ptr < storm : : models : : ModelBase > model , std : : vector < std : : shared_ptr < storm : : logic : : Formula > > const & formulas ) {
if ( storm : : settings : : generalSettings ( ) . isBisimulationSet ( ) ) {
STORM_LOG_THROW ( model - > isSparseModel ( ) , storm : : exceptions : : InvalidSettingsException , " Bisimulation minimization is currently only available for sparse models. " ) ;
std : : shared_ptr < storm : : models : : sparse : : Model < ValueType > > sparseModel = model - > template as < storm : : models : : sparse : : Model < ValueType > > ( ) ;
@ -141,8 +137,8 @@ namespace storm {
std : : cout < < " Performing bisimulation minimization... " ;
typename storm : : storage : : DeterministicModelBisimulationDecomposition < ValueType > : : Options options ;
if ( formula ) {
options = typename storm : : storage : : DeterministicModelBisimulationDecomposition < ValueType > : : Options ( * sparseModel , * formula . get ( ) ) ;
if ( ! formulas . empty ( ) ) {
options = typename storm : : storage : : DeterministicModelBisimulationDecomposition < ValueType > : : Options ( * sparseModel , formulas ) ;
}
if ( storm : : settings : : bisimulationSettings ( ) . isWeakBisimulationSet ( ) ) {
options . weak = true ;
@ -157,7 +153,7 @@ namespace storm {
}
template < typename ValueType >
void generateCounterexample ( storm : : prism : : Program const & program , std : : shared_ptr < storm : : models : : sparse : : Model < ValueType > > model , std : : shared_ptr < storm : : logic : : Formula > formula ) {
void generateCounterexample ( storm : : prism : : Program const & program , std : : shared_ptr < storm : : models : : sparse : : Model < ValueType > > model , std : : shared_ptr < storm : : logic : : Formula > const & formula ) {
if ( storm : : settings : : counterexampleGeneratorSettings ( ) . isMinimalCommandSetGenerationSet ( ) ) {
STORM_LOG_THROW ( model - > getType ( ) = = storm : : models : : ModelType : : Mdp , storm : : exceptions : : InvalidTypeException , " Minimal command set generation is only available for MDPs. " ) ;
STORM_LOG_THROW ( storm : : settings : : generalSettings ( ) . isSymbolicSet ( ) , storm : : exceptions : : InvalidSettingsException , " Minimal command set generation is only available for symbolic models. " ) ;
@ -180,15 +176,16 @@ namespace storm {
# ifdef STORM_HAVE_CARL
template < >
inline void generateCounterexample ( storm : : prism : : Program const & program , std : : shared_ptr < storm : : models : : sparse : : Model < storm : : RationalFunction > > model , std : : shared_ptr < storm : : logic : : Formula > formula ) {
inline void generateCounterexample ( storm : : prism : : Program const & program , std : : shared_ptr < storm : : models : : sparse : : Model < storm : : RationalFunction > > model , std : : shared_ptr < storm : : logic : : Formula > const & formula ) {
STORM_LOG_THROW ( false , storm : : exceptions : : InvalidSettingsException , " Unable to generate counterexample for parametric model. " ) ;
}
# endif
template < typename ValueType >
void verifySparseModel ( boost : : optional < storm : : prism : : Program > const & program , std : : shared_ptr < storm : : models : : sparse : : Model < ValueType > > model , std : : shared_ptr < storm : : logic : : Formula > formula ) {
void verifySparseModel ( boost : : optional < storm : : prism : : Program > const & program , std : : shared_ptr < storm : : models : : sparse : : Model < ValueType > > model , std : : vector < std : : shared_ptr < storm : : logic : : Formula > > const & formulas ) {
storm : : settings : : modules : : GeneralSettings const & settings = storm : : settings : : generalSettings ( ) ;
for ( auto const & formula : formulas ) {
/ / If we were requested to generate a counterexample , we now do so .
if ( settings . isCounterexampleSet ( ) ) {
STORM_LOG_THROW ( program , storm : : exceptions : : InvalidSettingsException , " Unable to generate counterexample for non-symbolic model. " ) ;
@ -199,12 +196,12 @@ namespace storm {
if ( model - > getType ( ) = = storm : : models : : ModelType : : Dtmc ) {
std : : shared_ptr < storm : : models : : sparse : : Dtmc < ValueType > > dtmc = model - > template as < storm : : models : : sparse : : Dtmc < ValueType > > ( ) ;
storm : : modelchecker : : SparseDtmcPrctlModelChecker < storm : : models : : sparse : : Dtmc < ValueType > > modelchecker ( * dtmc ) ;
if ( modelchecker . canHandle ( * formula . get ( ) ) ) {
result = modelchecker . check ( * formula . get ( ) ) ;
if ( modelchecker . canHandle ( * formula ) ) {
result = modelchecker . check ( * formula ) ;
} else {
storm : : modelchecker : : SparseDtmcEliminationModelChecker < storm : : models : : sparse : : Dtmc < ValueType > > modelchecker2 ( * dtmc ) ;
if ( modelchecker2 . canHandle ( * formula . get ( ) ) ) {
result = modelchecker2 . check ( * formula . get ( ) ) ;
if ( modelchecker2 . canHandle ( * formula ) ) {
result = modelchecker2 . check ( * formula ) ;
}
}
} else if ( model - > getType ( ) = = storm : : models : : ModelType : : Mdp ) {
@ -212,20 +209,20 @@ namespace storm {
# ifdef STORM_HAVE_CUDA
if ( settings . isCudaSet ( ) ) {
storm : : modelchecker : : TopologicalValueIterationMdpPrctlModelChecker < ValueType > modelchecker ( * mdp ) ;
result = modelchecker . check ( * formula . get ( ) ) ;
result = modelchecker . check ( * formula ) ;
} else {
storm : : modelchecker : : SparseMdpPrctlModelChecker < storm : : models : : sparse : : Mdp < ValueType > > modelchecker ( * mdp ) ;
result = modelchecker . check ( * formula . get ( ) ) ;
result = modelchecker . check ( * formula ) ;
}
# else
storm : : modelchecker : : SparseMdpPrctlModelChecker < storm : : models : : sparse : : Mdp < ValueType > > modelchecker ( * mdp ) ;
result = modelchecker . check ( * formula . get ( ) ) ;
result = modelchecker . check ( * formula ) ;
# endif
} else if ( model - > getType ( ) = = storm : : models : : ModelType : : Ctmc ) {
std : : shared_ptr < storm : : models : : sparse : : Ctmc < ValueType > > ctmc = model - > template as < storm : : models : : sparse : : Ctmc < ValueType > > ( ) ;
storm : : modelchecker : : SparseCtmcCslModelChecker < storm : : models : : sparse : : Ctmc < ValueType > > modelchecker ( * ctmc ) ;
result = modelchecker . check ( * formula . get ( ) ) ;
result = modelchecker . check ( * formula ) ;
}
if ( result ) {
@ -236,7 +233,7 @@ namespace storm {
} else {
std : : cout < < " skipped, because the modelling formalism is currently unsupported. " < < std : : endl ;
}
}
}
}
@ -258,8 +255,9 @@ namespace storm {
}
template < >
inline void verifySparseModel ( boost : : optional < storm : : prism : : Program > const & program , std : : shared_ptr < storm : : models : : sparse : : Model < storm : : RationalFunction > > model , std : : shared_ptr < storm : : logic : : Formula > formula ) {
inline void verifySparseModel ( boost : : optional < storm : : prism : : Program > const & program , std : : shared_ptr < storm : : models : : sparse : : Model < storm : : RationalFunction > > model , std : : vector < std : : shared_ptr < storm : : logic : : Formula > > const & formulas ) {
for ( auto const & formula : formulas ) {
STORM_LOG_THROW ( model - > getType ( ) = = storm : : models : : ModelType : : Dtmc , storm : : exceptions : : InvalidSettingsException , " Currently parametric verification is only available for DTMCs. " ) ;
std : : shared_ptr < storm : : models : : sparse : : Dtmc < storm : : RationalFunction > > dtmc = model - > template as < storm : : models : : sparse : : Dtmc < storm : : RationalFunction > > ( ) ;
@ -267,8 +265,8 @@ namespace storm {
std : : unique_ptr < storm : : modelchecker : : CheckResult > result ;
storm : : modelchecker : : SparseDtmcEliminationModelChecker < storm : : models : : sparse : : Dtmc < storm : : RationalFunction > > modelchecker ( * dtmc ) ;
if ( modelchecker . canHandle ( * formula . get ( ) ) ) {
result = modelchecker . check ( * formula . get ( ) ) ;
if ( modelchecker . canHandle ( * formula ) ) {
result = modelchecker . check ( * formula ) ;
} else {
STORM_LOG_THROW ( false , storm : : exceptions : : InvalidSettingsException , " The parametric engine currently does not support this property. " ) ;
}
@ -287,30 +285,31 @@ namespace storm {
exportParametricResultToFile ( result - > asExplicitQuantitativeCheckResult < storm : : RationalFunction > ( ) [ * dtmc - > getInitialStates ( ) . begin ( ) ] , storm : : models : : sparse : : Dtmc < storm : : RationalFunction > : : ConstraintCollector ( * dtmc ) , parametricSettings . exportResultPath ( ) ) ;
}
}
}
# endif
template < storm : : dd : : DdType DdType >
void verifySymbolicModel ( boost : : optional < storm : : prism : : Program > const & program , std : : shared_ptr < storm : : models : : symbolic : : Model < DdType > > model , std : : shared_ptr < storm : : logic : : Formula > formula ) {
void verifySymbolicModel ( boost : : optional < storm : : prism : : Program > const & program , std : : shared_ptr < storm : : models : : symbolic : : Model < DdType > > model , std : : vector < std : : shared_ptr < storm : : logic : : Formula > > const & formulas ) {
for ( auto const & formula : formulas ) {
std : : cout < < std : : endl < < " Model checking property: " < < * formula < < " ... " ;
std : : unique_ptr < storm : : modelchecker : : CheckResult > result ;
if ( model - > getType ( ) = = storm : : models : : ModelType : : Dtmc ) {
std : : shared_ptr < storm : : models : : symbolic : : Dtmc < DdType > > dtmc = model - > template as < storm : : models : : symbolic : : Dtmc < DdType > > ( ) ;
storm : : modelchecker : : HybridDtmcPrctlModelChecker < DdType , double > modelchecker ( * dtmc ) ;
if ( modelchecker . canHandle ( * formula . get ( ) ) ) {
result = modelchecker . check ( * formula . get ( ) ) ;
if ( modelchecker . canHandle ( * formula ) ) {
result = modelchecker . check ( * formula ) ;
}
} else if ( model - > getType ( ) = = storm : : models : : ModelType : : Ctmc ) {
std : : shared_ptr < storm : : models : : symbolic : : Ctmc < DdType > > ctmc = model - > template as < storm : : models : : symbolic : : Ctmc < DdType > > ( ) ;
storm : : modelchecker : : HybridCtmcCslModelChecker < DdType , double > modelchecker ( * ctmc ) ;
if ( modelchecker . canHandle ( * formula . get ( ) ) ) {
result = modelchecker . check ( * formula . get ( ) ) ;
if ( modelchecker . canHandle ( * formula ) ) {
result = modelchecker . check ( * formula ) ;
}
} else if ( model - > getType ( ) = = storm : : models : : ModelType : : Mdp ) {
std : : shared_ptr < storm : : models : : symbolic : : Mdp < DdType > > mdp = model - > template as < storm : : models : : symbolic : : Mdp < DdType > > ( ) ;
storm : : modelchecker : : HybridMdpPrctlModelChecker < DdType , double > modelchecker ( * mdp ) ;
if ( modelchecker . canHandle ( * formula . get ( ) ) ) {
result = modelchecker . check ( * formula . get ( ) ) ;
if ( modelchecker . canHandle ( * formula ) ) {
result = modelchecker . check ( * formula ) ;
}
} else {
STORM_LOG_THROW ( false , storm : : exceptions : : NotImplementedException , " This functionality is not yet implemented. " ) ;
@ -325,28 +324,29 @@ namespace storm {
std : : cout < < " skipped, because the modelling formalism is currently unsupported. " < < std : : endl ;
}
}
}
template < typename ValueType >
void buildAndCheckSymbolicModel ( boost : : optional < storm : : prism : : Program > const & program , boo st: : optional < std : : shared_ptr < storm : : logic : : Formula > > formula ) {
void buildAndCheckSymbolicModel ( boost : : optional < storm : : prism : : Program > const & program , std : : vector < std : : shared_ptr < storm : : logic : : Formula > > const & formulas ) {
/ / Now we are ready to actually build the model .
STORM_LOG_THROW ( program , storm : : exceptions : : InvalidStateException , " Program has not been successfully parsed. " ) ;
std : : shared_ptr < storm : : models : : ModelBase > model = buildSymbolicModel < ValueType > ( program . get ( ) , formula ) ;
std : : shared_ptr < storm : : models : : ModelBase > model = buildSymbolicModel < ValueType > ( program . get ( ) , formulas ) ;
STORM_LOG_THROW ( model ! = nullptr , storm : : exceptions : : InvalidStateException , " Model could not be constructed for an unknown reason. " ) ;
/ / Preprocess the model if needed .
model = preprocessModel < ValueType > ( model , formula ) ;
model = preprocessModel < ValueType > ( model , formulas ) ;
/ / Print some information about the model .
model - > printModelInformationToStream ( std : : cout ) ;
/ / Verify the model , if a formula was given .
if ( formula ) {
if ( ! formulas . empty ( ) ) {
if ( model - > isSparseModel ( ) ) {
verifySparseModel < ValueType > ( program , model - > as < storm : : models : : sparse : : Model < ValueType > > ( ) , formula . get ( ) ) ;
verifySparseModel < ValueType > ( program , model - > as < storm : : models : : sparse : : Model < ValueType > > ( ) , formulas ) ;
} else if ( model - > isSymbolicModel ( ) ) {
if ( storm : : settings : : generalSettings ( ) . getEngine ( ) = = storm : : settings : : modules : : GeneralSettings : : Engine : : Hybrid ) {
verifySymbolicModel ( program , model - > as < storm : : models : : symbolic : : Model < storm : : dd : : DdType : : CUDD > > ( ) , formula . get ( ) ) ;
verifySymbolicModel ( program , model - > as < storm : : models : : symbolic : : Model < storm : : dd : : DdType : : CUDD > > ( ) , formulas ) ;
} else {
/ / Not handled yet .
STORM_LOG_THROW ( false , storm : : exceptions : : NotImplementedException , " This functionality is not yet implemented. " ) ;
@ -358,22 +358,22 @@ namespace storm {
}
template < typename ValueType >
void buildAndCheckExplicitModel ( boo st: : optional < std : : shared_ptr < storm : : logic : : Formula > > formula ) {
void buildAndCheckExplicitModel ( std : : vector < std : : shared_ptr < storm : : logic : : Formula > > const & formulas ) {
storm : : settings : : modules : : GeneralSettings const & settings = storm : : settings : : generalSettings ( ) ;
STORM_LOG_THROW ( settings . isExplicitSet ( ) , storm : : exceptions : : InvalidStateException , " Unable to build explicit model without model files. " ) ;
std : : shared_ptr < storm : : models : : ModelBase > model = buildExplicitModel < ValueType > ( settings . getTransitionFilename ( ) , settings . getLabelingFilename ( ) , settings . isStateRewardsSet ( ) ? settings . getStateRewardsFilename ( ) : boost : : optional < std : : string > ( ) , settings . isTransitionRewardsSet ( ) ? settings . getTransitionRewardsFilename ( ) : boost : : optional < std : : string > ( ) ) ;
/ / Preprocess the model if needed .
model = preprocessModel < ValueType > ( model , formula ) ;
model = preprocessModel < ValueType > ( model , formulas ) ;
/ / Print some information about the model .
model - > printModelInformationToStream ( std : : cout ) ;
/ / Verify the model , if a formula was given .
if ( formula ) {
if ( ! formulas . empty ( ) ) {
STORM_LOG_THROW ( model - > isSparseModel ( ) , storm : : exceptions : : InvalidStateException , " Expected sparse model. " ) ;
verifySparseModel < ValueType > ( boost : : optional < storm : : prism : : Program > ( ) , model - > as < storm : : models : : sparse : : Model < ValueType > > ( ) , formula . get ( ) ) ;
verifySparseModel < ValueType > ( boost : : optional < storm : : prism : : Program > ( ) , model - > as < storm : : models : : sparse : : Model < ValueType > > ( ) , formulas ) ;
}
}