@ -3,35 +3,10 @@
# include "storm/utility/initialize.h"
# include "storm/utility/initialize.h"
# include "storm/settings/modules/GeneralSettings.h"
# include "storm/settings/modules/GeneralSettings.h"
# include "storm/settings/modules/CoreSettings.h"
# include "storm/settings/modules/IOSettings.h"
# include "storm/settings/modules/DebugSettings.h"
# include "storm/settings/modules/DebugSettings.h"
# include "storm/settings/modules/CuddSettings.h"
# include "storm/settings/modules/SylvanSettings.h"
# include "storm/settings/modules/EigenEquationSolverSettings.h"
# include "storm/settings/modules/GmmxxEquationSolverSettings.h"
# include "storm/settings/modules/NativeEquationSolverSettings.h"
# include "storm/settings/modules/EliminationSettings.h"
# include "storm/settings/modules/MinMaxEquationSolverSettings.h"
# include "storm/settings/modules/GameSolverSettings.h"
# include "storm/settings/modules/BisimulationSettings.h"
# include "storm/settings/modules/GlpkSettings.h"
# include "storm/settings/modules/GurobiSettings.h"
# include "storm/settings/modules/Smt2SmtSolverSettings.h"
# include "storm/settings/modules/ExplorationSettings.h"
# include "storm/settings/modules/ResourceSettings.h"
# include "storm/settings/modules/AbstractionSettings.h"
# include "storm/settings/modules/BuildSettings.h"
# include "storm/settings/modules/JitBuilderSettings.h"
# include "storm/settings/modules/TopologicalEquationSolverSettings.h"
# include "storm/settings/modules/ModelCheckerSettings.h"
# include "storm/settings/modules/MultiplierSettings.h"
# include "storm/settings/modules/TransformationSettings.h"
# include "storm/settings/modules/MultiObjectiveSettings.h"
# include "storm/settings/modules/HintSettings.h"
# include "storm-pomdp-cli/settings/modules/POMDPSettings.h"
# include "storm-pomdp-cli/settings/modules/POMDPSettings.h"
# include "storm-pomdp-cli/settings/PomdpSettings.h"
# include "storm/analysis/GraphConditions.h"
# include "storm/analysis/GraphConditions.h"
# include "storm-cli-utilities/cli.h"
# include "storm-cli-utilities/cli.h"
@ -51,39 +26,14 @@
# include "storm-pomdp/analysis/QualitativeStrategySearchNaive.h"
# include "storm-pomdp/analysis/QualitativeStrategySearchNaive.h"
# include "storm/api/storm.h"
# include "storm/api/storm.h"
# include "storm/exceptions/UnexpectedException.h"
# include <typeinfo>
# include <typeinfo>
/*!
* Initialize the settings manager .
*/
void initializeSettings ( ) {
storm : : settings : : mutableManager ( ) . setName ( " Storm-POMDP " , " storm-pomdp " ) ;
storm : : settings : : addModule < storm : : settings : : modules : : GeneralSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : IOSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : CoreSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : DebugSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : BuildSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : POMDPSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : TransformationSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : GmmxxEquationSolverSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : EigenEquationSolverSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : NativeEquationSolverSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : EliminationSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : MinMaxEquationSolverSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : GameSolverSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : BisimulationSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : GlpkSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : ExplorationSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : ResourceSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : JitBuilderSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : TopologicalEquationSolverSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : ModelCheckerSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : MultiplierSettings > ( ) ;
storm : : settings : : addModule < storm : : settings : : modules : : HintSettings > ( ) ;
}
namespace storm {
namespace pomdp {
namespace cli {
template < typename ValueType >
template < typename ValueType >
bool extractTargetAndSinkObservationSets ( std : : shared_ptr < storm : : models : : sparse : : Pomdp < ValueType > > const & pomdp , storm : : logic : : Formula const & subformula , std : : set < uint32_t > & targetObservationSet , storm : : storage : : BitVector & targetStates , storm : : storage : : BitVector & badStates ) {
bool extractTargetAndSinkObservationSets ( std : : shared_ptr < storm : : models : : sparse : : Pomdp < ValueType > > const & pomdp , storm : : logic : : Formula const & subformula , std : : set < uint32_t > & targetObservationSet , storm : : storage : : BitVector & targetStates , storm : : storage : : BitVector & badStates ) {
@ -176,52 +126,15 @@ bool extractTargetAndSinkObservationSets(std::shared_ptr<storm::models::sparse::
return validFormula ;
return validFormula ;
}
}
/*!
* Entry point for the pomdp backend .
*
* @ param argc The argc argument of main ( ) .
* @ param argv The argv argument of main ( ) .
* @ return Return code , 0 if successfull , not 0 otherwise .
*/
int main ( const int argc , const char * * argv ) {
//try {
storm : : utility : : setUp ( ) ;
storm : : cli : : printHeader ( " Storm-pomdp " , argc , argv ) ;
initializeSettings ( ) ;
bool optionsCorrect = storm : : cli : : parseOptions ( argc , argv ) ;
if ( ! optionsCorrect ) {
return - 1 ;
}
storm : : cli : : setUrgentOptions ( ) ;
typedef double VT ;
template < typename ValueType , storm : : dd : : DdType DdType >
void processOptionsWithValueTypeAndDdLib ( storm : : cli : : SymbolicInput const & symbolicInput , storm : : cli : : ModelProcessingInformation const & mpi ) {
auto const & pomdpSettings = storm : : settings : : getModule < storm : : settings : : modules : : POMDPSettings > ( ) ;
auto const & pomdpSettings = storm : : settings : : getModule < storm : : settings : : modules : : POMDPSettings > ( ) ;
auto const & general = storm : : settings : : getModule < storm : : settings : : modules : : GeneralSettings > ( ) ;
auto const & debug = storm : : settings : : getModule < storm : : settings : : modules : : DebugSettings > ( ) ;
if ( general . isVerboseSet ( ) ) {
storm : : utility : : setLogLevel ( l3pp : : LogLevel : : INFO ) ;
}
if ( debug . isDebugSet ( ) ) {
storm : : utility : : setLogLevel ( l3pp : : LogLevel : : DEBUG ) ;
}
if ( debug . isTraceSet ( ) ) {
storm : : utility : : setLogLevel ( l3pp : : LogLevel : : TRACE ) ;
}
auto symbolicInput = storm : : cli : : parseSymbolicInput ( ) ;
storm : : cli : : ModelProcessingInformation mpi ;
std : : tie ( symbolicInput , mpi ) = storm : : cli : : preprocessSymbolicInput ( symbolicInput ) ;
// We should not export here if we are going to do some processing first.
auto model = storm : : cli : : buildPreprocessExportModelWithValueTypeAndDdlib < storm : : dd : : DdType : : Sylvan , VT > ( symbolicInput , mpi ) ;
STORM_LOG_THROW ( model & & model - > getType ( ) = = storm : : models : : ModelType : : Pomdp , storm : : exceptions : : WrongFormatException , " Expected a POMDP. " ) ;
auto model = storm : : cli : : buildPreprocessExportModelWithValueTypeAndDdlib < DdType , ValueType > ( symbolicInput , mpi ) ;
STORM_LOG_THROW ( model & & model - > getType ( ) = = storm : : models : : ModelType : : Pomdp & & model - > isSparseModel ( ) , storm : : exceptions : : WrongFormatException , " Expected a POMDP in sparse representation. " ) ;
std : : shared_ptr < storm : : models : : sparse : : Pomdp < VT > > pomdp = model - > template as < storm : : models : : sparse : : Pomdp < VT > > ( ) ;
storm : : transformer : : MakePOMDPCanonic < VT > makeCanonic ( * pomdp ) ;
std : : shared_ptr < storm : : models : : sparse : : Pomdp < ValueType > > pomdp = model - > template as < storm : : models : : sparse : : Pomdp < ValueType > > ( ) ;
storm : : transformer : : MakePOMDPCanonic < ValueType > makeCanonic ( * pomdp ) ;
pomdp = makeCanonic . transform ( ) ;
pomdp = makeCanonic . transform ( ) ;
std : : shared_ptr < storm : : logic : : Formula const > formula ;
std : : shared_ptr < storm : : logic : : Formula const > formula ;
@ -233,7 +146,7 @@ int main(const int argc, const char** argv) {
if ( pomdpSettings . isAnalyzeUniqueObservationsSet ( ) ) {
if ( pomdpSettings . isAnalyzeUniqueObservationsSet ( ) ) {
STORM_PRINT_AND_LOG ( " Analyzing states with unique observation ... " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( " Analyzing states with unique observation ... " < < std : : endl ) ;
storm : : analysis : : UniqueObservationStates < VT > uniqueAnalysis ( * pomdp ) ;
storm : : analysis : : UniqueObservationStates < Value Type > uniqueAnalysis ( * pomdp ) ;
std : : cout < < uniqueAnalysis . analyse ( ) < < std : : endl ;
std : : cout < < uniqueAnalysis . analyse ( ) < < std : : endl ;
}
}
@ -256,12 +169,12 @@ int main(const int argc, const char** argv) {
if ( pomdpSettings . isSelfloopReductionSet ( ) & & ! storm : : solver : : minimize ( formula - > asProbabilityOperatorFormula ( ) . getOptimalityType ( ) ) ) {
if ( pomdpSettings . isSelfloopReductionSet ( ) & & ! storm : : solver : : minimize ( formula - > asProbabilityOperatorFormula ( ) . getOptimalityType ( ) ) ) {
STORM_PRINT_AND_LOG ( " Eliminating self-loop choices ... " ) ;
STORM_PRINT_AND_LOG ( " Eliminating self-loop choices ... " ) ;
uint64_t oldChoiceCount = pomdp - > getNumberOfChoices ( ) ;
uint64_t oldChoiceCount = pomdp - > getNumberOfChoices ( ) ;
storm : : transformer : : GlobalPOMDPSelfLoopEliminator < VT > selfLoopEliminator ( * pomdp ) ;
storm : : transformer : : GlobalPOMDPSelfLoopEliminator < Value Type > selfLoopEliminator ( * pomdp ) ;
pomdp = selfLoopEliminator . transform ( ) ;
pomdp = selfLoopEliminator . transform ( ) ;
STORM_PRINT_AND_LOG ( oldChoiceCount - pomdp - > getNumberOfChoices ( ) < < " choices eliminated through self-loop elimination. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( oldChoiceCount - pomdp - > getNumberOfChoices ( ) < < " choices eliminated through self-loop elimination. " < < std : : endl ) ;
}
}
if ( pomdpSettings . isQualitativeReductionSet ( ) ) {
if ( pomdpSettings . isQualitativeReductionSet ( ) ) {
storm : : analysis : : QualitativeAnalysis < VT > qualitativeAnalysis ( * pomdp ) ;
storm : : analysis : : QualitativeAnalysis < Value Type > qualitativeAnalysis ( * pomdp ) ;
STORM_PRINT_AND_LOG ( " Computing states with probability 0 ... " ) ;
STORM_PRINT_AND_LOG ( " Computing states with probability 0 ... " ) ;
prob0States = qualitativeAnalysis . analyseProb0 ( formula - > asProbabilityOperatorFormula ( ) ) ;
prob0States = qualitativeAnalysis . analyseProb0 ( formula - > asProbabilityOperatorFormula ( ) ) ;
std : : cout < < * prob0States < < std : : endl ;
std : : cout < < * prob0States < < std : : endl ;
@ -271,15 +184,15 @@ int main(const int argc, const char** argv) {
std : : cout < < * prob1States < < std : : endl ;
std : : cout < < * prob1States < < std : : endl ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
//std::cout << "actual reduction not yet implemented..." << std::endl;
//std::cout << "actual reduction not yet implemented..." << std::endl;
storm : : pomdp : : transformer : : KnownProbabilityTransformer < VT > kpt = storm : : pomdp : : transformer : : KnownProbabilityTransformer < doubl e> ( ) ;
storm : : pomdp : : transformer : : KnownProbabilityTransformer < Value Type > kpt = storm : : pomdp : : transformer : : KnownProbabilityTransformer < ValueTyp e> ( ) ;
pomdp = kpt . transform ( * pomdp , * prob0States , * prob1States ) ;
pomdp = kpt . transform ( * pomdp , * prob0States , * prob1States ) ;
}
}
if ( pomdpSettings . isGridApproximationSet ( ) ) {
if ( pomdpSettings . isGridApproximationSet ( ) ) {
storm : : pomdp : : modelchecker : : ApproximatePOMDPModelchecker < VT > checker = storm : : pomdp : : modelchecker : : ApproximatePOMDPModelchecker < doubl e> ( ) ;
auto overRes = storm : : utility : : one < VT > ( ) ;
auto underRes = storm : : utility : : zero < VT > ( ) ;
std : : unique_ptr < storm : : pomdp : : modelchecker : : POMDPCheckResult < VT > > result ;
storm : : pomdp : : modelchecker : : ApproximatePOMDPModelchecker < Value Type > checker = storm : : pomdp : : modelchecker : : ApproximatePOMDPModelchecker < ValueTyp e> ( ) ;
auto overRes = storm : : utility : : one < Value Type > ( ) ;
auto underRes = storm : : utility : : zero < Value Type > ( ) ;
std : : unique_ptr < storm : : pomdp : : modelchecker : : POMDPCheckResult < Value Type > > result ;
result = checker . refineReachabilityProbability ( * pomdp , targetObservationSet , probFormula . getOptimalityType ( ) = = storm : : OptimizationDirection : : Minimize ,
result = checker . refineReachabilityProbability ( * pomdp , targetObservationSet , probFormula . getOptimalityType ( ) = = storm : : OptimizationDirection : : Minimize ,
pomdpSettings . getGridResolution ( ) , pomdpSettings . getExplorationThreshold ( ) ) ;
pomdpSettings . getGridResolution ( ) , pomdpSettings . getExplorationThreshold ( ) ) ;
@ -301,10 +214,10 @@ int main(const int argc, const char** argv) {
storm : : expressions : : ExpressionManager expressionManager ;
storm : : expressions : : ExpressionManager expressionManager ;
std : : shared_ptr < storm : : utility : : solver : : SmtSolverFactory > smtSolverFactory = std : : make_shared < storm : : utility : : solver : : Z3SmtSolverFactory > ( ) ;
std : : shared_ptr < storm : : utility : : solver : : SmtSolverFactory > smtSolverFactory = std : : make_shared < storm : : utility : : solver : : Z3SmtSolverFactory > ( ) ;
if ( pomdpSettings . getMemlessSearchMethod ( ) = = " ccd16memless " ) {
if ( pomdpSettings . getMemlessSearchMethod ( ) = = " ccd16memless " ) {
storm : : pomdp : : QualitativeStrategySearchNaive < VT > memlessSearch ( * pomdp , targetObservationSet , targetStates , badStates , smtSolverFactory ) ;
storm : : pomdp : : QualitativeStrategySearchNaive < Value Type > memlessSearch ( * pomdp , targetObservationSet , targetStates , badStates , smtSolverFactory ) ;
memlessSearch . findNewStrategyForSomeState ( 5 ) ;
memlessSearch . findNewStrategyForSomeState ( 5 ) ;
} else if ( pomdpSettings . getMemlessSearchMethod ( ) = = " iterative " ) {
} else if ( pomdpSettings . getMemlessSearchMethod ( ) = = " iterative " ) {
storm : : pomdp : : MemlessStrategySearchQualitative < VT > memlessSearch ( * pomdp , targetObservationSet , targetStates , badStates , smtSolverFactory ) ;
storm : : pomdp : : MemlessStrategySearchQualitative < Value Type > memlessSearch ( * pomdp , targetObservationSet , targetStates , badStates , smtSolverFactory ) ;
memlessSearch . findNewStrategyForSomeState ( 5 ) ;
memlessSearch . findNewStrategyForSomeState ( 5 ) ;
} else {
} else {
STORM_LOG_ERROR ( " This method is not implemented. " ) ;
STORM_LOG_ERROR ( " This method is not implemented. " ) ;
@ -316,7 +229,7 @@ int main(const int argc, const char** argv) {
if ( pomdpSettings . isSelfloopReductionSet ( ) & & storm : : solver : : minimize ( formula - > asRewardOperatorFormula ( ) . getOptimalityType ( ) ) ) {
if ( pomdpSettings . isSelfloopReductionSet ( ) & & storm : : solver : : minimize ( formula - > asRewardOperatorFormula ( ) . getOptimalityType ( ) ) ) {
STORM_PRINT_AND_LOG ( " Eliminating self-loop choices ... " ) ;
STORM_PRINT_AND_LOG ( " Eliminating self-loop choices ... " ) ;
uint64_t oldChoiceCount = pomdp - > getNumberOfChoices ( ) ;
uint64_t oldChoiceCount = pomdp - > getNumberOfChoices ( ) ;
storm : : transformer : : GlobalPOMDPSelfLoopEliminator < VT > selfLoopEliminator ( * pomdp ) ;
storm : : transformer : : GlobalPOMDPSelfLoopEliminator < Value Type > selfLoopEliminator ( * pomdp ) ;
pomdp = selfLoopEliminator . transform ( ) ;
pomdp = selfLoopEliminator . transform ( ) ;
STORM_PRINT_AND_LOG ( oldChoiceCount - pomdp - > getNumberOfChoices ( ) < < " choices eliminated through self-loop elimination. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( oldChoiceCount - pomdp - > getNumberOfChoices ( ) < < " choices eliminated through self-loop elimination. " < < std : : endl ) ;
}
}
@ -362,10 +275,10 @@ int main(const int argc, const char** argv) {
" The formula is not supported by the grid approximation " ) ;
" The formula is not supported by the grid approximation " ) ;
STORM_LOG_ASSERT ( ! targetObservationSet . empty ( ) , " The set of target observations is empty! " ) ;
STORM_LOG_ASSERT ( ! targetObservationSet . empty ( ) , " The set of target observations is empty! " ) ;
storm : : pomdp : : modelchecker : : ApproximatePOMDPModelchecker < VT > checker = storm : : pomdp : : modelchecker : : ApproximatePOMDPModelchecker < doubl e> ( ) ;
auto overRes = storm : : utility : : one < VT > ( ) ;
auto underRes = storm : : utility : : zero < VT > ( ) ;
std : : unique_ptr < storm : : pomdp : : modelchecker : : POMDPCheckResult < VT > > result ;
storm : : pomdp : : modelchecker : : ApproximatePOMDPModelchecker < Value Type > checker = storm : : pomdp : : modelchecker : : ApproximatePOMDPModelchecker < ValueTyp e> ( ) ;
auto overRes = storm : : utility : : one < Value Type > ( ) ;
auto underRes = storm : : utility : : zero < Value Type > ( ) ;
std : : unique_ptr < storm : : pomdp : : modelchecker : : POMDPCheckResult < Value Type > > result ;
result = checker . computeReachabilityReward ( * pomdp , targetObservationSet ,
result = checker . computeReachabilityReward ( * pomdp , targetObservationSet ,
rewFormula . getOptimalityType ( ) = =
rewFormula . getOptimalityType ( ) = =
storm : : OptimizationDirection : : Minimize ,
storm : : OptimizationDirection : : Minimize ,
@ -379,7 +292,7 @@ int main(const int argc, const char** argv) {
STORM_PRINT_AND_LOG ( " Computing the unfolding for memory bound " < < pomdpSettings . getMemoryBound ( ) < < " and memory pattern ' " < < storm : : storage : : toString ( pomdpSettings . getMemoryPattern ( ) ) < < " ' ... " ) ;
STORM_PRINT_AND_LOG ( " Computing the unfolding for memory bound " < < pomdpSettings . getMemoryBound ( ) < < " and memory pattern ' " < < storm : : storage : : toString ( pomdpSettings . getMemoryPattern ( ) ) < < " ' ... " ) ;
storm : : storage : : PomdpMemory memory = storm : : storage : : PomdpMemoryBuilder ( ) . build ( pomdpSettings . getMemoryPattern ( ) , pomdpSettings . getMemoryBound ( ) ) ;
storm : : storage : : PomdpMemory memory = storm : : storage : : PomdpMemoryBuilder ( ) . build ( pomdpSettings . getMemoryPattern ( ) , pomdpSettings . getMemoryBound ( ) ) ;
std : : cout < < memory . toString ( ) < < std : : endl ;
std : : cout < < memory . toString ( ) < < std : : endl ;
storm : : transformer : : PomdpMemoryUnfolder < VT > memoryUnfolder ( * pomdp , memory ) ;
storm : : transformer : : PomdpMemoryUnfolder < Value Type > memoryUnfolder ( * pomdp , memory ) ;
pomdp = memoryUnfolder . transform ( ) ;
pomdp = memoryUnfolder . transform ( ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
pomdp - > printModelInformationToStream ( std : : cout ) ;
pomdp - > printModelInformationToStream ( std : : cout ) ;
@ -393,7 +306,7 @@ int main(const int argc, const char** argv) {
STORM_PRINT_AND_LOG ( " Eliminating mec choices ... " ) ;
STORM_PRINT_AND_LOG ( " Eliminating mec choices ... " ) ;
// Note: Elimination of mec choices only preserves memoryless schedulers.
// Note: Elimination of mec choices only preserves memoryless schedulers.
uint64_t oldChoiceCount = pomdp - > getNumberOfChoices ( ) ;
uint64_t oldChoiceCount = pomdp - > getNumberOfChoices ( ) ;
storm : : transformer : : GlobalPomdpMecChoiceEliminator < VT > mecChoiceEliminator ( * pomdp ) ;
storm : : transformer : : GlobalPomdpMecChoiceEliminator < Value Type > mecChoiceEliminator ( * pomdp ) ;
pomdp = mecChoiceEliminator . transform ( * formula ) ;
pomdp = mecChoiceEliminator . transform ( * formula ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( oldChoiceCount - pomdp - > getNumberOfChoices ( ) < < " choices eliminated through MEC choice elimination. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( oldChoiceCount - pomdp - > getNumberOfChoices ( ) < < " choices eliminated through MEC choice elimination. " < < std : : endl ) ;
@ -403,10 +316,10 @@ int main(const int argc, const char** argv) {
if ( pomdpSettings . isTransformBinarySet ( ) | | pomdpSettings . isTransformSimpleSet ( ) ) {
if ( pomdpSettings . isTransformBinarySet ( ) | | pomdpSettings . isTransformSimpleSet ( ) ) {
if ( pomdpSettings . isTransformSimpleSet ( ) ) {
if ( pomdpSettings . isTransformSimpleSet ( ) ) {
STORM_PRINT_AND_LOG ( " Transforming the POMDP to a simple POMDP. " ) ;
STORM_PRINT_AND_LOG ( " Transforming the POMDP to a simple POMDP. " ) ;
pomdp = storm : : transformer : : BinaryPomdpTransformer < VT > ( ) . transform ( * pomdp , true ) ;
pomdp = storm : : transformer : : BinaryPomdpTransformer < Value Type > ( ) . transform ( * pomdp , true ) ;
} else {
} else {
STORM_PRINT_AND_LOG ( " Transforming the POMDP to a binary POMDP. " ) ;
STORM_PRINT_AND_LOG ( " Transforming the POMDP to a binary POMDP. " ) ;
pomdp = storm : : transformer : : BinaryPomdpTransformer < VT > ( ) . transform ( * pomdp , false ) ;
pomdp = storm : : transformer : : BinaryPomdpTransformer < Value Type > ( ) . transform ( * pomdp , false ) ;
}
}
pomdp - > printModelInformationToStream ( std : : cout ) ;
pomdp - > printModelInformationToStream ( std : : cout ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
@ -415,14 +328,14 @@ int main(const int argc, const char** argv) {
if ( pomdpSettings . isExportToParametricSet ( ) ) {
if ( pomdpSettings . isExportToParametricSet ( ) ) {
STORM_PRINT_AND_LOG ( " Transforming memoryless POMDP to pMC... " ) ;
STORM_PRINT_AND_LOG ( " Transforming memoryless POMDP to pMC... " ) ;
storm : : transformer : : ApplyFiniteSchedulerToPomdp < VT > toPMCTransformer ( * pomdp ) ;
storm : : transformer : : ApplyFiniteSchedulerToPomdp < Value Type > toPMCTransformer ( * pomdp ) ;
std : : string transformMode = pomdpSettings . getFscApplicationTypeString ( ) ;
std : : string transformMode = pomdpSettings . getFscApplicationTypeString ( ) ;
auto pmc = toPMCTransformer . transform ( storm : : transformer : : parsePomdpFscApplicationMode ( transformMode ) ) ;
auto pmc = toPMCTransformer . transform ( storm : : transformer : : parsePomdpFscApplicationMode ( transformMode ) ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
pmc - > printModelInformationToStream ( std : : cout ) ;
pmc - > printModelInformationToStream ( std : : cout ) ;
STORM_PRINT_AND_LOG ( " Simplifying pMC... " ) ;
STORM_PRINT_AND_LOG ( " Simplifying pMC... " ) ;
//if (generalSettings.isBisimulationSet()) {
//if (generalSettings.isBisimulationSet()) {
pmc = storm : : api : : performBisimulationMinimization < storm : : RationalFunction > ( pmc - > as < storm : : models : : sparse : : Dtmc < storm : : RationalFunction > > ( ) , { formula } , storm : : storage : : BisimulationType : : Strong ) - > as < storm : : models : : sparse : : Dtmc < storm : : RationalFunction > > ( ) ;
pmc = storm : : api : : performBisimulationMinimization < storm : : RationalFunction > ( pmc - > template as < storm : : models : : sparse : : Dtmc < storm : : RationalFunction > > ( ) , { formula } , storm : : storage : : BisimulationType : : Strong ) - > template as < storm : : models : : sparse : : Dtmc < storm : : RationalFunction > > ( ) ;
//}
//}
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
STORM_PRINT_AND_LOG ( " done. " < < std : : endl ) ;
@ -443,6 +356,64 @@ int main(const int argc, const char** argv) {
STORM_LOG_WARN ( " Nothing to be done. Did you forget to specify a formula? " ) ;
STORM_LOG_WARN ( " Nothing to be done. Did you forget to specify a formula? " ) ;
}
}
}
template < storm : : dd : : DdType DdType >
void processOptionsWithDdLib ( storm : : cli : : SymbolicInput const & symbolicInput , storm : : cli : : ModelProcessingInformation const & mpi ) {
switch ( mpi . buildValueType ) {
case storm : : cli : : ModelProcessingInformation : : ValueType : : FinitePrecision :
processOptionsWithValueTypeAndDdLib < double , DdType > ( symbolicInput , mpi ) ;
break ;
case storm : : cli : : ModelProcessingInformation : : ValueType : : Exact :
STORM_LOG_THROW ( DdType = = storm : : dd : : DdType : : Sylvan , storm : : exceptions : : UnexpectedException , " Exact arithmetic is only supported with Dd library Sylvan. " ) ;
processOptionsWithValueTypeAndDdLib < storm : : RationalNumber , storm : : dd : : DdType : : Sylvan > ( symbolicInput , mpi ) ;
break ;
default :
STORM_LOG_THROW ( false , storm : : exceptions : : UnexpectedException , " Unexpected ValueType for model building. " ) ;
}
}
void processOptions ( ) {
auto symbolicInput = storm : : cli : : parseSymbolicInput ( ) ;
storm : : cli : : ModelProcessingInformation mpi ;
std : : tie ( symbolicInput , mpi ) = storm : : cli : : preprocessSymbolicInput ( symbolicInput ) ;
switch ( mpi . ddType ) {
case storm : : dd : : DdType : : CUDD :
processOptionsWithDdLib < storm : : dd : : DdType : : CUDD > ( symbolicInput , mpi ) ;
break ;
case storm : : dd : : DdType : : Sylvan :
processOptionsWithDdLib < storm : : dd : : DdType : : Sylvan > ( symbolicInput , mpi ) ;
break ;
default :
STORM_LOG_THROW ( false , storm : : exceptions : : UnexpectedException , " Unexpected Dd Type. " ) ;
}
}
}
}
}
/*!
* Entry point for the pomdp backend .
*
* @ param argc The argc argument of main ( ) .
* @ param argv The argv argument of main ( ) .
* @ return Return code , 0 if successfull , not 0 otherwise .
*/
int main ( const int argc , const char * * argv ) {
//try {
storm : : utility : : setUp ( ) ;
storm : : cli : : printHeader ( " Storm-pomdp " , argc , argv ) ;
storm : : settings : : initializePomdpSettings ( " Storm-POMDP " , " storm-pomdp " ) ;
bool optionsCorrect = storm : : cli : : parseOptions ( argc , argv ) ;
if ( ! optionsCorrect ) {
return - 1 ;
}
storm : : cli : : setUrgentOptions ( ) ;
// Invoke storm-pomdp with obtained settings
storm : : pomdp : : cli : : processOptions ( ) ;
// All operations have now been performed, so we clean up everything and terminate.
// All operations have now been performed, so we clean up everything and terminate.
storm : : utility : : cleanUp ( ) ;
storm : : utility : : cleanUp ( ) ;
return 0 ;
return 0 ;