Browse Source

more work towards making the new bisim class available from the cl

Former-commit-id: b177287e00
tempestpy_adaptions
dehnert 9 years ago
parent
commit
11b04c7940
  1. 33
      src/cli/entrypoints.h
  2. 4
      src/models/ModelBase.cpp
  3. 8
      src/models/ModelBase.h
  4. 5
      src/utility/storm.h

33
src/cli/entrypoints.h

@ -3,7 +3,6 @@
#include "src/utility/storm.h"
namespace storm {
namespace cli {
@ -84,14 +83,40 @@ namespace storm {
}
}
}
#define BRANCH_ON_MODELTYPE(result, model, value_type, dd_type, function, ...) \
if (model->isSymbolicModel()) { \
if (model->isOfType(storm::models::ModelType::Dtmc)) { \
result = function<storm::models::symbolic::Dtmc<dd_type>>(model->as<storm::models::symbolic::Dtmc<dd_type>>(), __VA_ARGS__); \
} else if (model->isOfType(storm::models::ModelType::Ctmc)) { \
result = function<storm::models::symbolic::Ctmc<dd_type>>(model->as<storm::models::symbolic::Ctmc<dd_type>>(), __VA_ARGS__); \
} else if (model->isOfType(storm::models::ModelType::Mdp)) { \
result = function<storm::models::symbolic::Mdp<dd_type>>(model->as<storm::models::symbolic::Mdp<dd_type>>(), __VA_ARGS__); \
} else { \
STORM_LOG_ASSERT(false, "Unknown model type."); \
} \
} else { \
STORM_LOG_ASSERT(model->isSparseModel(), "Unknown model type."); \
if (model->isOfType(storm::models::ModelType::Dtmc)) { \
result = function<storm::models::sparse::Dtmc<value_type>>(model->as<storm::models::sparse::Dtmc<value_type>>(), __VA_ARGS__); \
} else if (model->isOfType(storm::models::ModelType::Ctmc)) { \
result = function<storm::models::sparse::Ctmc<value_type>>(model->as<storm::models::sparse::Ctmc<value_type>>(), __VA_ARGS__); \
} else if (model->isOfType(storm::models::ModelType::Mdp)) { \
result = function<storm::models::sparse::Mdp<value_type>>(model->as<storm::models::sparse::Mdp<value_type>>(), __VA_ARGS__); \
} else if (model->isOfType(storm::models::ModelType::MarkovAutomaton)) { \
result = function<storm::models::sparse::MarkovAutomaton<value_type>>(model->as<storm::models::sparse::MarkovAutomaton<value_type>>(), __VA_ARGS__); \
} else { \
STORM_LOG_ASSERT(false, "Unknown model type."); \
} \
}
template<typename ValueType>
void buildAndCheckSymbolicModel(storm::prism::Program const& program, std::vector<std::shared_ptr<storm::logic::Formula>> const& formulas) {
std::shared_ptr<storm::models::ModelBase> model = buildSymbolicModel<ValueType>(program, formulas);
STORM_LOG_THROW(model != nullptr, storm::exceptions::InvalidStateException, "Model could not be constructed for an unknown reason.");
// Preprocess the model if needed.
model = preprocessModel<ValueType>(model, formulas);
BRANCH_ON_MODELTYPE(model, model, ValueType, storm::dd::DdType::CUDD, preprocessModel, formulas);
// Print some information about the model.
model->printModelInformationToStream(std::cout);
@ -127,7 +152,7 @@ namespace storm {
std::shared_ptr<storm::models::ModelBase> model = buildExplicitModel<ValueType>(settings.getTransitionFilename(), settings.getLabelingFilename(), settings.isStateRewardsSet() ? settings.getStateRewardsFilename() : boost::optional<std::string>(), settings.isTransitionRewardsSet() ? settings.getTransitionRewardsFilename() : boost::optional<std::string>(), settings.isChoiceLabelingSet() ? settings.getChoiceLabelingFilename() : boost::optional<std::string>());
// Preprocess the model if needed.
model = preprocessModel<ValueType>(model, formulas);
BRANCH_ON_MODELTYPE(model, model, ValueType, storm::dd::DdType::CUDD, preprocessModel, formulas);
// Print some information about the model.
model->printModelInformationToStream(std::cout);

4
src/models/ModelBase.cpp

@ -13,5 +13,9 @@ namespace storm {
bool ModelBase::isSymbolicModel() const {
return false;
}
bool ModelBase::isOfType(storm::models::ModelType const& modelType) const {
return this->getType() == modelType;
}
}
}

8
src/models/ModelBase.h

@ -89,6 +89,14 @@ namespace storm {
*/
virtual bool isSymbolicModel() const;
/*!
* Checks whether the model is of the given type.
*
* @param modelType The model type to check for.
* @return True iff the model is of the given type.
*/
bool isOfType(storm::models::ModelType const& modelType) const;
private:
// The type of the model.
ModelType modelType;

5
src/utility/storm.h

@ -30,6 +30,7 @@
#include "src/models/ModelBase.h"
#include "src/models/sparse/Model.h"
#include "src/models/sparse/StandardRewardModel.h"
#include "src/models/sparse/MarkovAutomaton.h"
#include "src/models/symbolic/Model.h"
#include "src/models/symbolic/StandardRewardModel.h"
@ -80,8 +81,6 @@ namespace storm {
std::vector<std::shared_ptr<storm::logic::Formula>> parseFormulasForExplicit(std::string const& inputString);
std::vector<std::shared_ptr<storm::logic::Formula>> parseFormulasForProgram(std::string const& inputString, storm::prism::Program const& program);
template<typename ValueType>
std::shared_ptr<storm::models::ModelBase> buildSymbolicModel(storm::prism::Program const& program, std::vector<std::shared_ptr<storm::logic::Formula>> const& formulas) {
std::shared_ptr<storm::models::ModelBase> result(nullptr);
@ -111,7 +110,6 @@ namespace storm {
result = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program, options);
}
// Then, build the model from the symbolic description.
return result;
}
@ -263,7 +261,6 @@ namespace storm {
return result;
}
#endif
template<storm::dd::DdType DdType>

Loading…
Cancel
Save