@ -214,6 +214,7 @@ namespace storm { 
			
		
	
		
			
				
					             
			
		
	
		
			
				
					            template < typename  ValueType >  
			
		
	
		
			
				
					            std : : vector < ValueType >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageProbabilities ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < ValueType >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < ValueType >  const &  backwardTransitions ,  std : : vector < ValueType >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  psiStates ,  storm : : solver : : MinMaxLinearEquationSolverFactory < ValueType >  const &  minMaxLinearEquationSolverFactory )  {  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					                uint_fast64_t  numberOfStates  =  transitionMatrix . getRowGroupCount ( ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                // If there are no goal states, we avoid the computation and directly return zero.
  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -226,6 +227,36 @@ namespace storm { 
			
		
	
		
			
				
					                    return  std : : vector < ValueType > ( numberOfStates ,  storm : : utility : : one < ValueType > ( ) ) ;  
			
		
	
		
			
				
					                }  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					                // Otherwise, reduce the long run average probabilities to long run average rewards.
  
			
		
	
		
			
				
					                // Every Markovian goal state s gets 1/E(s) reward for its (unique) action.
  
			
		
	
		
			
				
					                std : : vector < ValueType >  totalActionRewards ( transitionMatrix . getRowCount ( ) ,  storm : : utility : : zero < ValueType > ( ) ) ;  
			
		
	
		
			
				
					                storm : : storage : : BitVector  markovianGoalStates  =  markovianStates  &  psiStates ;  
			
		
	
		
			
				
					                for  ( auto  const &  state  :  markovianGoalStates )  {  
			
		
	
		
			
				
					                    totalActionRewards [ transitionMatrix . getRowGroupIndices ( ) [ state ] ]  =  storm : : utility : : one < ValueType > ( )  /  exitRateVector [ state ] ;  
			
		
	
		
			
				
					                }  
			
		
	
		
			
				
					                return  computeLongRunAverageRewards ( dir ,  transitionMatrix ,  backwardTransitions ,  exitRateVector ,  markovianStates ,  totalActionRewards ,  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					            }  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					            template < typename  ValueType ,  typename  RewardModelType >  
			
		
	
		
			
				
					            std : : vector < ValueType >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageRewards ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < ValueType >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < ValueType >  const &  backwardTransitions ,  std : : vector < ValueType >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  RewardModelType  const &  rewardModel ,  storm : : solver : : MinMaxLinearEquationSolverFactory < ValueType >  const &  minMaxLinearEquationSolverFactory )  {  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					                // Obtain the total action reward vector where the state rewards are scaled accordingly
  
			
		
	
		
			
				
					                std : : vector < ValueType >  stateRewardWeights ( transitionMatrix . getRowGroupCount ( ) ,  storm : : utility : : zero < ValueType > ( ) ) ;  
			
		
	
		
			
				
					                for  ( auto  const  markovianState  :  markovianStates )  {  
			
		
	
		
			
				
					                    stateRewardWeights [ markovianState ]  =  storm : : utility : : one < ValueType > ( )  /  exitRateVector [ markovianState ] ;  
			
		
	
		
			
				
					                }  
			
		
	
		
			
				
					                std : : vector < ValueType >  totalRewardVector  =  rewardModel . getTotalActionRewardVector ( transitionMatrix ,  stateRewardWeights ) ;  
			
		
	
		
			
				
					                RewardModelType  scaledRewardModel ( boost : : none ,  std : : move ( totalRewardVector ) ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                return  computeLongRunAverageRewards ( dir ,  transitionMatrix ,  backwardTransitions ,  exitRateVector ,  markovianStates ,  totalRewardVector ,  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					           }  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					            template < typename  ValueType >  
			
		
	
		
			
				
					            std : : vector < ValueType >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageRewards ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < ValueType >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < ValueType >  const &  backwardTransitions ,  std : : vector < ValueType >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  std : : vector < ValueType >  const &  totalActionRewards ,  storm : : solver : : MinMaxLinearEquationSolverFactory < ValueType >  const &  minMaxLinearEquationSolverFactory )  {  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					                uint_fast64_t  numberOfStates  =  transitionMatrix . getRowGroupCount ( ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                // Start by decomposing the Markov automaton into its MECs.
  
			
		
	
		
			
				
					                storm : : storage : : MaximalEndComponentDecomposition < ValueType >  mecDecomposition ( transitionMatrix ,  backwardTransitions ) ;  
			
		
	
		
			
				
					                 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -251,7 +282,7 @@ namespace storm { 
			
		
	
		
			
				
					                    }  
			
		
	
		
			
				
					                     
			
		
	
		
			
				
					                    // Compute the LRA value for the current MEC.
  
			
		
	
		
			
				
					                    lraValuesForEndComponents . push_back ( computeLraForMaximalEndComponent ( dir ,  transitionMatrix ,  exitRateVector ,  markovianStates ,  psiState s,  mec ) ) ;  
			
		
	
		
			
				
					                    lraValuesForEndComponents . push_back ( computeLraForMaximalEndComponent ( dir ,  transitionMatrix ,  exitRateVector ,  markovianStates ,  totalActionReward s,  mec ) ) ;  
			
		
	
		
			
				
					                }  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					                // For fast transition rewriting, we build some auxiliary data structures.
  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -381,7 +412,7 @@ namespace storm { 
			
		
	
		
			
				
					            }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            template < typename  ValueType >  
			
		
	
		
			
				
					            ValueType  SparseMarkovAutomatonCslHelper : : computeLraForMaximalEndComponent ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < ValueType >  const &  transitionMatrix ,  std : : vector < ValueType >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  goalState s ,  storm : : storage : : MaximalEndComponent  const &  mec )  {  
			
		
	
		
			
				
					            ValueType  SparseMarkovAutomatonCslHelper : : computeLraForMaximalEndComponent ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < ValueType >  const &  transitionMatrix ,  std : : vector < ValueType >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  std : : vector < ValueType >  const &  totalActionReward s ,  storm : : storage : : MaximalEndComponent  const &  mec )  {  
			
		
	
		
			
				
					                std : : unique_ptr < storm : : utility : : solver : : LpSolverFactory >  lpSolverFactory ( new  storm : : utility : : solver : : LpSolverFactory ( ) ) ;  
			
		
	
		
			
				
					                std : : unique_ptr < storm : : solver : : LpSolver >  solver  =  lpSolverFactory - > create ( " LRA for MEC " ) ;  
			
		
	
		
			
				
					                solver - > setOptimizationDirection ( invert ( dir ) ) ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -402,6 +433,9 @@ namespace storm { 
			
		
	
		
			
				
					                     
			
		
	
		
			
				
					                    // Now, based on the type of the state, create a suitable constraint.
  
			
		
	
		
			
				
					                    if  ( markovianStates . get ( state ) )  {  
			
		
	
		
			
				
					                        STORM_LOG_ASSERT ( stateChoicesPair . second . size ( )  = =  1 ,  " Markovian state  "  < <  state  < <  "  is not deterministic: It has  "  < <  stateChoicesPair . second . size ( )  < <  "  choices. " ) ;  
			
		
	
		
			
				
					                        uint_fast64_t  choice  =  * stateChoicesPair . second . begin ( ) ;  
			
		
	
		
			
				
					                         
			
		
	
		
			
				
					                        storm : : expressions : : Expression  constraint  =  stateToVariableMap . at ( state ) ;  
			
		
	
		
			
				
					                         
			
		
	
		
			
				
					                        for  ( auto  element  :  transitionMatrix . getRow ( nondeterministicChoiceIndices [ state ] ) )  {  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -409,7 +443,7 @@ namespace storm { 
			
		
	
		
			
				
					                        }  
			
		
	
		
			
				
					                         
			
		
	
		
			
				
					                        constraint  =  constraint  +  solver - > getManager ( ) . rational ( storm : : utility : : one < ValueType > ( )  /  exitRateVector [ state ] )  *  k ;  
			
		
	
		
			
				
					                        storm : : expressions : : Expression  rightHandSide  =  goalStates . get ( state )  ?  solver - > getManager ( ) . rational ( storm : : utility : : one < ValueType > ( )  /  exitRateVector [ state ] )  :  solver - > getManager ( ) . rational ( storm : : utility : : zero < ValueType > ( ) ) ;  
			
		
	
		
			
				
					                        storm : : expressions : : Expression  rightHandSide  =  solver - > getManager ( ) . rational ( totalActionRewards [ choice ] ) ;  
			
		
	
		
			
				
					                        if  ( dir  = =  OptimizationDirection : : Minimize )  {  
			
		
	
		
			
				
					                            constraint  =  constraint  < =  rightHandSide ;  
			
		
	
		
			
				
					                        }  else  {  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -426,7 +460,7 @@ namespace storm { 
			
		
	
		
			
				
					                                constraint  =  constraint  -  stateToVariableMap . at ( element . getColumn ( ) )  *  solver - > getManager ( ) . rational ( element . getValue ( ) ) ;  
			
		
	
		
			
				
					                            }  
			
		
	
		
			
				
					                             
			
		
	
		
			
				
					                            storm : : expressions : : Expression  rightHandSide  =  solver - > getManager ( ) . rational ( storm : : utility : : zero < ValueType > ( ) ) ;  
			
		
	
		
			
				
					                            storm : : expressions : : Expression  rightHandSide  =  solver - > getManager ( ) . rational ( totalActionRewards [ choice ] ) ;  
			
		
	
		
			
				
					                            if  ( dir  = =  OptimizationDirection : : Minimize )  {  
			
		
	
		
			
				
					                                constraint  =  constraint  < =  rightHandSide ;  
			
		
	
		
			
				
					                            }  else  {  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -451,11 +485,15 @@ namespace storm { 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            template  std : : vector < double >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageProbabilities ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < double >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < double >  const &  backwardTransitions ,  std : : vector < double >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  psiStates ,  storm : : solver : : MinMaxLinearEquationSolverFactory < double >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					            template  std : : vector < double >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageRewards ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < double >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < double >  const &  backwardTransitions ,  std : : vector < double >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : models : : sparse : : StandardRewardModel < double >  const &  rewardModel ,  storm : : solver : : MinMaxLinearEquationSolverFactory < double >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					            template  std : : vector < double >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageRewards ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < double >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < double >  const &  backwardTransitions ,  std : : vector < double >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  std : : vector < double >  const &  totalActionRewards ,  storm : : solver : : MinMaxLinearEquationSolverFactory < double >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					            template  std : : vector < double >  SparseMarkovAutomatonCslHelper : : computeReachabilityTimes ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < double >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < double >  const &  backwardTransitions ,  std : : vector < double >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  psiStates ,  storm : : solver : : MinMaxLinearEquationSolverFactory < double >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					            template  void  SparseMarkovAutomatonCslHelper : : computeBoundedReachabilityProbabilities ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < double >  const &  transitionMatrix ,  std : : vector < double >  const &  exitRates ,  storm : : storage : : BitVector  const &  goalStates ,  storm : : storage : : BitVector  const &  markovianNonGoalStates ,  storm : : storage : : BitVector  const &  probabilisticNonGoalStates ,  std : : vector < double > &  markovianNonGoalValues ,  std : : vector < double > &  probabilisticNonGoalValues ,  double  delta ,  uint_fast64_t  numberOfSteps ,  storm : : solver : : MinMaxLinearEquationSolverFactory < double >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					            template  double  SparseMarkovAutomatonCslHelper : : computeLraForMaximalEndComponent ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < double >  const &  transitionMatrix ,  std : : vector < double >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  goalState s ,  storm : : storage : : MaximalEndComponent  const &  mec ) ;  
			
		
	
		
			
				
					            template  double  SparseMarkovAutomatonCslHelper : : computeLraForMaximalEndComponent ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < double >  const &  transitionMatrix ,  std : : vector < double >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  std : : vector < double >  const &  totalActionReward s ,  storm : : storage : : MaximalEndComponent  const &  mec ) ;  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					            template  std : : vector < storm : : RationalNumber >  SparseMarkovAutomatonCslHelper : : computeBoundedUntilProbabilities ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  transitionMatrix ,  std : : vector < storm : : RationalNumber >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  psiStates ,  std : : pair < double ,  double >  const &  boundsPair ,  storm : : solver : : MinMaxLinearEquationSolverFactory < storm : : RationalNumber >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					                 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -465,11 +503,15 @@ namespace storm { 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            template  std : : vector < storm : : RationalNumber >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageProbabilities ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  backwardTransitions ,  std : : vector < storm : : RationalNumber >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  psiStates ,  storm : : solver : : MinMaxLinearEquationSolverFactory < storm : : RationalNumber >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					            template  std : : vector < storm : : RationalNumber >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageRewards ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  backwardTransitions ,  std : : vector < storm : : RationalNumber >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : models : : sparse : : StandardRewardModel < storm : : RationalNumber >  const &  rewardModel ,  storm : : solver : : MinMaxLinearEquationSolverFactory < storm : : RationalNumber >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					            template  std : : vector < storm : : RationalNumber >  SparseMarkovAutomatonCslHelper : : computeLongRunAverageRewards ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  backwardTransitions ,  std : : vector < storm : : RationalNumber >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  std : : vector < storm : : RationalNumber >  const &  totalActionRewards ,  storm : : solver : : MinMaxLinearEquationSolverFactory < storm : : RationalNumber >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					             
			
		
	
		
			
				
					            template  std : : vector < storm : : RationalNumber >  SparseMarkovAutomatonCslHelper : : computeReachabilityTimes ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  transitionMatrix ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  backwardTransitions ,  std : : vector < storm : : RationalNumber >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  psiStates ,  storm : : solver : : MinMaxLinearEquationSolverFactory < storm : : RationalNumber >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					            template  void  SparseMarkovAutomatonCslHelper : : computeBoundedReachabilityProbabilities ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  transitionMatrix ,  std : : vector < storm : : RationalNumber >  const &  exitRates ,  storm : : storage : : BitVector  const &  goalStates ,  storm : : storage : : BitVector  const &  markovianNonGoalStates ,  storm : : storage : : BitVector  const &  probabilisticNonGoalStates ,  std : : vector < storm : : RationalNumber > &  markovianNonGoalValues ,  std : : vector < storm : : RationalNumber > &  probabilisticNonGoalValues ,  storm : : RationalNumber  delta ,  uint_fast64_t  numberOfSteps ,  storm : : solver : : MinMaxLinearEquationSolverFactory < storm : : RationalNumber >  const &  minMaxLinearEquationSolverFactory ) ;  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					            template  storm : : RationalNumber  SparseMarkovAutomatonCslHelper : : computeLraForMaximalEndComponent ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  transitionMatrix ,  std : : vector < storm : : RationalNumber >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  storm : : storage : : BitVector  const &  goalStates ,   storm : : storage : : MaximalEndComponent  const &  mec ) ;  
			
		
	
		
			
				
					            template  storm : : RationalNumber  SparseMarkovAutomatonCslHelper : : computeLraForMaximalEndComponent ( OptimizationDirection  dir ,  storm : : storage : : SparseMatrix < storm : : RationalNumber >  const &  transitionMatrix ,  std : : vector < storm : : RationalNumber >  const &  exitRateVector ,  storm : : storage : : BitVector  const &  markovianStates ,  std : : vector < storm : : RationalNumber >  const &  totalActionRewards ,    storm : : storage : : MaximalEndComponent  const &  mec ) ;  
			
		
	
		
			
				
					                 
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					    }