16 std::string
const& parameterBoundariesString,
17 std::set<VariableType>
const& consideredVariables) {
18 std::string::size_type positionOfFirstRelation = parameterBoundariesString.find(
"<=");
19 STORM_LOG_THROW(positionOfFirstRelation != std::string::npos, storm::exceptions::InvalidArgumentException,
20 "When parsing the region" << parameterBoundariesString <<
" I could not find a '<=' after the first number");
21 std::string::size_type positionOfSecondRelation = parameterBoundariesString.find(
"<=", positionOfFirstRelation + 2);
22 STORM_LOG_THROW(positionOfSecondRelation != std::string::npos, storm::exceptions::InvalidArgumentException,
23 "When parsing the region" << parameterBoundariesString <<
" I could not find a '<=' after the parameter");
25 std::string parameter = parameterBoundariesString.substr(positionOfFirstRelation + 2, positionOfSecondRelation - (positionOfFirstRelation + 2));
28 parameter.erase(std::remove_if(parameter.begin(), parameter.end(), ::isspace), parameter.end());
29 STORM_LOG_THROW(parameter.length() > 0, storm::exceptions::InvalidArgumentException,
30 "When parsing the region" << parameterBoundariesString <<
" I could not find a parameter");
32 std::unique_ptr<VariableType> var;
33 for (
auto const& v : consideredVariables) {
34 std::stringstream stream;
36 if (parameter == stream.str()) {
37 var = std::make_unique<VariableType>(v);
42 CoefficientType lb = storm::utility::convertNumber<CoefficientType>(parameterBoundariesString.substr(0, positionOfFirstRelation));
43 CoefficientType ub = storm::utility::convertNumber<CoefficientType>(parameterBoundariesString.substr(positionOfSecondRelation + 2));
44 lowerBoundaries.emplace(std::make_pair(*var, lb));
45 upperBoundaries.emplace(std::make_pair(*var, ub));
47 STORM_LOG_WARN(
"Could not find parameter " << parameter <<
" in the set of considered variables. Ignoring this parameter.");
53 std::set<VariableType>
const& consideredVariables) {
56 std::vector<std::string> parameterBoundaries;
57 boost::split(parameterBoundaries, regionString, boost::is_any_of(
","));
58 for (
auto const& parameterBoundary : parameterBoundaries) {
59 if (!std::all_of(parameterBoundary.begin(), parameterBoundary.end(), ::isspace)) {
60 parseParameterBoundaries(lowerBoundaries, upperBoundaries, parameterBoundary, consideredVariables);
65 for (
auto const& v : consideredVariables) {
66 STORM_LOG_THROW(lowerBoundaries.count(v) > 0, storm::exceptions::WrongFormatException,
"Variable " << v <<
" was not defined in region string.");
67 STORM_LOG_ASSERT(upperBoundaries.count(v) > 0,
"Variable " << v <<
" has a lower but not an upper bound.");
76 std::set<VariableType>
const& consideredVariables) {
79 std::vector<std::string> parameterBoundaries;
80 CoefficientType bound = storm::utility::convertNumber<CoefficientType>(regionBound);
81 STORM_LOG_THROW(0 < bound && bound < 1, storm::exceptions::WrongFormatException,
"Bound must be between 0 and 1, " << bound <<
" is not.");
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.