17 std::string
const& parameterBoundariesString,
18 std::set<VariableType>
const& consideredVariables) {
19 std::string::size_type positionOfFirstRelation = parameterBoundariesString.find(
"<=");
20 STORM_LOG_THROW(positionOfFirstRelation != std::string::npos, storm::exceptions::InvalidArgumentException,
21 "When parsing the region" << parameterBoundariesString <<
" I could not find a '<=' after the first number");
22 std::string::size_type positionOfSecondRelation = parameterBoundariesString.find(
"<=", positionOfFirstRelation + 2);
23 STORM_LOG_THROW(positionOfSecondRelation != std::string::npos, storm::exceptions::InvalidArgumentException,
24 "When parsing the region" << parameterBoundariesString <<
" I could not find a '<=' after the parameter");
26 std::string parameter = parameterBoundariesString.substr(positionOfFirstRelation + 2, positionOfSecondRelation - (positionOfFirstRelation + 2));
29 parameter.erase(std::remove_if(parameter.begin(), parameter.end(), ::isspace), parameter.end());
30 STORM_LOG_THROW(parameter.length() > 0, storm::exceptions::InvalidArgumentException,
31 "When parsing the region" << parameterBoundariesString <<
" I could not find a parameter");
33 std::unique_ptr<VariableType> var;
34 for (
auto const& v : consideredVariables) {
35 std::stringstream stream;
37 if (parameter == stream.str()) {
38 var = std::make_unique<VariableType>(v);
43 CoefficientType lb = storm::utility::convertNumber<CoefficientType>(parameterBoundariesString.substr(0, positionOfFirstRelation));
44 CoefficientType ub = storm::utility::convertNumber<CoefficientType>(parameterBoundariesString.substr(positionOfSecondRelation + 2));
45 lowerBoundaries.emplace(std::make_pair(*var, lb));
46 upperBoundaries.emplace(std::make_pair(*var, ub));
48 STORM_LOG_WARN(
"Could not find parameter " << parameter <<
" in the set of considered variables. Ignoring this parameter.");
54 std::set<VariableType>
const& consideredVariables) {
57 std::vector<std::string> parameterBoundaries;
58 boost::split(parameterBoundaries, regionString, boost::is_any_of(
","));
59 for (
auto const& parameterBoundary : parameterBoundaries) {
60 if (!std::all_of(parameterBoundary.begin(), parameterBoundary.end(), ::isspace)) {
61 parseParameterBoundaries(lowerBoundaries, upperBoundaries, parameterBoundary, consideredVariables);
66 for (
auto const& v : consideredVariables) {
67 STORM_LOG_THROW(lowerBoundaries.count(v) > 0, storm::exceptions::WrongFormatException,
"Variable " << v <<
" was not defined in region string.");
68 STORM_LOG_ASSERT(upperBoundaries.count(v) > 0,
"Variable " << v <<
" has a lower but not an upper bound.");
77 std::set<VariableType>
const& consideredVariables) {
80 std::vector<std::string> parameterBoundaries;
81 CoefficientType bound = storm::utility::convertNumber<CoefficientType>(regionBound);
82 for (
auto const& v : consideredVariables) {
83 lowerBoundaries.emplace(std::make_pair(v, 0 + bound));
84 upperBoundaries.emplace(std::make_pair(v, 1 - bound));
93 std::string
const& regionsString, std::set<VariableType>
const& consideredVariables) {
94 std::vector<storm::storage::ParameterRegion<ParametricType>> result;
95 std::vector<std::string> regionsStrVec;
96 boost::split(regionsStrVec, regionsString, boost::is_any_of(
";"));
97 for (
auto const& regionStr : regionsStrVec) {
98 if (!std::all_of(regionStr.begin(), regionStr.end(), ::isspace)) {
99 result.emplace_back(parseRegion(regionStr, consideredVariables));
107 std::string
const& fileName, std::set<VariableType>
const& consideredVariables) {
109 std::ifstream inputFileStream;
112 std::vector<storm::storage::ParameterRegion<ParametricType>> result;
116 std::string fileContent((std::istreambuf_iterator<char>(inputFileStream)), (std::istreambuf_iterator<char>()));
117 result = parseMultipleRegions(fileContent, consideredVariables);
118 }
catch (std::exception& e) {
void openFile(std::string const &filepath, std::ofstream &filestream, bool append=false, bool silent=false)
Open the given file for writing.