150 bool makeVariablesGlobal)
const {
152 return std::make_pair(*
this, std::vector<storm::jani::Property>());
158 STORM_LOG_THROW(
false, storm::exceptions::InvalidOperationException,
"Cannot transform model description to the JANI format.");
194 std::vector<storm::expressions::Variable> result;
197 for (
auto const& constant : constants) {
198 result.emplace_back(constant.get().getExpressionVariable());
202 for (
auto const& constant : constants) {
203 result.emplace_back(constant.get().getExpressionVariable());
245 std::string
const& constantDefinitionString) {
246 std::map<storm::expressions::Variable, storm::expressions::Expression> constantDefinitions;
247 std::set<storm::expressions::Variable> definedConstants;
249 if (!constantDefinitionString.empty()) {
250 std::vector<std::string> definitions;
251 boost::split(definitions, constantDefinitionString, boost::is_any_of(
","));
252 for (
auto& definition : definitions) {
253 boost::trim(definition);
255 std::size_t positionOfAssignmentOperator = definition.find(
'=');
256 STORM_LOG_THROW(positionOfAssignmentOperator != std::string::npos, storm::exceptions::WrongFormatException,
257 "Illegal constant definition string: syntax error.");
259 std::string constantName = definition.substr(0, positionOfAssignmentOperator);
260 boost::trim(constantName);
261 std::string value = definition.substr(positionOfAssignmentOperator + 1);
264 if (manager.hasVariable(constantName)) {
265 auto const& variable = manager.getVariable(constantName);
266 STORM_LOG_THROW(definedConstants.find(variable) == definedConstants.end(), storm::exceptions::WrongFormatException,
267 "Illegally trying to define constant '" << constantName <<
"' twice.");
268 definedConstants.insert(variable);
270 if (manager.hasVariable(value)) {
271 auto const& valueVariable = manager.getVariable(value);
273 variable.getType() == valueVariable.getType(), storm::exceptions::WrongFormatException,
274 "Illegally trying to define constant '" << constantName <<
"' by constant '" << valueVariable.getName() <<
" of different type.");
275 constantDefinitions[variable] = valueVariable.getExpression();
276 }
else if (variable.hasBooleanType()) {
277 if (value ==
"true") {
278 constantDefinitions[variable] = manager.boolean(
true);
279 }
else if (value ==
"false") {
280 constantDefinitions[variable] = manager.boolean(
false);
282 STORM_LOG_THROW(
false, storm::exceptions::WrongFormatException,
"Illegal value for boolean constant: " << value <<
".");
284 }
else if (variable.hasIntegerType()) {
285 std::size_t position = 0;
286 int_fast64_t integerValue = 0;
289 integerValue = std::stoll(value, &position);
290 }
catch (std::exception&) {
293 STORM_LOG_THROW(valid && position == value.size(), storm::exceptions::WrongFormatException,
294 "Illegal value for integer constant: " << value <<
".");
295 constantDefinitions[variable] = manager.integer(integerValue);
296 }
else if (variable.hasRationalType()) {
299 constantDefinitions[variable] = manager.rational(rationalValue);
300 }
catch (std::exception& e) {
302 "Illegal constant definition string '" << constantName <<
"=" << value <<
"': " << e.what() <<
".");
307 "Illegal constant definition string: unknown undefined constant '" << constantName <<
"'.");
312 return constantDefinitions;