@ -18,8 +18,7 @@ namespace storm {
namespace parser {
/*!
* Parses a transition file and a labeling file and produces a DTMC out of them ; a pointer to the dtmc
* is saved in the field " dtmc "
* Parses a transition file and a labeling file
* Note that the labeling file may have at most as many nodes as the transition file !
*
* @ param transitionSystemFile String containing the location of the transition file ( . . . . tra )
@ -27,31 +26,49 @@ namespace parser {
* @ param stateRewardFile String containing the location of the state reward file ( . . . srew )
* @ param transitionRewardFile String containing the location of the transition reward file ( . . . trew )
*/
DeterministicModelParser : : DeterministicModelParser ( std : : string const & transitionSystemFile , std : : string const & labelingFile ,
std : : string const & stateRewardFile , std : : string const & transitionRewardFile ) {
storm : : parser : : DeterministicSparseTransitionParser tp ( transitionSystemFile ) ;
this - > transitionSystem = tp . getMatrix ( ) ;
DeterministicModelParserResultContainer < double > parseDeterministicModel ( std : : string const & transitionSystemFile , std : : string const & labelingFile ,
std : : string const & stateRewardFile , std : : string const & transitionRewardFile ) {
uint_fast64_t stateCount = this - > transitionSystem - > getRowCount ( ) ;
storm : : storage : : SparseMatrix < double > resultTransitionSystem = storm : : parser : : DeterministicSparseTransitionParser ( transitionSystemFile ) ;
storm : : parser : : AtomicPropositionLabelingParser lp ( stateCount , labelingFile ) ;
this - > labeling = lp . getLabeling ( ) ;
uint_fast64_t stateCount = resultTransitionSystem . getRowCount ( ) ;
this - > stateRewards = nullptr ;
this - > transitionRewards = nullptr ;
storm : : models : : AtomicPropositionsLabeling resultLabeling = storm : : parser : : AtomicPropositionLabelingParser ( stateCount , labelingFile ) ;
DeterministicModelParserResultContainer < double > result ( resultTransitionSystem , resultLabeling ) ;
if ( stateRewardFile ! = " " ) {
storm : : parser : : SparseStateRewardParser srp ( stateCount , stateRewardFile ) ;
this - > stateRewards = srp . getStateRewards ( ) ;
result . stateRewards . reset ( storm : : parser : : SparseStateRewardParser ( stateCount , stateRewardFile ) ) ;
}
if ( transitionRewardFile ! = " " ) {
RewardMatrixInformationStruct * rewardMatrixInfo = new RewardMatrixInformationStruct ( stateCount , stateCount , nullptr ) ;
storm : : parser : : DeterministicSparseTransitionParser trp ( transitionRewardFile , false , rewardMatrixInfo ) ;
result . transitionRewards . reset ( storm : : parser : : DeterministicSparseTransitionParser ( transitionRewardFile , false , rewardMatrixInfo ) ) ;
delete rewardMatrixInfo ;
this - > transitionRewards = trp . getMatrix ( ) ;
}
this - > dtmc = nullptr ;
this - > ctmc = nullptr ;
return result ;
}
/*!
* Uses the Function parseDeterministicModel internally to parse the given input files .
* @ note This is a Short - Hand for Constructing a Dtmc directly from the data returned by @ parseDeterministicModel
* @ return A Dtmc Model
*/
storm : : models : : Dtmc < double > DeterministicModelParserAsDtmc ( std : : string const & transitionSystemFile , std : : string const & labelingFile ,
std : : string const & stateRewardFile , std : : string const & transitionRewardFile ) {
DeterministicModelParserResultContainer < double > parserResult = parseDeterministicModel ( transitionRewardFile , labelingFile , stateRewardFile , transitionRewardFile ) ;
return storm : : models : : Dtmc < double > ( parserResult . transitionSystem , parserResult . labeling , parserResult . stateRewards , parserResult . transitionRewards ) ;
}
/*!
* Uses the Function parseDeterministicModel internally to parse the given input files .
* @ note This is a Short - Hand for Constructing a Ctmc directly from the data returned by @ parseDeterministicModel
* @ return A Ctmc Model
*/
storm : : models : : Ctmc < double > DeterministicModelParserAsCtmc ( std : : string const & transitionSystemFile , std : : string const & labelingFile ,
std : : string const & stateRewardFile , std : : string const & transitionRewardFile ) {
DeterministicModelParserResultContainer < double > parserResult = parseDeterministicModel ( transitionRewardFile , labelingFile , stateRewardFile , transitionRewardFile ) ;
return storm : : models : : Ctmc < double > ( parserResult . transitionSystem , parserResult . labeling , parserResult . stateRewards , parserResult . transitionRewards ) ;
}
} /* namespace parser */