@ -32,7 +32,7 @@ namespace storm {
PcaaObjective < ValueType > & currentObjective = result . objectives . back ( ) ;
currentObjective . originalFormula = subFormula ;
if ( currentObjective . originalFormula - > isOperatorFormula ( ) ) {
preprocessFormula ( currentObjective . originalFormula - > asOperatorFormula ( ) , result , currentObjective ) ;
preprocessOperator Formula ( currentObjective . originalFormula - > asOperatorFormula ( ) , result , currentObjective ) ;
} else {
STORM_LOG_THROW ( false , storm : : exceptions : : InvalidPropertyException , " Could not preprocess the subformula " < < * subFormula < < " of " < < originalFormula < < " because it is not supported " ) ;
}
@ -93,7 +93,7 @@ namespace storm {
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : OperatorFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessOperator Formula ( storm : : logic : : OperatorFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
// Get a unique name for the new reward model.
currentObjective . rewardModelName = " objective " + std : : to_string ( result . objectives . size ( ) ) ;
@ -124,11 +124,11 @@ namespace storm {
}
if ( formula . isProbabilityOperatorFormula ( ) ) {
preprocessFormula ( formula . asProbabilityOperatorFormula ( ) , result , currentObjective ) ;
preprocessProbabilityOperator Formula ( formula . asProbabilityOperatorFormula ( ) , result , currentObjective ) ;
} else if ( formula . isRewardOperatorFormula ( ) ) {
preprocessFormula ( formula . asRewardOperatorFormula ( ) , result , currentObjective ) ;
preprocessRewardOperator Formula ( formula . asRewardOperatorFormula ( ) , result , currentObjective ) ;
} else if ( formula . isTimeOperatorFormula ( ) ) {
preprocessFormula ( formula . asTimeOperatorFormula ( ) , result , currentObjective ) ;
preprocessTimeOperator Formula ( formula . asTimeOperatorFormula ( ) , result , currentObjective ) ;
} else {
STORM_LOG_THROW ( false , storm : : exceptions : : InvalidPropertyException , " Could not preprocess the objective " < < formula < < " because it is not supported " ) ;
}
@ -140,52 +140,52 @@ namespace storm {
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : ProbabilityOperatorFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessProbabilityOperator Formula ( storm : : logic : : ProbabilityOperatorFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
if ( formula . getSubformula ( ) . isUntilFormula ( ) ) {
preprocessFormula ( formula . getSubformula ( ) . asUntilFormula ( ) , result , currentObjective ) ;
preprocessUntil Formula ( formula . getSubformula ( ) . asUntilFormula ( ) , result , currentObjective ) ;
} else if ( formula . getSubformula ( ) . isBoundedUntilFormula ( ) ) {
preprocessFormula ( formula . getSubformula ( ) . asBoundedUntilFormula ( ) , result , currentObjective ) ;
preprocessBoundedUntil Formula ( formula . getSubformula ( ) . asBoundedUntilFormula ( ) , result , currentObjective ) ;
} else if ( formula . getSubformula ( ) . isGloballyFormula ( ) ) {
preprocessFormula ( formula . getSubformula ( ) . asGloballyFormula ( ) , result , currentObjective ) ;
preprocessGlobally Formula ( formula . getSubformula ( ) . asGloballyFormula ( ) , result , currentObjective ) ;
} else if ( formula . getSubformula ( ) . isEventuallyFormula ( ) ) {
preprocessFormula ( formula . getSubformula ( ) . asEventuallyFormula ( ) , result , currentObjective ) ;
preprocessEventually Formula ( formula . getSubformula ( ) . asEventuallyFormula ( ) , result , currentObjective ) ;
} else {
STORM_LOG_THROW ( false , storm : : exceptions : : InvalidPropertyException , " The subformula of " < < formula < < " is not supported. " ) ;
}
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : RewardOperatorFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessRewardOperator Formula ( storm : : logic : : RewardOperatorFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
// Check if the reward model is uniquely specified
STORM_LOG_THROW ( ( formula . hasRewardModelName ( ) & & result . preprocessedModel . hasRewardModel ( formula . getRewardModelName ( ) ) )
| | result . preprocessedModel . hasUniqueRewardModel ( ) , storm : : exceptions : : InvalidPropertyException , " The reward model is not unique and the formula " < < formula < < " does not specify a reward model. " ) ;
if ( formula . getSubformula ( ) . isEventuallyFormula ( ) ) {
preprocessFormula ( formula . getSubformula ( ) . asEventuallyFormula ( ) , result , currentObjective , formula . getOptionalRewardModelName ( ) ) ;
preprocessEventually Formula ( formula . getSubformula ( ) . asEventuallyFormula ( ) , result , currentObjective , formula . getOptionalRewardModelName ( ) ) ;
} else if ( formula . getSubformula ( ) . isCumulativeRewardFormula ( ) ) {
preprocessFormula ( formula . getSubformula ( ) . asCumulativeRewardFormula ( ) , result , currentObjective , formula . getOptionalRewardModelName ( ) ) ;
preprocessCumulativeReward Formula ( formula . getSubformula ( ) . asCumulativeRewardFormula ( ) , result , currentObjective , formula . getOptionalRewardModelName ( ) ) ;
} else if ( formula . getSubformula ( ) . isTotalRewardFormula ( ) ) {
preprocessFormula ( formula . getSubformula ( ) . as TotalRewardFormula ( ) , result , currentObjective , formula . getOptionalRewardModelName ( ) ) ;
preprocessTotalRewardFormula ( result , currentObjective , formula . getOptionalRewardModelName ( ) ) ;
} else {
STORM_LOG_THROW ( false , storm : : exceptions : : InvalidPropertyException , " The subformula of " < < formula < < " is not supported. " ) ;
}
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : TimeOperatorFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessTimeOperator Formula ( storm : : logic : : TimeOperatorFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
// Time formulas are only supported for Markov automata
STORM_LOG_THROW ( result . originalModel . isOfType ( storm : : models : : ModelType : : MarkovAutomaton ) , storm : : exceptions : : InvalidPropertyException , " Time operator formulas are only supported for Markov automata. " ) ;
if ( formula . getSubformula ( ) . isEventuallyFormula ( ) ) {
preprocessFormula ( formula . getSubformula ( ) . asEventuallyFormula ( ) , result , currentObjective ) ;
preprocessEventually Formula ( formula . getSubformula ( ) . asEventuallyFormula ( ) , result , currentObjective ) ;
} else {
STORM_LOG_THROW ( false , storm : : exceptions : : InvalidPropertyException , " The subformula of " < < formula < < " is not supported. " ) ;
}
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : UntilFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessUntil Formula ( storm : : logic : : UntilFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
CheckTask < storm : : logic : : Formula , ValueType > phiTask ( formula . getLeftSubformula ( ) ) ;
CheckTask < storm : : logic : : Formula , ValueType > psiTask ( formula . getRightSubformula ( ) ) ;
storm : : modelchecker : : SparsePropositionalModelChecker < SparseModelType > mc ( result . preprocessedModel ) ;
@ -223,7 +223,7 @@ namespace storm {
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : BoundedUntilFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessBoundedUntil Formula ( storm : : logic : : BoundedUntilFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
if ( formula . hasDiscreteTimeBound ( ) ) {
currentObjective . upperTimeBound = storm : : utility : : convertNumber < ValueType > ( formula . getDiscreteTimeBound ( ) ) ;
@ -240,11 +240,11 @@ namespace storm {
}
currentObjective . upperTimeBound = storm : : utility : : convertNumber < ValueType > ( formula . getIntervalBounds ( ) . second ) ;
}
preprocessFormula ( storm : : logic : : UntilFormula ( formula . getLeftSubformula ( ) . asSharedPointer ( ) , formula . getRightSubformula ( ) . asSharedPointer ( ) ) , result , currentObjective ) ;
preprocessUntil Formula ( storm : : logic : : UntilFormula ( formula . getLeftSubformula ( ) . asSharedPointer ( ) , formula . getRightSubformula ( ) . asSharedPointer ( ) ) , result , currentObjective ) ;
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : GloballyFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessGlobally Formula ( storm : : logic : : GloballyFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective ) {
// The formula will be transformed to an until formula for the complementary event.
// If the original formula minimizes, the complementary one will maximize and vice versa.
// Hence, the decision whether to consider positive or negative rewards flips.
@ -255,13 +255,13 @@ namespace storm {
auto negatedSubformula = std : : make_shared < storm : : logic : : UnaryBooleanStateFormula > ( storm : : logic : : UnaryBooleanStateFormula : : OperatorType : : Not , formula . getSubformula ( ) . asSharedPointer ( ) ) ;
preprocessFormula ( storm : : logic : : UntilFormula ( storm : : logic : : Formula : : getTrueFormula ( ) , negatedSubformula ) , result , currentObjective ) ;
preprocessUntil Formula ( storm : : logic : : UntilFormula ( storm : : logic : : Formula : : getTrueFormula ( ) , negatedSubformula ) , result , currentObjective ) ;
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : EventuallyFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective , boost : : optional < std : : string > const & optionalRewardModelName ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessEventually Formula ( storm : : logic : : EventuallyFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective , boost : : optional < std : : string > const & optionalRewardModelName ) {
if ( formula . isReachabilityProbabilityFormula ( ) ) {
preprocessFormula ( storm : : logic : : UntilFormula ( storm : : logic : : Formula : : getTrueFormula ( ) , formula . getSubformula ( ) . asSharedPointer ( ) ) , result , currentObjective ) ;
preprocessUntil Formula ( storm : : logic : : UntilFormula ( storm : : logic : : Formula : : getTrueFormula ( ) , formula . getSubformula ( ) . asSharedPointer ( ) ) , result , currentObjective ) ;
return ;
}
@ -304,7 +304,7 @@ namespace storm {
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : CumulativeRewardFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective , boost : : optional < std : : string > const & optionalRewardModelName ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessCumulativeReward Formula ( storm : : logic : : CumulativeRewardFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective , boost : : optional < std : : string > const & optionalRewardModelName ) {
STORM_LOG_THROW ( result . originalModel . isOfType ( storm : : models : : ModelType : : Mdp ) , storm : : exceptions : : InvalidPropertyException , " Cumulative reward formulas are not supported for the given model type. " ) ;
STORM_LOG_THROW ( formula . hasDiscreteTimeBound ( ) , storm : : exceptions : : InvalidPropertyException , " Expected a cumulativeRewardFormula with a discrete time bound but got " < < formula < < " . " ) ;
STORM_LOG_THROW ( formula . getDiscreteTimeBound ( ) > 0 , storm : : exceptions : : InvalidPropertyException , " Expected a cumulativeRewardFormula with a positive discrete time bound but got " < < formula < < " . " ) ;
@ -324,7 +324,7 @@ namespace storm {
}
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : preprocessFormula ( storm : : logic : : TotalRewardFormula const & formula , ReturnType & result , PcaaObjective < ValueType > & currentObjective , boost : : optional < std : : string > const & optionalRewardModelName ) {
void SparsePcaaPreprocessor < SparseModelType > : : preprocessTotalRewardFormula ( ReturnType & result , PcaaObjective < ValueType > & currentObjective , boost : : optional < std : : string > const & optionalRewardModelName ) {
RewardModelType objectiveRewards = result . preprocessedModel . getRewardModel ( optionalRewardModelName ? optionalRewardModelName . get ( ) : " " ) ;
objectiveRewards . reduceToStateBasedRewards ( result . preprocessedModel . getTransitionMatrix ( ) , false ) ;
if ( ! currentObjective . rewardsArePositive ) {
@ -341,7 +341,7 @@ namespace storm {
template < typename SparseModelType >
void SparsePcaaPreprocessor < SparseModelType > : : analyzeEndComponents ( ReturnType & result , storm : : storage : : SparseMatrix < ValueType > const & backwardTransitions ) {
result . ecActions = storm : : storage : : BitVector ( result . preprocessedModel . getNumberOfChoices ( ) , false ) ;
std : : vector < storm : : storage : : MaximalEndComponent > ecs ;
auto mecDecomposition = storm : : storage : : MaximalEndComponentDecomposition < ValueType > ( result . preprocessedModel . getTransitionMatrix ( ) , backwardTransitions ) ;