@ -17,7 +17,8 @@ namespace storm {
namespace storage {
namespace storage {
template < typename ValueType >
template < typename ValueType >
DFT < ValueType > : : DFT ( DFTElementVector const & elements , DFTElementPointer const & tle ) : mElements ( elements ) , mNrOfBEs ( 0 ) , mNrOfSpares ( 0 ) , mNrRepresentatives ( 0 ) , mTopLevelIndex ( tle - > id ( ) ) , mMaxSpareChildCount ( 0 ) {
DFT < ValueType > : : DFT ( DFTElementVector const & elements , DFTElementPointer const & tle ) : mElements ( elements ) , mNrOfBEs ( 0 ) , mNrOfSpares ( 0 ) , mNrRepresentatives ( 0 ) ,
mTopLevelIndex ( tle - > id ( ) ) , mMaxSpareChildCount ( 0 ) {
// Check that ids correspond to indices in the element vector
// Check that ids correspond to indices in the element vector
STORM_LOG_ASSERT ( elementIndicesCorrect ( ) , " Ids incorrect. " ) ;
STORM_LOG_ASSERT ( elementIndicesCorrect ( ) , " Ids incorrect. " ) ;
@ -32,7 +33,8 @@ namespace storm {
+ + mNrOfSpares ;
+ + mNrOfSpares ;
mMaxSpareChildCount = std : : max ( mMaxSpareChildCount , std : : static_pointer_cast < DFTSpare < ValueType > > ( elem ) - > children ( ) . size ( ) ) ;
mMaxSpareChildCount = std : : max ( mMaxSpareChildCount , std : : static_pointer_cast < DFTSpare < ValueType > > ( elem ) - > children ( ) . size ( ) ) ;
for ( auto const & spareReprs : std : : static_pointer_cast < DFTSpare < ValueType > > ( elem ) - > children ( ) ) {
for ( auto const & spareReprs : std : : static_pointer_cast < DFTSpare < ValueType > > ( elem ) - > children ( ) ) {
STORM_LOG_THROW ( spareReprs - > isGate ( ) | | spareReprs - > isBasicElement ( ) , storm : : exceptions : : WrongFormatException , " Child ' " < < spareReprs - > name ( ) < < " ' of spare ' " < < elem - > name ( ) < < " ' must be gate or BE. " ) ;
STORM_LOG_THROW ( spareReprs - > isGate ( ) | | spareReprs - > isBasicElement ( ) , storm : : exceptions : : WrongFormatException ,
" Child ' " < < spareReprs - > name ( ) < < " ' of spare ' " < < elem - > name ( ) < < " ' must be gate or BE. " ) ;
std : : set < size_t > module = { spareReprs - > id ( ) } ;
std : : set < size_t > module = { spareReprs - > id ( ) } ;
spareReprs - > extendSpareModule ( module ) ;
spareReprs - > extendSpareModule ( module ) ;
std : : vector < size_t > sparesAndBes ;
std : : vector < size_t > sparesAndBes ;
@ -72,7 +74,8 @@ namespace storm {
if ( ! mTopModule . empty ( ) ) {
if ( ! mTopModule . empty ( ) ) {
for ( auto & module : mSpareModules ) {
for ( auto & module : mSpareModules ) {
if ( std : : find ( module . second . begin ( ) , module . second . end ( ) , mTopModule . front ( ) ) ! = module . second . end ( ) ) {
if ( std : : find ( module . second . begin ( ) , module . second . end ( ) , mTopModule . front ( ) ) ! = module . second . end ( ) ) {
STORM_LOG_WARN ( " Elements of spare module ' " < < getElement ( module . first ) - > name ( ) < < " ' also contained in top module. All elements of this spare module will be activated from the beginning on. " ) ;
STORM_LOG_WARN ( " Elements of spare module ' " < < getElement ( module . first ) - > name ( )
< < " ' also contained in top module. All elements of this spare module will be activated from the beginning on. " ) ;
module . second . clear ( ) ;
module . second . clear ( ) ;
}
}
}
}
@ -179,7 +182,8 @@ namespace storm {
std : : shared_ptr < DFTDependency < ValueType > const > dependency = getDependency ( idDependency ) ;
std : : shared_ptr < DFTDependency < ValueType > const > dependency = getDependency ( idDependency ) ;
visitQueue . push ( dependency - > id ( ) ) ;
visitQueue . push ( dependency - > id ( ) ) ;
visitQueue . push ( dependency - > triggerEvent ( ) - > id ( ) ) ;
visitQueue . push ( dependency - > triggerEvent ( ) - > id ( ) ) ;
STORM_LOG_THROW ( dependency - > dependentEvents ( ) . size ( ) = = 1 , storm : : exceptions : : NotSupportedException , " Direct state generation does not support n-ary dependencies. Consider rewriting them by setting the binary dependency flag. " ) ;
STORM_LOG_THROW ( dependency - > dependentEvents ( ) . size ( ) = = 1 , storm : : exceptions : : NotSupportedException ,
" Direct state generation does not support n-ary dependencies. Consider rewriting them by setting the binary dependency flag. " ) ;
visitQueue . push ( dependency - > dependentEvents ( ) [ 0 ] - > id ( ) ) ;
visitQueue . push ( dependency - > dependentEvents ( ) [ 0 ] - > id ( ) ) ;
}
}
stateIndex = performStateGenerationInfoDFS ( generationInfo , visitQueue , visited , stateIndex ) ;
stateIndex = performStateGenerationInfoDFS ( generationInfo , visitQueue , visited , stateIndex ) ;
@ -225,7 +229,8 @@ namespace storm {
}
}
template < typename ValueType >
template < typename ValueType >
size_t DFT < ValueType > : : performStateGenerationInfoDFS ( DFTStateGenerationInfo & generationInfo , std : : queue < size_t > & visitQueue , storm : : storage : : BitVector & visited , size_t stateIndex ) const {
size_t DFT < ValueType > : : performStateGenerationInfoDFS ( DFTStateGenerationInfo & generationInfo , std : : queue < size_t > & visitQueue , storm : : storage : : BitVector & visited ,
size_t stateIndex ) const {
while ( ! visitQueue . empty ( ) ) {
while ( ! visitQueue . empty ( ) ) {
size_t id = visitQueue . front ( ) ;
size_t id = visitQueue . front ( ) ;
visitQueue . pop ( ) ;
visitQueue . pop ( ) ;
@ -338,7 +343,8 @@ namespace storm {
// Accumulate children names
// Accumulate children names
std : : vector < std : : string > childrenNames ;
std : : vector < std : : string > childrenNames ;
for ( size_t i = 1 ; i < rewrites . size ( ) ; + + i ) {
for ( size_t i = 1 ; i < rewrites . size ( ) ; + + i ) {
STORM_LOG_ASSERT ( mElements [ rewrites [ i ] ] - > parents ( ) . front ( ) - > id ( ) = = originalParent - > id ( ) , " Children have not the same father for rewrite " < < mElements [ rewrites [ i ] ] - > name ( ) ) ;
STORM_LOG_ASSERT ( mElements [ rewrites [ i ] ] - > parents ( ) . front ( ) - > id ( ) = = originalParent - > id ( ) ,
" Children have not the same father for rewrite " < < mElements [ rewrites [ i ] ] - > name ( ) ) ;
childrenNames . push_back ( mElements [ rewrites [ i ] ] - > name ( ) ) ;
childrenNames . push_back ( mElements [ rewrites [ i ] ] - > name ( ) ) ;
}
}
@ -621,6 +627,7 @@ namespace storm {
}
}
}
}
// TODO check VOT gates
// TODO check VOT gates
// TODO check only one constant failed event
return wellformed ;
return wellformed ;
}
}
@ -744,7 +751,8 @@ namespace storm {
}
}
template < typename ValueType >
template < typename ValueType >
void DFT < ValueType > : : findSymmetriesHelper ( std : : vector < size_t > const & candidates , DFTColouring < ValueType > const & colouring , std : : map < size_t , std : : vector < std : : vector < size_t > > > & result ) const {
void DFT < ValueType > : : findSymmetriesHelper ( std : : vector < size_t > const & candidates , DFTColouring < ValueType > const & colouring ,
std : : map < size_t , std : : vector < std : : vector < size_t > > > & result ) const {
if ( candidates . size ( ) < = 0 ) {
if ( candidates . size ( ) < = 0 ) {
return ;
return ;
}
}
@ -807,7 +815,8 @@ namespace storm {
std : : vector < size_t > rewrite = { e - > id ( ) , child - > id ( ) } ;
std : : vector < size_t > rewrite = { e - > id ( ) , child - > id ( ) } ;
for ( size_t isdElemId : ISD ) {
for ( size_t isdElemId : ISD ) {
if ( isdElemId = = child - > id ( ) ) continue ;
if ( isdElemId = = child - > id ( ) ) continue ;
if ( std : : find_if ( children . begin ( ) , children . end ( ) , [ & isdElemId ] ( std : : shared_ptr < DFTElement < ValueType > > const & e ) { return e - > id ( ) = = isdElemId ; } ) ! = children . end ( ) ) {
if ( std : : find_if ( children . begin ( ) , children . end ( ) , [ & isdElemId ] ( std : : shared_ptr < DFTElement < ValueType > > const & e ) { return e - > id ( ) = = isdElemId ; } ) ! =
children . end ( ) ) {
// element in subtree is also child
// element in subtree is also child
rewrite . push_back ( isdElemId ) ;
rewrite . push_back ( isdElemId ) ;
}
}
@ -863,10 +872,12 @@ namespace storm {
template < typename ValueType >
template < typename ValueType >
void DFT < ValueType > : : setRelevantEvents ( std : : set < size_t > const & relevantEvents , bool allowDCForRelevantEvents ) const {
void DFT < ValueType > : : setRelevantEvents ( std : : set < size_t > const & relevantEvents , bool allowDCForRelevantEvents ) const {
mRelevantEvents . clear ( ) ;
for ( auto const & elem : mElements ) {
for ( auto const & elem : mElements ) {
if ( relevantEvents . find ( elem - > id ( ) ) ! = relevantEvents . end ( ) ) {
if ( relevantEvents . find ( elem - > id ( ) ) ! = relevantEvents . end ( ) ) {
elem - > setRelevance ( true ) ;
elem - > setRelevance ( true ) ;
elem - > setAllowDC ( allowDCForRelevantEvents ) ;
elem - > setAllowDC ( allowDCForRelevantEvents ) ;
mRelevantEvents . insert ( elem - > id ( ) ) ;
} else {
} else {
elem - > setRelevance ( false ) ;
elem - > setRelevance ( false ) ;
elem - > setAllowDC ( true ) ;
elem - > setAllowDC ( true ) ;
@ -876,29 +887,20 @@ namespace storm {
template < typename ValueType >
template < typename ValueType >
std : : set < size_t > DFT < ValueType > : : getRelevantEvents ( ) const {
std : : set < size_t > DFT < ValueType > : : getRelevantEvents ( ) const {
std : : set < size_t > relevantEvents ;
for ( auto const & elem : mElements ) {
if ( elem - > isRelevant ( ) ) {
relevantEvents . insert ( elem - > id ( ) ) ;
}
return mRelevantEvents ;
}
}
return relevantEvents ;
}
template < typename ValueType >
template < typename ValueType >
std : : string DFT < ValueType > : : getRelevantEventsString ( ) const {
std : : string DFT < ValueType > : : getRelevantEventsString ( ) const {
std : : stringstream stream ;
std : : stringstream stream ;
bool first = true ;
bool first = true ;
for ( auto const & elem : mElements ) {
if ( elem - > isRelevant ( ) ) {
for ( size_t relevant_id : getRelevantEvents ( ) ) {
if ( first ) {
if ( first ) {
first = false ;
first = false ;
} else {
} else {
stream < < " , " ;
stream < < " , " ;
}
}
stream < < elem - > name ( ) < < " [ " < < elem - > id ( ) < < " ] " ;
}
stream < < getElement ( relevant_id ) - > name ( ) < < " [ " < < relevant_id < < " ] " ;
}
}
return stream . str ( ) ;
return stream . str ( ) ;
}
}
@ -1000,10 +1002,14 @@ namespace storm {
}
}
// Explicitly instantiate the class.
// Explicitly instantiate the class.
template class DFT < double > ;
template
class DFT < double > ;
# ifdef STORM_HAVE_CARL
# ifdef STORM_HAVE_CARL
template class DFT < RationalFunction > ;
template
class DFT < RationalFunction > ;
# endif
# endif
}
}