@ -8,7 +8,7 @@ 
		
	
		
			
				namespace  storm  { namespace  storm  {  
		
	
		
			
				    namespace  builder  {     namespace  builder  {  
		
	
		
			
				
 
		
	
		
			
				        storm : : jani : : Model *  JaniGSPNBuilder : : build ( std : : string  const &  automatonName ,  bool  buildStandardProperties )  {  
		
	
		
			
				        storm : : jani : : Model *  JaniGSPNBuilder : : build ( std : : string  const &  automatonName )  {  
		
	
		
			
				            storm : : jani : : ModelType  modelType  =  storm : : jani : : ModelType : : MA ;             storm : : jani : : ModelType  modelType  =  storm : : jani : : ModelType : : MA ;  
		
	
		
			
				            if  ( gspn . getNumberOfTimedTransitions ( )  = =  0 )  {             if  ( gspn . getNumberOfTimedTransitions ( )  = =  0 )  {  
		
	
		
			
				                storm : : jani : : ModelType  modelType  =  storm : : jani : : ModelType : : MDP ;                 storm : : jani : : ModelType  modelType  =  storm : : jani : : ModelType : : MDP ;  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -22,15 +22,8 @@ namespace storm { 
		
	
		
			
				            addEdges ( mainAutomaton ,  locId ) ;             addEdges ( mainAutomaton ,  locId ) ;  
		
	
		
			
				            model - > addAutomaton ( mainAutomaton ) ;             model - > addAutomaton ( mainAutomaton ) ;  
		
	
		
			
				            model - > setStandardSystemComposition ( ) ;             model - > setStandardSystemComposition ( ) ;  
		
	
		
			
				            if  ( buildStandardProperties )  {  
		
	
		
			
				                buildProperties ( model ) ;  
		
	
		
			
				            }  
		
	
		
			
				            return  model ;             return  model ;  
		
	
		
			
				        }         }  
		
	
		
			
				         
		
	
		
			
				        std : : vector < storm : : jani : : Property >  const &  JaniGSPNBuilder : : getStandardProperties ( )  const  {  
		
	
		
			
				            return  standardProperties ;  
		
	
		
			
				        }  
		
	
		
			
				
 
		
	
		
			
				        void  JaniGSPNBuilder : : addVariables ( storm : : jani : : Model *  model )  {         void  JaniGSPNBuilder : : addVariables ( storm : : jani : : Model *  model )  {  
		
	
		
			
				            for  ( auto  const &  place  :  gspn . getPlaces ( ) )  {             for  ( auto  const &  place  :  gspn . getPlaces ( ) )  {  
		
	
	
		
			
				
					
						
							 
					
					
						
							 
					
					
				 
				@ -188,11 +181,10 @@ namespace storm { 
		
	
		
			
				
 
		
	
		
			
				            }             }  
		
	
		
			
				        }         }  
		
	
		
			
				          
		
	
		
			
				
  
		
	
		
			
				        storm : : jani : : Variable  const &  JaniGSPNBuilder : : addDeadlockTransientVariable ( storm : : jani : : Model *  model ,  std : : string  name ,  bool  ignoreCapacities ,  bool  ignoreInhibitorArcs ,  bool  ignoreEmptyPlaces )  {         storm : : jani : : Variable  const &  JaniGSPNBuilder : : addDeadlockTransientVariable ( storm : : jani : : Model *  model ,  std : : string  name ,  bool  ignoreCapacities ,  bool  ignoreInhibitorArcs ,  bool  ignoreEmptyPlaces )  {  
		
	
		
			
				             
		
	
		
			
				            storm : : expressions : : Expression  transientValue  =  expressionManager - > boolean ( true ) ;             storm : : expressions : : Expression  transientValue  =  expressionManager - > boolean ( true ) ;  
		
	
		
			
				              
		
	
		
			
				
  
		
	
		
			
				            // build the conjunction over all transitions
             // build the conjunction over all transitions
  
		
	
		
			
				            std : : vector < storm : : gspn : : Transition  const * >  transitions ;             std : : vector < storm : : gspn : : Transition  const * >  transitions ;  
		
	
		
			
				            transitions . reserve ( gspn . getNumberOfImmediateTransitions ( )  +  gspn . getNumberOfTimedTransitions ( ) ) ;             transitions . reserve ( gspn . getNumberOfImmediateTransitions ( )  +  gspn . getNumberOfTimedTransitions ( ) ) ;  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -204,7 +196,7 @@ namespace storm { 
		
	
		
			
				            }             }  
		
	
		
			
				            bool  firstTransition  =  true ;             bool  firstTransition  =  true ;  
		
	
		
			
				            for  ( auto  const &  transition  :  transitions )  {             for  ( auto  const &  transition  :  transitions )  {  
		
	
		
			
				                  
		
	
		
			
				
  
		
	
		
			
				                // build the disjunction over all in/out places and inhibitor arcs
                 // build the disjunction over all in/out places and inhibitor arcs
  
		
	
		
			
				                storm : : expressions : : Expression  transitionDisabled  =  expressionManager - > boolean ( false ) ;                 storm : : expressions : : Expression  transitionDisabled  =  expressionManager - > boolean ( false ) ;  
		
	
		
			
				                bool  firstPlace  =  true ;                 bool  firstPlace  =  true ;  
		
	
	
		
			
				
					
						
							 
					
					
						
							 
					
					
				 
				@ -244,7 +236,7 @@ namespace storm { 
		
	
		
			
				                        }                         }  
		
	
		
			
				                    }                     }  
		
	
		
			
				                }                 }  
		
	
		
			
				                  
		
	
		
			
				
  
		
	
		
			
				                if  ( firstTransition )  {                 if  ( firstTransition )  {  
		
	
		
			
				                    transientValue  =  transitionDisabled ;                     transientValue  =  transitionDisabled ;  
		
	
		
			
				                    firstTransition  =  false ;                     firstTransition  =  false ;  
		
	
	
		
			
				
					
						
							 
					
					
						
							 
					
					
				 
				@ -271,36 +263,50 @@ namespace storm { 
		
	
		
			
				            }             }  
		
	
		
			
				            return  res ;             return  res ;  
		
	
		
			
				        }         }  
		
	
		
			
				         
		
	
		
			
				        void  JaniGSPNBuilder : : buildProperties ( storm : : jani : : Model *  model )  {  
		
	
		
			
				            standardProperties . clear ( ) ;  
		
	
		
			
				             
		
	
		
			
				            auto  const &  deadlockVar  =  addDeadlockTransientVariable ( model ,  getUniqueVarName ( * expressionManager ,  " deadl " ) ) ;  
		
	
		
			
				            auto  deadlock  =  std : : make_shared < storm : : logic : : AtomicExpressionFormula > ( deadlockVar . getExpressionVariable ( ) . getExpression ( ) ) ;  
		
	
		
			
				            auto  trueFormula  =  std : : make_shared < storm : : logic : : BooleanLiteralFormula > ( true ) ;  
		
	
		
			
				             
		
	
		
			
				            auto  maxReachDeadlock  =  std : : make_shared < storm : : logic : : ProbabilityOperatorFormula > (  
		
	
		
			
				                    std : : make_shared < storm : : logic : : EventuallyFormula > ( deadlock ,  storm : : logic : : FormulaContext : : Probability ) ,  
		
	
		
			
				                    storm : : logic : : OperatorInformation ( storm : : solver : : OptimizationDirection : : Maximize ) ) ;  
		
	
		
			
				            standardProperties . emplace_back ( " MaxPrReachDeadlock " ,  maxReachDeadlock ,  " The maximal probability to eventually reach a deadlock. " ) ;  
		
	
		
			
				             
		
	
		
			
				
 
		
	
		
			
				        std : : vector < storm : : jani : : Property >  const &  JaniGSPNBuilder : : getStandardProperties ( storm : : jani : : Model *  model ,  std : : shared_ptr < storm : : logic : : AtomicExpressionFormula >  atomicFormula ,  std : : string  name ,  std : : string  description ,  bool  maximal )  {  
		
	
		
			
				            std : : vector < storm : : jani : : Property >  standardProperties ;  
		
	
		
			
				            std : : string  dirShort  =  maximal  ?  " Max "  :  " Min " ;  
		
	
		
			
				            std : : string  dirLong  =  maximal  ?  " maximal "  :  " minimal " ;  
		
	
		
			
				            storm : : solver : : OptimizationDirection  optimizationDirection  =  maximal  ?  storm : : solver : : OptimizationDirection : : Maximize  :  storm : : solver : : OptimizationDirection : : Minimize ;  
		
	
		
			
				
 
		
	
		
			
				            // Build reachability property
  
		
	
		
			
				            auto  reachFormula  =  std : : make_shared < storm : : logic : : ProbabilityOperatorFormula > (  
		
	
		
			
				                    std : : make_shared < storm : : logic : : EventuallyFormula > ( atomicFormula ,  storm : : logic : : FormulaContext : : Probability ) ,  
		
	
		
			
				                    storm : : logic : : OperatorInformation ( optimizationDirection ) ) ;  
		
	
		
			
				            standardProperties . emplace_back ( dirShort  +  " PrReach "  +  name ,  reachFormula ,  " The  "  +  dirLong  +  "  probability to eventually reach  "  +  description  +  " . " ) ;  
		
	
		
			
				
 
		
	
		
			
				            // Build time bounded reachability property
  
		
	
		
			
				            // Add variable for time bound
  
		
	
		
			
				            auto  exprTB  =  expressionManager - > declareRationalVariable ( getUniqueVarName ( * expressionManager ,  " TIME_BOUND " ) ) ;             auto  exprTB  =  expressionManager - > declareRationalVariable ( getUniqueVarName ( * expressionManager ,  " TIME_BOUND " ) ) ;  
		
	
		
			
				            auto  janiTB  =  storm : : jani : : Constant ( exprTB . getName ( ) ,  exprTB ) ;             auto  janiTB  =  storm : : jani : : Constant ( exprTB . getName ( ) ,  exprTB ) ;  
		
	
		
			
				            model - > addConstant ( janiTB ) ;             model - > addConstant ( janiTB ) ;  
		
	
		
			
				            storm : : logic : : TimeBound  tb ( false ,  janiTB . getExpressionVariable ( ) . getExpression ( ) ) ;             storm : : logic : : TimeBound  tb ( false ,  janiTB . getExpressionVariable ( ) . getExpression ( ) ) ;  
		
	
		
			
				            storm : : logic : : TimeBoundReference  tbr ( storm : : logic : : TimeBoundType : : Time ) ;             storm : : logic : : TimeBoundReference  tbr ( storm : : logic : : TimeBoundType : : Time ) ;  
		
	
		
			
				            auto  maxReachDeadlockTimeBounded  =  std : : make_shared < storm : : logic : : ProbabilityOperatorFormula > (  
		
	
		
			
				                    std : : make_shared < storm : : logic : : BoundedUntilFormula > ( trueFormula ,  deadlock ,  boost : : none ,  tb ,  tbr ) ,  
		
	
		
			
				                    storm : : logic : : OperatorInformation ( storm : : solver : : OptimizationDirection : : Maximize ) ) ;  
		
	
		
			
				            standardProperties . emplace_back ( " MaxPrReachDeadlockTB " ,  maxReachDeadlockTimeBounded ,  " The maximal probability to reach a deadlock within 'TIME_BOUND' steps. " ) ;  
		
	
		
			
				             
		
	
		
			
				            auto  expTimeDeadlock  =  std : : make_shared < storm : : logic : : TimeOperatorFormula > (  
		
	
		
			
				                    std : : make_shared < storm : : logic : : EventuallyFormula > ( deadlock ,  storm : : logic : : FormulaContext : : Time ) ,  
		
	
		
			
				                    storm : : logic : : OperatorInformation ( storm : : solver : : OptimizationDirection : : Maximize ) ) ;  
		
	
		
			
				            standardProperties . emplace_back ( " MinExpTimeDeadlock " ,  expTimeDeadlock ,  " The minimal expected time to reach a deadlock. " ) ;  
		
	
		
			
				             
		
	
		
			
				
 
		
	
		
			
				            auto  trueFormula  =  std : : make_shared < storm : : logic : : BooleanLiteralFormula > ( true ) ;  
		
	
		
			
				            auto  reachTimeBoundFormula  =  std : : make_shared < storm : : logic : : ProbabilityOperatorFormula > (  
		
	
		
			
				                    std : : make_shared < storm : : logic : : BoundedUntilFormula > ( trueFormula ,  atomicFormula ,  boost : : none ,  tb ,  tbr ) ,  
		
	
		
			
				                    storm : : logic : : OperatorInformation ( optimizationDirection ) ) ;  
		
	
		
			
				            standardProperties . emplace_back ( dirShort  +  " PrReach "  +  name  +  " TB " ,  reachTimeBoundFormula ,  " The  "  +  dirLong  +  "  probability to reach  "  +  description  +  "  within 'TIME_BOUND' steps. " ) ;  
		
	
		
			
				
 
		
	
		
			
				            // Use complementary direction for expected time
  
		
	
		
			
				            dirShort  =  maximal  ?  " Min "  :  " Max " ;  
		
	
		
			
				            dirLong  =  maximal  ?  " minimal "  :  " maximal " ;  
		
	
		
			
				            optimizationDirection  =  maximal  ?  storm : : solver : : OptimizationDirection : : Minimize  :  storm : : solver : : OptimizationDirection : : Maximize ;  
		
	
		
			
				
 
		
	
		
			
				            // Build expected time property
  
		
	
		
			
				            auto  expTimeFormula  =  std : : make_shared < storm : : logic : : TimeOperatorFormula > (  
		
	
		
			
				                    std : : make_shared < storm : : logic : : EventuallyFormula > ( atomicFormula ,  storm : : logic : : FormulaContext : : Time ) ,  
		
	
		
			
				                    storm : : logic : : OperatorInformation ( optimizationDirection ) ) ;  
		
	
		
			
				            standardProperties . emplace_back ( dirShort  +  " ExpTime "  +  name ,  expTimeFormula ,  " The  "  +  dirLong  +  "  expected time to reach  "  +  description  +  " . " ) ;  
		
	
		
			
				        }  
		
	
		
			
				
 
		
	
		
			
				        std : : vector < storm : : jani : : Property >  const &  JaniGSPNBuilder : : getDeadlockProperties ( storm : : jani : : Model *  model )  {  
		
	
		
			
				            auto  const &  deadlockVar  =  addDeadlockTransientVariable ( model ,  getUniqueVarName ( * expressionManager ,  " deadl " ) ) ;  
		
	
		
			
				            auto  deadlockFormula  =  std : : make_shared < storm : : logic : : AtomicExpressionFormula > ( deadlockVar . getExpressionVariable ( ) . getExpression ( ) ) ;  
		
	
		
			
				            return  getStandardProperties ( model ,  deadlockFormula ,  " Deadlock " ,  " a deadlock " ,  true ) ;  
		
	
		
			
				        }         }  
		
	
		
			
				
 
		
	
		
			
				         
		
	
		
			
				    }     }  
		
	
		
			
				} }