Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
prism.cpp
Go to the documentation of this file.
2
4
7
8#include "storm/utility/cli.h"
10
12
13#include <boost/algorithm/string.hpp>
14
15namespace storm {
16namespace utility {
17namespace prism {
18
20 std::map<storm::expressions::Variable, storm::expressions::Expression> const& constantDefinitions) {
21 storm::prism::Program result = program.defineUndefinedConstants(constantDefinitions);
22 result = result.substituteConstantsFormulas();
23 return result;
24}
25
26storm::prism::Program preprocess(storm::prism::Program const& program, std::string const& constantDefinitionString) {
27 return preprocess(program, storm::utility::cli::parseConstantDefinitionString(program.getManager(), constantDefinitionString));
28}
29
31 if (program.hasUndefinedConstants()) {
32 std::vector<std::reference_wrapper<storm::prism::Constant const>> undefinedConstants = program.getUndefinedConstants();
33 std::stringstream stream;
34 bool printComma = false;
35 for (auto const& constant : undefinedConstants) {
36 if (printComma) {
37 stream << ", ";
38 } else {
39 printComma = true;
40 }
41 stream << constant.get().getName() << " (" << constant.get().getType() << ")";
42 }
43 stream << ".";
44 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Program still contains these undefined constants: " + stream.str());
45 }
46}
47} // namespace prism
48} // namespace utility
49} // namespace storm
Program defineUndefinedConstants(std::map< storm::expressions::Variable, storm::expressions::Expression > const &constantDefinitions) const
Defines the undefined constants according to the given map and returns the resulting program.
Definition Program.cpp:984
std::vector< std::reference_wrapper< Constant const > > getUndefinedConstants() const
Retrieves the undefined constants in the program.
Definition Program.cpp:368
Program substituteConstantsFormulas(bool substituteConstants=true, bool substituteFormulas=true) const
Substitutes all constants and/or formulas appearing in the expressions of the program by their defini...
Definition Program.cpp:1078
storm::expressions::ExpressionManager & getManager() const
Retrieves the manager responsible for the expressions of this program.
Definition Program.cpp:2359
bool hasUndefinedConstants() const
Retrieves whether there are undefined constants of any type in the program.
Definition Program.cpp:285
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
std::map< storm::expressions::Variable, storm::expressions::Expression > parseConstantDefinitionString(storm::expressions::ExpressionManager const &manager, std::string const &constantDefinitionString)
Definition cli.cpp:18
storm::prism::Program preprocess(storm::prism::Program const &program, std::map< storm::expressions::Variable, storm::expressions::Expression > const &constantDefinitions)
Definition prism.cpp:19
void requireNoUndefinedConstants(storm::prism::Program const &program)
Definition prism.cpp:30
LabParser.cpp.
Definition cli.cpp:18