3#include <boost/algorithm/string.hpp>
4#include <boost/lexical_cast.hpp>
17template<
typename ValueType>
18ValueParser<ValueType>::ParametricData::ParametricData()
19 :
manager(new storm::expressions::ExpressionManager()),
23 parser->setIdentifierMapping(identifierMapping);
26template<
typename ValueType>
27ValueParser<ValueType>::ParametricData::~ParametricData() =
default;
29template<
typename ValueType>
31 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Parameters are not supported in this build (Have you checked storm-pars?).");
37 data.identifierMapping.emplace(var.
getName(), var);
38 data.parser->setIdentifierMapping(data.identifierMapping);
46 return rationalFunction;
49template<
typename ValueType>
54template<
typename NumberType>
58 "Could not parse value '" << value <<
"' into " <<
typeid(NumberType).name() <<
".");
63 if (boost::conversion::try_lexical_convert(value, result)) {
67 storm::RationalNumber rationalResult;
77template<
typename IntervalType>
81 result = IntervalType(pointResult);
85 std::string intermediate = value;
86 boost::trim(intermediate);
87 carl::BoundType leftBound;
88 carl::BoundType rightBound;
89 if (intermediate.front() ==
'(') {
90 leftBound = carl::BoundType::STRICT;
91 }
else if (intermediate.front() ==
'[') {
92 leftBound = carl::BoundType::WEAK;
96 if (intermediate.back() ==
')') {
97 rightBound = carl::BoundType::STRICT;
98 }
else if (intermediate.back() ==
']') {
99 rightBound = carl::BoundType::WEAK;
103 intermediate = intermediate.substr(1, intermediate.size() - 2);
105 std::vector<std::string> words;
106 boost::split(words, intermediate, boost::is_any_of(
","));
107 if (words.size() != 2) {
111 boost::trim(words[0]);
115 boost::trim(words[1]);
119 result = IntervalType(leftVal, leftBound, rightVal, rightBound);
123template<
typename NumberType>
125 if constexpr (std::is_same_v<NumberType, double>) {
127 }
else if constexpr (std::is_same_v<NumberType, storm::RationalNumber>) {
128 return carl::try_parse(value, result);
129 }
else if constexpr (std::is_same_v<NumberType, storm::Interval>) {
131 }
else if constexpr (std::is_same_v<NumberType, storm::RationalInterval>) {
134 return boost::conversion::try_lexical_convert(value, result);
139template class ValueParser<double>;
140template class ValueParser<storm::RationalNumber>;
141template class ValueParser<storm::RationalFunction>;
142template class ValueParser<storm::Interval>;
143template class ValueParser<storm::RationalInterval>;
Variable declareRationalVariable(std::string const &name, bool auxiliary=false)
Declares a new rational variable with a name that must not yet exist and its corresponding type.
std::string const & getName() const
Retrieves the name of the variable.
void addParameter(std::string const ¶meter)
Add declaration of parameter.
ValueType parseValue(std::string const &value) const
Parse ValueType from string.
#define STORM_LOG_TRACE(message)
#define STORM_LOG_THROW(cond, exception, message)
Contains all file parsers and helper classes.
NumberType parseNumber(std::string const &value)
Parse number from string.
bool parseInterval(std::string const &value, IntervalType &result)
bool parseDouble(std::string const &value, double &result)
SettingsManager const & manager()
Retrieves the settings manager.
TargetType convertNumber(SourceType const &number)
carl::RationalFunction< Polynomial, true > RationalFunction
typename detail::IntervalMetaProgrammingHelper< ValueType >::BaseType IntervalBaseType
Helper to access the type in which interval boundaries are stored.