@ -17,13 +17,13 @@
namespace storm {
namespace prism {
Program : : Program ( std : : shared_ptr < storm : : expressions : : ExpressionManager > manager , ModelType modelType , std : : vector < Constant > const & constants , std : : vector < BooleanVariable > const & globalBooleanVariables , std : : vector < IntegerVariable > const & globalIntegerVariables , std : : vector < Formula > const & formulas , std : : vector < Module > const & modules , std : : map < std : : string , uint_fast64_t > const & actionToIndexMap , std : : vector < RewardModel > const & rewardModels , bool fixInitialConstruct , storm : : prism : : InitialConstruct const & initialConstruct , std : : vector < Label > const & labels , std : : string const & filename , uint_fast64_t lineNumber , bool finalModel )
Program : : Program ( std : : shared_ptr < storm : : expressions : : ExpressionManager > manager , ModelType modelType , std : : vector < Constant > const & constants , std : : vector < BooleanVariable > const & globalBooleanVariables , std : : vector < IntegerVariable > const & globalIntegerVariables , std : : vector < Formula > const & formulas , std : : vector < Module > const & modules , std : : map < std : : string , uint_fast64_t > const & actionToIndexMap , std : : vector < RewardModel > const & rewardModels , std : : vector < Label > const & labels , boost : : optional < InitialConstruct > const & initialConstruct , boo st: : optional < std : : shared_ptr < Composition > > const & composition , std : : string const & filename , uint_fast64_t lineNumber , bool finalModel )
: LocatedInformation ( filename , lineNumber ) , manager ( manager ) ,
modelType ( modelType ) , constants ( constants ) , constantToIndexMap ( ) ,
globalBooleanVariables ( globalBooleanVariables ) , globalBooleanVariableToIndexMap ( ) ,
globalIntegerVariables ( globalIntegerVariables ) , globalIntegerVariableToIndexMap ( ) ,
formulas ( formulas ) , formulaToIndexMap ( ) , modules ( modules ) , moduleToIndexMap ( ) ,
rewardModels ( rewardModels ) , rewardModelToIndexMap ( ) , initialConstruct ( initialConstruct ) ,
rewardModels ( rewardModels ) , rewardModelToIndexMap ( ) , systemComposition ( composition ) ,
labels ( labels ) , labelToIndexMap ( ) , actionToIndexMap ( actionToIndexMap ) , indexToActionMap ( ) , actions ( ) ,
synchronizingActionIndices ( ) , actionIndicesToModuleIndexMap ( ) , variableToModuleIndexMap ( )
{
@ -31,8 +31,11 @@ namespace storm {
// Start by creating the necessary mappings from the given ones.
this - > createMappings ( ) ;
// Create a new initial construct if the corresponding flag was set.
if ( fixInitialConstruct ) {
// Set the initial construct.
if ( initialConstruct ) {
this - > initialConstruct = initialConstruct . get ( ) ;
} else {
// Create a new initial construct if none was given.
storm : : expressions : : Expression newInitialExpression = manager - > boolean ( true ) ;
for ( auto const & booleanVariable : this - > getGlobalBooleanVariables ( ) ) {
@ -53,7 +56,6 @@ namespace storm {
}
if ( finalModel ) {
// If the model is supposed to be a CTMC, but contains probabilistic commands, we transform them to Markovian
// commands and issue a warning.
if ( modelType = = storm : : prism : : Program : : ModelType : : CTMC & & storm : : settings : : generalSettings ( ) . isPrismCompatibilityEnabled ( ) ) {
@ -293,6 +295,18 @@ namespace storm {
return this - > initialConstruct ;
}
bool Program : : specifiesSystemComposition ( ) const {
return static_cast < bool > ( systemComposition ) ;
}
Composition const & Program : : getSystemComposition ( ) const {
return * systemComposition . get ( ) ;
}
boost : : optional < std : : shared_ptr < Composition > > Program : : getOptionalSystemComposition ( ) const {
return systemComposition ;
}
std : : set < std : : string > const & Program : : getActions ( ) const {
return this - > actions ;
}
@ -416,7 +430,7 @@ namespace storm {
newModules . push_back ( module . restrictCommands ( indexSet ) ) ;
}
return Program ( this - > manager , this - > getModelType ( ) , this - > getConstants ( ) , this - > getGlobalBooleanVariables ( ) , this - > getGlobalIntegerVariables ( ) , this - > getFormulas ( ) , newModules , this - > getActionNameToIndexMapping ( ) , this - > getRewardModels ( ) , false , this - > getInitialConstruct ( ) , this - > getLabels ( ) ) ;
return Program ( this - > manager , this - > getModelType ( ) , this - > getConstants ( ) , this - > getGlobalBooleanVariables ( ) , this - > getGlobalIntegerVariables ( ) , this - > getFormulas ( ) , newModules , this - > getActionNameToIndexMapping ( ) , this - > getRewardModels ( ) , this - > getLabels ( ) , this - > getInitialConstruct ( ) , this - > getOptionalSystemComposition ( ) ) ;
}
void Program : : createMappings ( ) {
@ -516,7 +530,7 @@ namespace storm {
STORM_LOG_THROW ( definedUndefinedConstants . find ( constantExpressionPair . first ) ! = definedUndefinedConstants . end ( ) , storm : : exceptions : : InvalidArgumentException , " Unable to define non-existant constant. " ) ;
}
return Program ( this - > manager , this - > getModelType ( ) , newConstants , this - > getGlobalBooleanVariables ( ) , this - > getGlobalIntegerVariables ( ) , this - > getFormulas ( ) , this - > getModules ( ) , this - > getActionNameToIndexMapping ( ) , this - > getRewardModels ( ) , false , this - > getInitialConstruct ( ) , this - > getLabels ( ) ) ;
return Program ( this - > manager , this - > getModelType ( ) , newConstants , this - > getGlobalBooleanVariables ( ) , this - > getGlobalIntegerVariables ( ) , this - > getFormulas ( ) , this - > getModules ( ) , this - > getActionNameToIndexMapping ( ) , this - > getRewardModels ( ) , this - > getLabels ( ) , this - > getInitialConstruct ( ) , this - > getOptionalSystemComposition ( ) ) ;
}
Program Program : : substituteConstants ( ) const {
@ -576,7 +590,7 @@ namespace storm {
newLabels . emplace_back ( label . substitute ( constantSubstitution ) ) ;
}
return Program ( this - > manager , this - > getModelType ( ) , newConstants , newBooleanVariables , newIntegerVariables , newFormulas , newModules , this - > getActionNameToIndexMapping ( ) , newRewardModels , false , newInitialConstruct , newLabels ) ;
return Program ( this - > manager , this - > getModelType ( ) , newConstants , newBooleanVariables , newIntegerVariables , newFormulas , newModules , this - > getActionNameToIndexMapping ( ) , newRewardModels , newLabels , newInitialConstruct , this - > getOptionalSystemComposition ( ) ) ;
}
void Program : : checkValidity ( Program : : ValidityCheckLevel lvl ) const {
@ -1017,7 +1031,7 @@ namespace storm {
}
Program Program : : replaceModulesAndConstantsInProgram ( std : : vector < Module > const & newModules , std : : vector < Constant > const & newConstants ) {
return Program ( this - > manager , modelType , newConstants , getGlobalBooleanVariables ( ) , getGlobalIntegerVariables ( ) , getFormulas ( ) , newModules , getActionNameToIndexMapping ( ) , getRewardModels ( ) , false , getInitialConstruct ( ) , getLabels ( ) , " " , 0 , false ) ;
return Program ( this - > manager , modelType , newConstants , getGlobalBooleanVariables ( ) , getGlobalIntegerVariables ( ) , getFormulas ( ) , newModules , getActionNameToIndexMapping ( ) , getRewardModels ( ) , getLabels ( ) , getInitialConstruct ( ) , this - > getOptionalSystemComposition ( ) ) ;
}
Program Program : : flattenModules ( std : : unique_ptr < storm : : utility : : solver : : SmtSolverFactory > const & smtSolverFactory ) const {
@ -1203,7 +1217,7 @@ namespace storm {
// Finally, we can create the module and the program and return it.
storm : : prism : : Module singleModule ( newModuleName . str ( ) , allBooleanVariables , allIntegerVariables , newCommands , this - > getFilename ( ) , 0 ) ;
return Program ( manager , this - > getModelType ( ) , this - > getConstants ( ) , std : : vector < storm : : prism : : BooleanVariable > ( ) , std : : vector < storm : : prism : : IntegerVariable > ( ) , this - > getFormulas ( ) , { singleModule } , actionToIndexMap , this - > getRewardModels ( ) , false , this - > getInitialConstruct ( ) , this - > getLabels ( ) , this - > getFilename ( ) , 0 , true ) ;
return Program ( manager , this - > getModelType ( ) , this - > getConstants ( ) , std : : vector < storm : : prism : : BooleanVariable > ( ) , std : : vector < storm : : prism : : IntegerVariable > ( ) , this - > getFormulas ( ) , { singleModule } , actionToIndexMap , this - > getRewardModels ( ) , this - > getLabels ( ) , this - > getInitialConstruct ( ) , this - > getOptionalSystemComposition ( ) , this - > getFilename ( ) , 0 , true ) ;
}
std : : unordered_map < uint_fast64_t , std : : string > Program : : buildCommandIndexToActionNameMap ( ) const {
@ -1353,6 +1367,14 @@ namespace storm {
stream < < label < < std : : endl ;
}
stream < < program . getInitialConstruct ( ) < < std : : endl ;
if ( program . specifiesSystemComposition ( ) ) {
stream < < " system " < < std : : endl ;
stream < < " \t " < < program . getSystemComposition ( ) < < std : : endl ;
stream < < " endsystem " < < std : : endl ;
}
return stream ;
}