@ -82,34 +82,12 @@ namespace storm {
return result ;
}
template < typename ValueType >
std : : map < storm : : storage : : sparse : : state_type , ValueType > SparseMdpPrctlHelper < ValueType > : : computeRewardBoundedValues ( SolutionType const & type , OptimizationDirection dir , storm : : modelchecker : : multiobjective : : MultiDimensionalRewardUnfolding < ValueType , true > & rewardUnfolding , storm : : storage : : BitVector const & initialStates , storm : : solver : : MinMaxLinearEquationSolverFactory < ValueType > const & minMaxLinearEquationSolverFactory ) {
storm : : utility : : Stopwatch swAll ( true ) , swBuild , swCheck ;
auto initEpoch = rewardUnfolding . getStartEpoch ( ) ;
auto epochOrder = rewardUnfolding . getEpochComputationOrder ( initEpoch ) ;
// initialize data that will be needed for each epoch
std : : vector < ValueType > x , b ;
std : : unique_ptr < storm : : solver : : MinMaxLinearEquationSolver < ValueType > > minMaxSolver ;
template < typename ValueType >
std : : vector < ValueType > analyzeTrivialEpochModel ( OptimizationDirection dir , typename storm : : modelchecker : : multiobjective : : MultiDimensionalRewardUnfolding < ValueType , true > : : EpochModel & epochModel ) {
// Assert that the epoch model is indeed trivial
assert ( epochModel . epochMatrix . getEntryCount ( ) = = 0 ) ;
ValueType precision = storm : : utility : : convertNumber < ValueType > ( storm : : settings : : getModule < storm : : settings : : modules : : GeneralSettings > ( ) . getPrecision ( ) ) ;
uint64_t epochCount = 0 ;
for ( uint64_t dim = 0 ; dim < rewardUnfolding . getEpochManager ( ) . getDimensionCount ( ) ; + + dim ) {
epochCount + = rewardUnfolding . getEpochManager ( ) . getDimensionOfEpoch ( initEpoch , dim ) + 1 ;
}
if ( storm : : settings : : getModule < storm : : settings : : modules : : GeneralSettings > ( ) . isSoundSet ( ) ) {
precision = precision / storm : : utility : : convertNumber < ValueType > ( epochCount ) ;
}
storm : : utility : : ProgressMeasurement progress ( " epochs " ) ;
progress . setMaxCount ( epochOrder . size ( ) ) ;
progress . startNewMeasurement ( 0 ) ;
uint64_t numCheckedEpochs = 0 ;
for ( auto const & epoch : epochOrder ) {
swBuild . start ( ) ;
auto & epochModel = rewardUnfolding . setCurrentEpoch ( epoch ) ;
swBuild . stop ( ) ; swCheck . start ( ) ;
// If the epoch matrix is empty we do not need to solve a linear equation system
if ( epochModel . epochMatrix . getEntryCount ( ) = = 0 ) {
std : : vector < ValueType > epochResult ;
epochResult . reserve ( epochModel . epochInStates . getNumberOfSetBits ( ) ) ;
@ -152,9 +130,12 @@ namespace storm {
// Insert the solution w.r.t. this choice
epochResult . push_back ( std : : move ( bestValue ) ) ;
}
return epochResult ;
}
template < typename ValueType >
std : : vector < ValueType > analyzeNonTrivialEpochModel ( OptimizationDirection dir , typename storm : : modelchecker : : multiobjective : : MultiDimensionalRewardUnfolding < ValueType , true > : : EpochModel & epochModel , std : : vector < ValueType > & x , std : : vector < ValueType > & b , std : : unique_ptr < storm : : solver : : MinMaxLinearEquationSolver < ValueType > > & minMaxSolver , storm : : solver : : MinMaxLinearEquationSolverFactory < ValueType > const & minMaxLinearEquationSolverFactory , ValueType const & precision , SolutionType const & type ) {
rewardUnfolding . setSolutionForCurrentEpoch ( std : : move ( epochResult ) ) ;
} else {
// Update some data for the case that the Matrix has changed
if ( epochModel . epochMatrixChanged ) {
x . assign ( epochModel . epochMatrix . getRowGroupCount ( ) , storm : : utility : : zero < ValueType > ( ) ) ;
@ -197,8 +178,34 @@ namespace storm {
// Solve the minMax equation system
minMaxSolver - > solveEquations ( x , b ) ;
// Plug in the result into the reward unfolding
rewardUnfolding . setSolutionForCurrentEpoch ( storm : : utility : : vector : : filterVector ( x , epochModel . epochInStates ) ) ;
return storm : : utility : : vector : : filterVector ( x , epochModel . epochInStates ) ;
}
template < typename ValueType >
std : : map < storm : : storage : : sparse : : state_type , ValueType > SparseMdpPrctlHelper < ValueType > : : computeRewardBoundedValues ( SolutionType const & type , OptimizationDirection dir , storm : : modelchecker : : multiobjective : : MultiDimensionalRewardUnfolding < ValueType , true > & rewardUnfolding , storm : : storage : : BitVector const & initialStates , storm : : solver : : MinMaxLinearEquationSolverFactory < ValueType > const & minMaxLinearEquationSolverFactory ) {
storm : : utility : : Stopwatch swAll ( true ) , swBuild , swCheck ;
auto initEpoch = rewardUnfolding . getStartEpoch ( ) ;
auto epochOrder = rewardUnfolding . getEpochComputationOrder ( initEpoch ) ;
// initialize data that will be needed for each epoch
std : : vector < ValueType > x , b ;
std : : unique_ptr < storm : : solver : : MinMaxLinearEquationSolver < ValueType > > minMaxSolver ;
ValueType precision = rewardUnfolding . getRequiredEpochModelPrecision ( initEpoch , storm : : utility : : convertNumber < ValueType > ( storm : : settings : : getModule < storm : : settings : : modules : : GeneralSettings > ( ) . getPrecision ( ) ) ) ;
storm : : utility : : ProgressMeasurement progress ( " epochs " ) ;
progress . setMaxCount ( epochOrder . size ( ) ) ;
progress . startNewMeasurement ( 0 ) ;
uint64_t numCheckedEpochs = 0 ;
for ( auto const & epoch : epochOrder ) {
swBuild . start ( ) ;
auto & epochModel = rewardUnfolding . setCurrentEpoch ( epoch ) ;
swBuild . stop ( ) ; swCheck . start ( ) ;
// If the epoch matrix is empty we do not need to solve a linear equation system
if ( epochModel . epochMatrix . getEntryCount ( ) = = 0 ) {
rewardUnfolding . setSolutionForCurrentEpoch ( analyzeTrivialEpochModel < ValueType > ( dir , epochModel ) ) ;
} else {
rewardUnfolding . setSolutionForCurrentEpoch ( analyzeNonTrivialEpochModel < ValueType > ( dir , epochModel , x , b , minMaxSolver , minMaxLinearEquationSolverFactory , precision , type ) ) ;
}
swCheck . stop ( ) ;
+ + numCheckedEpochs ;