@ -15,7 +15,7 @@ namespace storm {
storm : : models : : sparse : : StateLabeling const & stateLabeling ,
storm : : models : : sparse : : StateLabeling const & stateLabeling ,
std : : unordered_map < std : : string , RewardModelType > const & rewardModels ,
std : : unordered_map < std : : string , RewardModelType > const & rewardModels ,
boost : : optional < std : : vector < LabelSet > > const & optionalChoiceLabeling )
boost : : optional < std : : vector < LabelSet > > const & optionalChoiceLabeling )
: NondeterministicModel < ValueType > ( storm : : models : : ModelType : : Mdp , transitionMatrix , stateLabeling , rewardModels , optionalChoiceLabeling ) {
: NondeterministicModel < ValueType , RewardModelType > ( storm : : models : : ModelType : : Mdp , transitionMatrix , stateLabeling , rewardModels , optionalChoiceLabeling ) {
STORM_LOG_THROW ( transitionMatrix . isProbabilistic ( ) , storm : : exceptions : : InvalidArgumentException , " The probability matrix is invalid. " ) ;
STORM_LOG_THROW ( transitionMatrix . isProbabilistic ( ) , storm : : exceptions : : InvalidArgumentException , " The probability matrix is invalid. " ) ;
}
}
@ -25,12 +25,12 @@ namespace storm {
storm : : models : : sparse : : StateLabeling & & stateLabeling ,
storm : : models : : sparse : : StateLabeling & & stateLabeling ,
std : : unordered_map < std : : string , RewardModelType > & & rewardModels ,
std : : unordered_map < std : : string , RewardModelType > & & rewardModels ,
boost : : optional < std : : vector < LabelSet > > & & optionalChoiceLabeling )
boost : : optional < std : : vector < LabelSet > > & & optionalChoiceLabeling )
: NondeterministicModel < ValueType > ( storm : : models : : ModelType : : Mdp , std : : move ( transitionMatrix ) , std : : move ( stateLabeling ) , std : : move ( rewardModels ) , std : : move ( optionalChoiceLabeling ) ) {
: NondeterministicModel < ValueType , RewardModelType > ( storm : : models : : ModelType : : Mdp , std : : move ( transitionMatrix ) , std : : move ( stateLabeling ) , std : : move ( rewardModels ) , std : : move ( optionalChoiceLabeling ) ) {
STORM_LOG_THROW ( transitionMatrix . isProbabilistic ( ) , storm : : exceptions : : InvalidArgumentException , " The probability matrix is invalid. " ) ;
STORM_LOG_THROW ( transitionMatrix . isProbabilistic ( ) , storm : : exceptions : : InvalidArgumentException , " The probability matrix is invalid. " ) ;
}
}
template < typename ValueType , typename RewardModelType >
template < typename ValueType , typename RewardModelType >
Mdp < ValueType > Mdp < ValueType , RewardModelType > : : restrictChoiceLabels ( LabelSet const & enabledChoiceLabels ) const {
Mdp < ValueType , RewardModelType > Mdp < ValueType , RewardModelType > : : restrictChoiceLabels ( LabelSet const & enabledChoiceLabels ) const {
STORM_LOG_THROW ( this - > hasChoiceLabeling ( ) , storm : : exceptions : : InvalidArgumentException , " Restriction to label set is impossible for unlabeled model. " ) ;
STORM_LOG_THROW ( this - > hasChoiceLabeling ( ) , storm : : exceptions : : InvalidArgumentException , " Restriction to label set is impossible for unlabeled model. " ) ;
std : : vector < LabelSet > const & choiceLabeling = this - > getChoiceLabeling ( ) ;
std : : vector < LabelSet > const & choiceLabeling = this - > getChoiceLabeling ( ) ;
@ -68,26 +68,28 @@ namespace storm {
}
}
}
}
Mdp < ValueType > restrictedMdp ( transitionMatrixBuilder . build ( ) , storm : : models : : sparse : : StateLabeling ( this - > getStateLabeling ( ) ) ,
Mdp < ValueType , RewardModelType > restrictedMdp ( transitionMatrixBuilder . build ( ) , storm : : models : : sparse : : StateLabeling ( this - > getStateLabeling ( ) ) ,
std : : unordered_map < std : : string , RewardModelType > ( this - > getRewardModels ( ) ) , boost : : optional < std : : vector < LabelSet > > ( newChoiceLabeling ) ) ;
std : : unordered_map < std : : string , RewardModelType > ( this - > getRewardModels ( ) ) , boost : : optional < std : : vector < LabelSet > > ( newChoiceLabeling ) ) ;
return restrictedMdp ;
return restrictedMdp ;
}
}
template < typename ValueType , typename RewardModelType >
template < typename ValueType , typename RewardModelType >
Mdp < ValueType > Mdp < ValueType , RewardModelType > : : restrictActions ( storm : : storage : : BitVector const & enabledActions ) const {
Mdp < ValueType , RewardModelType > Mdp < ValueType , RewardModelType > : : restrictActions ( storm : : storage : : BitVector const & enabledActions ) const {
storm : : storage : : SparseMatrix < ValueType > restrictedTransitions = this - > getTransitionMatrix ( ) . restrictRows ( enabledActions ) ;
storm : : storage : : SparseMatrix < ValueType > restrictedTransitions = this - > getTransitionMatrix ( ) . restrictRows ( enabledActions ) ;
std : : unordered_map < std : : string , RewardModelType > newRewardModels ;
std : : unordered_map < std : : string , RewardModelType > newRewardModels ;
for ( auto const & rewardModel : this - > getRewardModels ( ) ) {
for ( auto const & rewardModel : this - > getRewardModels ( ) ) {
newRewardModels . emplace ( rewardModel . first , rewardModel . second . restrictActions ( enabledActions ) ) ;
newRewardModels . emplace ( rewardModel . first , rewardModel . second . restrictActions ( enabledActions ) ) ;
}
}
return Mdp < ValueType > ( restrictedTransitions , this - > getStateLabeling ( ) , newRewardModels , this - > getOptionalChoiceLabeling ( ) ) ;
return Mdp < ValueType , RewardModelType > ( restrictedTransitions , this - > getStateLabeling ( ) , newRewardModels , this - > getOptionalChoiceLabeling ( ) ) ;
}
}
template class Mdp < double > ;
template class Mdp < double > ;
template class Mdp < float > ;
template class Mdp < float > ;
# ifdef STORM_HAVE_CARL
# ifdef STORM_HAVE_CARL
template class Mdp < double , storm : : models : : sparse : : StandardRewardModel < storm : : Interval > > ;
template class Mdp < storm : : RationalFunction > ;
template class Mdp < storm : : RationalFunction > ;
# endif
# endif
xxxxxxxxxx