Browse Source

remove constant from model, e.g. for constants that do not appear in the model

tempestpy_adaptions
Sebastian Junges 6 years ago
parent
commit
98f1468479
  1. 16
      src/storm/storage/jani/Model.cpp
  2. 5
      src/storm/storage/jani/Model.h

16
src/storm/storage/jani/Model.cpp

@ -638,6 +638,22 @@ namespace storm {
return constantToIndex.find(name) != constantToIndex.end(); return constantToIndex.find(name) != constantToIndex.end();
} }
void Model::removeConstant(std::string const& name) {
auto pos = constantToIndex.find(name);
if (pos != constantToIndex.end()) {
uint64_t index = pos->second;
constants.erase(constants.begin() + index);
constantToIndex.erase(pos);
for (auto& entry : constantToIndex) {
if(entry.second > index) {
entry.second--;
}
}
}
}
Constant const& Model::getConstant(std::string const& name) const { Constant const& Model::getConstant(std::string const& name) const {
auto it = constantToIndex.find(name); auto it = constantToIndex.find(name);
STORM_LOG_THROW(it != constantToIndex.end(), storm::exceptions::WrongFormatException, "Unable to retrieve unknown constant '" << name << "'."); STORM_LOG_THROW(it != constantToIndex.end(), storm::exceptions::WrongFormatException, "Unable to retrieve unknown constant '" << name << "'.");

5
src/storm/storage/jani/Model.h

@ -170,6 +170,11 @@ namespace storm {
*/ */
bool hasConstant(std::string const& name) const; bool hasConstant(std::string const& name) const;
/*!
* Removes (without checks) a constant from the model.
*/
void removeConstant(std::string const& name);
/*! /*!
* Retrieves the constants of the model. * Retrieves the constants of the model.
*/ */
Loading…
Cancel
Save