@ -13,20 +13,20 @@ namespace storm {
Scheduler < ValueType > : : Scheduler ( uint_fast64_t numberOfModelStates , boost : : optional < storm : : storage : : MemoryStructure > const & memoryStructure ) : memoryStructure ( memoryStructure ) {
uint_fast64_t numOfMemoryStates = memoryStructure ? memoryStructure - > getNumberOfStates ( ) : 1 ;
schedulerChoices = std : : vector < std : : vector < SchedulerChoice < ValueType > > > ( numOfMemoryStates , std : : vector < SchedulerChoice < ValueType > > ( numberOfModelStates ) ) ;
reachabl eStates = std : : vector < storm : : storage : : BitVector > ( numOfMemoryStates , storm : : storage : : BitVector ( numberOfModelStates , tru e) ) ;
dontCa reStates = std : : vector < storm : : storage : : BitVector > ( numOfMemoryStates , storm : : storage : : BitVector ( numberOfModelStates , fals e) ) ;
numOfUndefinedChoices = numOfMemoryStates * numberOfModelStates ;
numOfDeterministicChoices = 0 ;
numOfUnreachabl eStates = 0 ;
numOfDontCar eStates = 0 ;
}
template < typename ValueType >
Scheduler < ValueType > : : Scheduler ( uint_fast64_t numberOfModelStates , boost : : optional < storm : : storage : : MemoryStructure > & & memoryStructure ) : memoryStructure ( std : : move ( memoryStructure ) ) {
uint_fast64_t numOfMemoryStates = this - > memoryStructure ? this - > memoryStructure - > getNumberOfStates ( ) : 1 ;
schedulerChoices = std : : vector < std : : vector < SchedulerChoice < ValueType > > > ( numOfMemoryStates , std : : vector < SchedulerChoice < ValueType > > ( numberOfModelStates ) ) ;
reachabl eStates = std : : vector < storm : : storage : : BitVector > ( numOfMemoryStates , storm : : storage : : BitVector ( numberOfModelStates , tru e) ) ;
dontCa reStates = std : : vector < storm : : storage : : BitVector > ( numOfMemoryStates , storm : : storage : : BitVector ( numberOfModelStates , fals e) ) ;
numOfUndefinedChoices = numOfMemoryStates * numberOfModelStates ;
numOfDeterministicChoices = 0 ;
numOfUnreachabl eStates = 0 ;
numOfDontCar eStates = 0 ;
}
template < typename ValueType >
@ -35,7 +35,7 @@ namespace storm {
STORM_LOG_ASSERT ( modelState < schedulerChoices [ memoryState ] . size ( ) , " Illegal model state index " ) ;
auto & schedulerChoice = schedulerChoices [ memoryState ] [ modelState ] ;
if ( reachabl eStates[ memoryState ] . get ( modelState ) ) {
if ( ! dontCar eStates[ memoryState ] . get ( modelState ) ) {
if ( schedulerChoice . isDefined ( ) ) {
if ( ! choice . isDefined ( ) ) {
+ + numOfUndefinedChoices ;
@ -87,13 +87,13 @@ namespace storm {
}
template < typename ValueType >
void Scheduler < ValueType > : : setStateUnreachabl e ( uint_fast64_t modelState , uint_fast64_t memoryState ) {
void Scheduler < ValueType > : : setDontCar e ( uint_fast64_t modelState , uint_fast64_t memoryState ) {
STORM_LOG_ASSERT ( memoryState < getNumberOfMemoryStates ( ) , " Illegal memory state index " ) ;
STORM_LOG_ASSERT ( modelState < schedulerChoices [ memoryState ] . size ( ) , " Illegal model state index " ) ;
auto & schedulerChoice = schedulerChoices [ memoryState ] [ modelState ] ;
if ( reachabl eStates[ memoryState ] . get ( modelState ) ) {
reachabl eStates [ memoryState ] . set ( modelState , fals e) ;
+ + numOfUnreachabl eStates ;
if ( ! dontCar eStates[ memoryState ] . get ( modelState ) ) {
dontCa reStates[ memoryState ] . set ( modelState , tru e) ;
+ + numOfDontCar eStates ;
// Choices for unreachable states are not considered undefined or deterministic
if ( ! schedulerChoice . isDefined ( ) ) {
@ -106,27 +106,8 @@ namespace storm {
}
template < typename ValueType >
void Scheduler < ValueType > : : setStateReachable ( uint_fast64_t modelState , uint_fast64_t memoryState ) {
STORM_LOG_ASSERT ( memoryState < getNumberOfMemoryStates ( ) , " Illegal memory state index " ) ;
STORM_LOG_ASSERT ( modelState < schedulerChoices [ memoryState ] . size ( ) , " Illegal model state index " ) ;
auto & schedulerChoice = schedulerChoices [ memoryState ] [ modelState ] ;
if ( ! reachableStates [ memoryState ] . get ( modelState ) ) {
reachableStates [ memoryState ] . set ( modelState , true ) ;
- - numOfUnreachableStates ;
// Choices for unreachable states are not considered undefined or deterministic
if ( ! schedulerChoice . isDefined ( ) ) {
+ + numOfUndefinedChoices ;
} else if ( schedulerChoice . isDeterministic ( ) ) {
+ + numOfDeterministicChoices ;
}
}
}
template < typename ValueType >
bool Scheduler < ValueType > : : isStateReachable ( uint_fast64_t modelState , uint64_t memoryState ) const {
return reachableStates [ memoryState ] . get ( modelState ) ;
bool Scheduler < ValueType > : : isDontCare ( uint_fast64_t modelState , uint64_t memoryState ) const {
return dontCareStates [ memoryState ] . get ( modelState ) ;
}
template < typename ValueType >
@ -154,7 +135,7 @@ namespace storm {
template < typename ValueType >
bool Scheduler < ValueType > : : isDeterministicScheduler ( ) const {
return numOfDeterministicChoices = = ( schedulerChoices . size ( ) * schedulerChoices . begin ( ) - > size ( ) ) - numOfUndefinedChoices - numOfUnreachabl eStates ;
return numOfDeterministicChoices = = ( schedulerChoices . size ( ) * schedulerChoices . begin ( ) - > size ( ) ) - numOfUndefinedChoices - numOfDontCar eStates ;
}
template < typename ValueType >
@ -174,7 +155,6 @@ namespace storm {
template < typename ValueType >
void Scheduler < ValueType > : : printToStream ( std : : ostream & out , std : : shared_ptr < storm : : models : : sparse : : Model < ValueType > > model , bool skipUniqueChoices ) const {
// TODO ignore unreachable states
STORM_LOG_THROW ( model = = nullptr | | model - > getNumberOfStates ( ) = = schedulerChoices . front ( ) . size ( ) , storm : : exceptions : : InvalidOperationException , " The given model is not compatible with this scheduler. " ) ;
bool const stateValuationsGiven = model ! = nullptr & & model - > hasStateValuations ( ) ;
@ -267,9 +247,8 @@ namespace storm {
}
// Print memory updates
if ( ! isMemorylessScheduler ( ) ) {
stateString < < std : : setw ( 30 ) ; //todo set width
out < < std : : setw ( 8 ) ;
for ( auto const & choiceProbPair : choice . getChoiceAsDistribution ( ) ) {
uint64_t row = model - > getTransitionMatrix ( ) . getRowGroupIndices ( ) [ state ] + choiceProbPair . first ;
bool firstUpdate = true ;
@ -282,7 +261,6 @@ namespace storm {
stateString < < " model state' = " < < entryIt - > getColumn ( ) < < " : (transition = " < < entryIt - model - > getTransitionMatrix ( ) . begin ( ) < < " ) -> " < < " (m' = " < < this - > memoryStructure - > getSuccessorMemoryState ( memoryState , entryIt - model - > getTransitionMatrix ( ) . begin ( ) ) < < " ) " ;
//out << ", model state' = " << entryIt->getColumn() << ": (transition = " << entryIt - model->getTransitionMatrix().begin() << ") -> " << "(m' = ?) ";
}
}
stateString < < std : : endl ;