Browse Source

Const reference for splittingThreshold

main
Matthias Volk 4 years ago
parent
commit
c9841b71a0
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 12
      src/storm-pars/api/region.h
  2. 8
      src/storm-pars/parser/ParameterRegionParser.cpp
  3. 8
      src/storm-pars/parser/ParameterRegionParser.h

12
src/storm-pars/api/region.h

@ -39,7 +39,7 @@ namespace storm {
}; };
template <typename ValueType> template <typename ValueType>
std::vector<storm::storage::ParameterRegion<ValueType>> parseRegions(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none) { std::vector<storm::storage::ParameterRegion<ValueType>> parseRegions(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none) {
// If the given input string looks like a file (containing a dot and there exists a file with that name), // If the given input string looks like a file (containing a dot and there exists a file with that name),
// we try to parse it as a file, otherwise we assume it's a region string. // we try to parse it as a file, otherwise we assume it's a region string.
if (inputString.find(".") != std::string::npos && std::ifstream(inputString).good()) { if (inputString.find(".") != std::string::npos && std::ifstream(inputString).good()) {
@ -50,12 +50,12 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
storm::storage::ParameterRegion<ValueType> createRegion(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> splittingThreshold= boost::none) { storm::storage::ParameterRegion<ValueType> createRegion(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none) {
return storm::parser::ParameterRegionParser<ValueType>().createRegion(inputString, consideredVariables, splittingThreshold); return storm::parser::ParameterRegionParser<ValueType>().createRegion(inputString, consideredVariables, splittingThreshold);
} }
template <typename ValueType> template <typename ValueType>
std::vector<storm::storage::ParameterRegion<ValueType>> parseRegions(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> splittingThreshold= boost::none) { std::vector<storm::storage::ParameterRegion<ValueType>> parseRegions(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> const& splittingThreshold = boost::none) {
std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> modelParameters; std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> modelParameters;
if (model.isSparseModel()) { if (model.isSparseModel()) {
auto const& sparseModel = dynamic_cast<storm::models::sparse::Model<ValueType> const&>(model); auto const& sparseModel = dynamic_cast<storm::models::sparse::Model<ValueType> const&>(model);
@ -69,7 +69,7 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
std::vector<storm::storage::ParameterRegion<ValueType>> createRegion(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> splittingThreshold= boost::none) { std::vector<storm::storage::ParameterRegion<ValueType>> createRegion(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> const& splittingThreshold = boost::none) {
std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> modelParameters; std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> modelParameters;
if (model.isSparseModel()) { if (model.isSparseModel()) {
auto const& sparseModel = dynamic_cast<storm::models::sparse::Model<ValueType> const&>(model); auto const& sparseModel = dynamic_cast<storm::models::sparse::Model<ValueType> const&>(model);
@ -83,7 +83,7 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
storm::storage::ParameterRegion<ValueType> parseRegion(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> splittingThreshold= boost::none) { storm::storage::ParameterRegion<ValueType> parseRegion(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none) {
// Handle the "empty region" case // Handle the "empty region" case
if (inputString == "" && consideredVariables.empty()) { if (inputString == "" && consideredVariables.empty()) {
return storm::storage::ParameterRegion<ValueType>(); return storm::storage::ParameterRegion<ValueType>();
@ -95,7 +95,7 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
storm::storage::ParameterRegion<ValueType> parseRegion(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> splittingThreshold= boost::none) { storm::storage::ParameterRegion<ValueType> parseRegion(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> const& splittingThreshold = boost::none) {
// Handle the "empty region" case // Handle the "empty region" case
if (inputString == "" && !model.hasParameters()) { if (inputString == "" && !model.hasParameters()) {
return storm::storage::ParameterRegion<ValueType>(); return storm::storage::ParameterRegion<ValueType>();

8
src/storm-pars/parser/ParameterRegionParser.cpp

@ -42,7 +42,7 @@ namespace storm {
} }
template<typename ParametricType> template<typename ParametricType>
storm::storage::ParameterRegion<ParametricType> ParameterRegionParser<ParametricType>::parseRegion(std::string const& regionString, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold) { storm::storage::ParameterRegion<ParametricType> ParameterRegionParser<ParametricType>::parseRegion(std::string const& regionString, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold) {
Valuation lowerBoundaries; Valuation lowerBoundaries;
Valuation upperBoundaries; Valuation upperBoundaries;
std::vector<std::string> parameterBoundaries; std::vector<std::string> parameterBoundaries;
@ -66,7 +66,7 @@ namespace storm {
} }
template<typename ParametricType> template<typename ParametricType>
storm::storage::ParameterRegion<ParametricType> ParameterRegionParser<ParametricType>::createRegion(std::string const& regionBound, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold) { storm::storage::ParameterRegion<ParametricType> ParameterRegionParser<ParametricType>::createRegion(std::string const& regionBound, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold) {
Valuation lowerBoundaries; Valuation lowerBoundaries;
Valuation upperBoundaries; Valuation upperBoundaries;
std::vector<std::string> parameterBoundaries; std::vector<std::string> parameterBoundaries;
@ -84,7 +84,7 @@ namespace storm {
} }
template<typename ParametricType> template<typename ParametricType>
std::vector<storm::storage::ParameterRegion<ParametricType>> ParameterRegionParser<ParametricType>::parseMultipleRegions(std::string const& regionsString, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold) { std::vector<storm::storage::ParameterRegion<ParametricType>> ParameterRegionParser<ParametricType>::parseMultipleRegions(std::string const& regionsString, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold) {
std::vector<storm::storage::ParameterRegion<ParametricType>> result; std::vector<storm::storage::ParameterRegion<ParametricType>> result;
std::vector<std::string> regionsStrVec; std::vector<std::string> regionsStrVec;
boost::split(regionsStrVec, regionsString, boost::is_any_of(";")); boost::split(regionsStrVec, regionsString, boost::is_any_of(";"));
@ -97,7 +97,7 @@ namespace storm {
} }
template<typename ParametricType> template<typename ParametricType>
std::vector<storm::storage::ParameterRegion<ParametricType>> ParameterRegionParser<ParametricType>::parseMultipleRegionsFromFile(std::string const& fileName, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold) { std::vector<storm::storage::ParameterRegion<ParametricType>> ParameterRegionParser<ParametricType>::parseMultipleRegionsFromFile(std::string const& fileName, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold) {
// Open file and initialize result. // Open file and initialize result.
std::ifstream inputFileStream; std::ifstream inputFileStream;

8
src/storm-pars/parser/ParameterRegionParser.h

@ -25,21 +25,21 @@ namespace storm {
* Parse a single region from a string of the form "0.3<=p<=0.5,0.4<=q<=0.7". * Parse a single region from a string of the form "0.3<=p<=0.5,0.4<=q<=0.7".
* *
*/ */
static storm::storage::ParameterRegion<ParametricType> parseRegion(std::string const& regionString, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none); static storm::storage::ParameterRegion<ParametricType> parseRegion(std::string const& regionString, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none);
static storm::storage::ParameterRegion<ParametricType> createRegion(std::string const& regionBound, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none); static storm::storage::ParameterRegion<ParametricType> createRegion(std::string const& regionBound, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none);
/* /*
* Parse a vector of region from a string of the form "0.3<=p<=0.5,0.4<=q<=0.7;0.1<=p<=0.3,0.2<=q<=0.4". * Parse a vector of region from a string of the form "0.3<=p<=0.5,0.4<=q<=0.7;0.1<=p<=0.3,0.2<=q<=0.4".
* *
*/ */
static std::vector<storm::storage::ParameterRegion<ParametricType>> parseMultipleRegions(std::string const& regionsString, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none); static std::vector<storm::storage::ParameterRegion<ParametricType>> parseMultipleRegions(std::string const& regionsString, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none);
/* /*
* Parse multiple regions from a file * Parse multiple regions from a file
* *
*/ */
static std::vector<storm::storage::ParameterRegion<ParametricType>> parseMultipleRegionsFromFile(std::string const& fileName, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none); static std::vector<storm::storage::ParameterRegion<ParametricType>> parseMultipleRegionsFromFile(std::string const& fileName, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none);
}; };
} }

|||||||
100:0
Loading…
Cancel
Save