@ -11,30 +11,30 @@
namespace storm {
namespace storm {
namespace generator {
namespace generator {
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
Choice < ValueType , StateType > : : Choice ( uint_fast64_t actionIndex , bool markovian ) : markovian ( markovian ) , actionIndex ( actionIndex ) , distribution ( ) , totalMass ( storm : : utility : : zero < ValueType > ( ) ) , rewards ( ) , labels ( ) {
Choice < ValueType , StateType > : : Choice ( uint_fast64_t actionIndex , bool markovian ) : markovian ( markovian ) , actionIndex ( actionIndex ) , distribution ( ) , totalMass ( storm : : utility : : zero < ValueType > ( ) ) , rewards ( ) , labels ( ) {
// Intentionally left empty.
// Intentionally left empty.
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
void Choice < ValueType , StateType > : : add ( Choice const & other ) {
void Choice < ValueType , StateType > : : add ( Choice const & other ) {
STORM_LOG_THROW ( this - > markovian = = other . markovian , storm : : exceptions : : InvalidOperationException , " Type of choices do not match. " ) ;
STORM_LOG_THROW ( this - > markovian = = other . markovian , storm : : exceptions : : InvalidOperationException , " Type of choices do not match. " ) ;
STORM_LOG_THROW ( this - > actionIndex = = other . actionIndex , storm : : exceptions : : InvalidOperationException , " Action index of choices do not match. " ) ;
STORM_LOG_THROW ( this - > actionIndex = = other . actionIndex , storm : : exceptions : : InvalidOperationException , " Action index of choices do not match. " ) ;
STORM_LOG_THROW ( this - > rewards . size ( ) = = other . rewards . size ( ) , storm : : exceptions : : InvalidOperationException , " Reward value sizes of choices do not match. " ) ;
STORM_LOG_THROW ( this - > rewards . size ( ) = = other . rewards . size ( ) , storm : : exceptions : : InvalidOperationException , " Reward value sizes of choices do not match. " ) ;
// Add the elements to the distribution.
// Add the elements to the distribution.
this - > distribution . add ( other . distribution ) ;
this - > distribution . add ( other . distribution ) ;
// Update the total mass of the choice.
// Update the total mass of the choice.
this - > totalMass + = other . totalMass ;
this - > totalMass + = other . totalMass ;
// Add all reward values.
// Add all reward values.
auto otherRewIt = other . rewards . begin ( ) ;
auto otherRewIt = other . rewards . begin ( ) ;
for ( auto & rewardValue : this - > rewards ) {
for ( auto & rewardValue : this - > rewards ) {
rewardValue + = * otherRewIt ;
rewardValue + = * otherRewIt ;
}
}
// Join label sets and origin data if given.
// Join label sets and origin data if given.
if ( other . labels ) {
if ( other . labels ) {
this - > addLabels ( other . labels . get ( ) ) ;
this - > addLabels ( other . labels . get ( ) ) ;
@ -43,27 +43,27 @@ namespace storm {
this - > addOriginData ( other . originData . get ( ) ) ;
this - > addOriginData ( other . originData . get ( ) ) ;
}
}
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
typename storm : : storage : : Distribution < ValueType , StateType > : : iterator Choice < ValueType , StateType > : : begin ( ) {
typename storm : : storage : : Distribution < ValueType , StateType > : : iterator Choice < ValueType , StateType > : : begin ( ) {
return distribution . begin ( ) ;
return distribution . begin ( ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
typename storm : : storage : : Distribution < ValueType , StateType > : : const_iterator Choice < ValueType , StateType > : : begin ( ) const {
typename storm : : storage : : Distribution < ValueType , StateType > : : const_iterator Choice < ValueType , StateType > : : begin ( ) const {
return distribution . cbegin ( ) ;
return distribution . cbegin ( ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
typename storm : : storage : : Distribution < ValueType , StateType > : : iterator Choice < ValueType , StateType > : : end ( ) {
typename storm : : storage : : Distribution < ValueType , StateType > : : iterator Choice < ValueType , StateType > : : end ( ) {
return distribution . end ( ) ;
return distribution . end ( ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
typename storm : : storage : : Distribution < ValueType , StateType > : : const_iterator Choice < ValueType , StateType > : : end ( ) const {
typename storm : : storage : : Distribution < ValueType , StateType > : : const_iterator Choice < ValueType , StateType > : : end ( ) const {
return distribution . cend ( ) ;
return distribution . cend ( ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
void Choice < ValueType , StateType > : : addLabel ( std : : string const & newLabel ) {
void Choice < ValueType , StateType > : : addLabel ( std : : string const & newLabel ) {
if ( ! labels ) {
if ( ! labels ) {
@ -71,7 +71,7 @@ namespace storm {
}
}
labels - > insert ( newLabel ) ;
labels - > insert ( newLabel ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
void Choice < ValueType , StateType > : : addLabels ( std : : set < std : : string > const & newLabels ) {
void Choice < ValueType , StateType > : : addLabels ( std : : set < std : : string > const & newLabels ) {
if ( labels ) {
if ( labels ) {
@ -97,8 +97,8 @@ namespace storm {
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
bool Choice < ValueType , StateType > : : hasPlayerIndex ( ) const {
return playerIndex . is_initialized ( ) ;
bool Choice < ValueType , StateType > : : hasPlayer ( ) const {
return player . is_initialized ( ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
@ -113,7 +113,7 @@ namespace storm {
} else {
} else {
if ( ! data . empty ( ) ) {
if ( ! data . empty ( ) ) {
// Reaching this point means that the both the existing and the given data are non-empty
// Reaching this point means that the both the existing and the given data are non-empty
auto existingDataAsIndexSet = boost : : any_cast < storm : : storage : : FlatSet < uint_fast64_t > > ( & this - > originData . get ( ) ) ;
auto existingDataAsIndexSet = boost : : any_cast < storm : : storage : : FlatSet < uint_fast64_t > > ( & this - > originData . get ( ) ) ;
if ( existingDataAsIndexSet ! = nullptr ) {
if ( existingDataAsIndexSet ! = nullptr ) {
auto givenDataAsIndexSet = boost : : any_cast < storm : : storage : : FlatSet < uint_fast64_t > > ( & data ) ;
auto givenDataAsIndexSet = boost : : any_cast < storm : : storage : : FlatSet < uint_fast64_t > > ( & data ) ;
@ -125,63 +125,63 @@ namespace storm {
}
}
}
}
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
bool Choice < ValueType , StateType > : : hasOriginData ( ) const {
bool Choice < ValueType , StateType > : : hasOriginData ( ) const {
return originData . is_initialized ( ) ;
return originData . is_initialized ( ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
boost : : any const & Choice < ValueType , StateType > : : getOriginData ( ) const {
boost : : any const & Choice < ValueType , StateType > : : getOriginData ( ) const {
return originData . get ( ) ;
return originData . get ( ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
uint_fast64_t Choice < ValueType , StateType > : : getActionIndex ( ) const {
uint_fast64_t Choice < ValueType , StateType > : : getActionIndex ( ) const {
return actionIndex ;
return actionIndex ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
ValueType Choice < ValueType , StateType > : : getTotalMass ( ) const {
ValueType Choice < ValueType , StateType > : : getTotalMass ( ) const {
return totalMass ;
return totalMass ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
void Choice < ValueType , StateType > : : addProbability ( StateType const & state , ValueType const & value ) {
void Choice < ValueType , StateType > : : addProbability ( StateType const & state , ValueType const & value ) {
totalMass + = value ;
totalMass + = value ;
distribution . addProbability ( state , value ) ;
distribution . addProbability ( state , value ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
void Choice < ValueType , StateType > : : addReward ( ValueType const & value ) {
void Choice < ValueType , StateType > : : addReward ( ValueType const & value ) {
rewards . push_back ( value ) ;
rewards . push_back ( value ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
void Choice < ValueType , StateType > : : addRewards ( std : : vector < ValueType > & & values ) {
void Choice < ValueType , StateType > : : addRewards ( std : : vector < ValueType > & & values ) {
this - > rewards = std : : move ( values ) ;
this - > rewards = std : : move ( values ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
std : : vector < ValueType > const & Choice < ValueType , StateType > : : getRewards ( ) const {
std : : vector < ValueType > const & Choice < ValueType , StateType > : : getRewards ( ) const {
return rewards ;
return rewards ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
bool Choice < ValueType , StateType > : : isMarkovian ( ) const {
bool Choice < ValueType , StateType > : : isMarkovian ( ) const {
return markovian ;
return markovian ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
std : : size_t Choice < ValueType , StateType > : : size ( ) const {
std : : size_t Choice < ValueType , StateType > : : size ( ) const {
return distribution . size ( ) ;
return distribution . size ( ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
void Choice < ValueType , StateType > : : reserve ( std : : size_t const & size ) {
void Choice < ValueType , StateType > : : reserve ( std : : size_t const & size ) {
distribution . reserve ( size ) ;
distribution . reserve ( size ) ;
}
}
template < typename ValueType , typename StateType >
template < typename ValueType , typename StateType >
std : : ostream & operator < < ( std : : ostream & out , Choice < ValueType , StateType > const & choice ) {
std : : ostream & operator < < ( std : : ostream & out , Choice < ValueType , StateType > const & choice ) {
out < < " < " ;
out < < " < " ;
@ -191,7 +191,7 @@ namespace storm {
out < < " > " ;
out < < " > " ;
return out ;
return out ;
}
}
template struct Choice < double > ;
template struct Choice < double > ;
# ifdef STORM_HAVE_CARL
# ifdef STORM_HAVE_CARL