7 changed files with 154 additions and 6 deletions
			
			
		- 
					2src/storm/cli/cli.cpp
- 
					9src/storm/cli/entrypoints.h
- 
					72src/storm/parser/DirectEncodingParser.cpp
- 
					33src/storm/parser/DirectEncodingParser.h
- 
					22src/storm/settings/modules/IOSettings.cpp
- 
					16src/storm/settings/modules/IOSettings.h
- 
					6src/storm/utility/storm.h
| @ -0,0 +1,72 @@ | |||
| #include "storm/parser/DirectEncodingParser.h"
 | |||
| 
 | |||
| #include <cstdio>
 | |||
| #include <cstring>
 | |||
| #include <cstdint>
 | |||
| #include <clocale>
 | |||
| #include <iostream>
 | |||
| #include <string>
 | |||
| 
 | |||
| #include "storm/exceptions/FileIoException.h"
 | |||
| #include "storm/exceptions/WrongFormatException.h"
 | |||
| #include "storm/exceptions/InvalidArgumentException.h"
 | |||
| #include "storm/settings/SettingsManager.h"
 | |||
| 
 | |||
| #include "storm/adapters/CarlAdapter.h"
 | |||
| #include "storm/utility/macros.h"
 | |||
| #include "storm/utility/file.h"
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace parser { | |||
| 
 | |||
|         template<typename ValueType, typename RewardModelType> | |||
|         std::shared_ptr<storm::models::sparse::Model<ValueType, RewardModelType>> DirectEncodingParser<ValueType, RewardModelType>::parseModel(std::string const& filename) { | |||
| 
 | |||
|             // Load file
 | |||
|             STORM_LOG_INFO("Reading from file " << filename); | |||
|             std::ifstream file; | |||
|             storm::utility::openFile(filename, file); | |||
|             std::string line; | |||
| 
 | |||
|             // Initialize
 | |||
|             storm::models::ModelType type; | |||
| 
 | |||
|             // Iterate over all lines
 | |||
|             while (std::getline(file, line)) { | |||
|                 STORM_LOG_TRACE("Parsing: " << line); | |||
|             } | |||
| 
 | |||
|             // Done parsing
 | |||
|             storm::utility::closeFile(file); | |||
| 
 | |||
| 
 | |||
|             // Build model
 | |||
|             switch (type) { | |||
|                 case storm::models::ModelType::Dtmc: | |||
|                 { | |||
|                     STORM_LOG_THROW(false, storm::exceptions::FileIoException, "DTMC not supported."); | |||
|                 } | |||
|                 case storm::models::ModelType::Ctmc: | |||
|                 { | |||
|                     STORM_LOG_THROW(false, storm::exceptions::FileIoException, "CTMC not supported."); | |||
|                 } | |||
|                 case storm::models::ModelType::Mdp: | |||
|                 { | |||
|                     STORM_LOG_THROW(false, storm::exceptions::FileIoException, "MDP not supported."); | |||
|                 } | |||
|                 case storm::models::ModelType::MarkovAutomaton: | |||
|                 { | |||
|                     STORM_LOG_THROW(false, storm::exceptions::FileIoException, "MA not supported."); | |||
|                 } | |||
|                 default: | |||
|                     STORM_LOG_THROW(false, storm::exceptions::FileIoException, "Unknown/Unhandled model type " << type << " which cannot be parsed."); | |||
|             } | |||
|         } | |||
| 
 | |||
|         template class DirectEncodingParser<double>; | |||
| 
 | |||
| #ifdef STORM_HAVE_CARL
 | |||
|         template class DirectEncodingParser<storm::RationalFunction>; | |||
| #endif
 | |||
|     } // namespace parser
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,33 @@ | |||
| #ifndef STORM_PARSER_DIRECTENCODINGPARSER_H_ | |||
| #define STORM_PARSER_DIRECTENCODINGPARSER_H_ | |||
| 
 | |||
| #include "storm/models/sparse/Model.h" | |||
| 
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace parser { | |||
| 
 | |||
|         /*! | |||
|          *	Parser for models in the DRN format with explicit encoding. | |||
|          */ | |||
|         template<typename ValueType, typename RewardModelType = models::sparse::StandardRewardModel<ValueType>> | |||
|         class DirectEncodingParser { | |||
|         public: | |||
| 
 | |||
|             /*! | |||
|              * Load a model in DRN format from a file and create the model. | |||
|              * | |||
|              * @param file The DRN file to be parsed. | |||
|              * | |||
|              * @return A sparse model | |||
|              */ | |||
|             static std::shared_ptr<storm::models::sparse::Model<ValueType, RewardModelType>> parseModel(std::string const& file); | |||
| 
 | |||
|         private: | |||
| 
 | |||
|         }; | |||
| 
 | |||
|     } // namespace parser | |||
| } // namespace storm | |||
| 
 | |||
| #endif /* STORM_PARSER_DIRECTENCODINGPARSER_H_ */ | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue