3#include <boost/algorithm/string/join.hpp>
4#include <boost/functional/hash.hpp>
15namespace expressions {
22 booleanValues(this->getManager().getNumberOfBooleanVariables()),
23 integerValues(this->getManager().getNumberOfIntegerVariables() + this->getManager().getNumberOfBitVectorVariables()),
24 rationalValues(this->getManager().getNumberOfRationalVariables()) {
30 booleanValues = other.booleanValues;
31 integerValues = other.integerValues;
32 rationalValues = other.rationalValues;
39 booleanValues = other.booleanValues;
40 integerValues = other.integerValues;
41 rationalValues = other.rationalValues;
48 booleanValues = std::move(other.booleanValues);
49 integerValues = std::move(other.integerValues);
50 rationalValues = std::move(other.rationalValues);
56 this->
setManager(other.getManagerAsSharedPtr());
57 booleanValues = std::move(other.booleanValues);
58 integerValues = std::move(other.integerValues);
59 rationalValues = std::move(other.rationalValues);
65 return this->
getManager() == other.
getManager() && booleanValues == other.booleanValues && integerValues == other.integerValues &&
66 rationalValues == other.rationalValues;
70 return booleanValues[booleanVariable.
getOffset()];
74 return integerValues[integerVariable.
getOffset()];
78 return integerValues[bitVectorVariable.
getOffset()];
82 return rationalValues[rationalVariable.
getOffset()];
86 booleanValues[booleanVariable.
getOffset()] = value;
90 integerValues[integerVariable.
getOffset()] = value;
94 integerValues[bitVectorVariable.
getOffset()] = value;
98 rationalValues[rationalVariable.
getOffset()] = value;
102 std::vector<std::string> assignments;
103 for (
auto const& variable : selectedVariables) {
104 std::stringstream stream;
105 stream << variable.getName() <<
"=";
106 if (variable.hasBooleanType()) {
107 stream << std::boolalpha << this->
getBooleanValue(variable) << std::noboolalpha;
108 }
else if (variable.hasIntegerType()) {
110 }
else if (variable.hasRationalType()) {
113 STORM_LOG_THROW(
false, storm::exceptions::InvalidTypeException,
"Unexpected variable type.");
115 assignments.push_back(stream.str());
117 return "[" + boost::join(assignments,
", ") +
"]";
122 std::set<storm::expressions::Variable> allVariables;
124 allVariables.insert(e.first);
128 std::stringstream sstr;
131 if (!booleanValues.empty()) {
132 for (
auto element : booleanValues) {
133 sstr << element <<
" ";
137 if (!integerValues.empty()) {
138 for (
auto const& element : integerValues) {
139 sstr << element <<
" ";
143 if (!rationalValues.empty()) {
144 for (
auto const& element : rationalValues) {
145 sstr << element <<
" ";
157 if (variable.second.isBooleanType()) {
158 result[variable.first.getName()] = this->
getBooleanValue(variable.first);
159 }
else if (variable.second.isIntegerType()) {
160 result[variable.first.getName()] = this->
getIntegerValue(variable.first);
161 }
else if (variable.second.isRationalType()) {
162 result[variable.first.getName()] = storm::utility::convertNumber<storm::RationalNumber>(this->
getRationalValue(variable.first));
164 STORM_LOG_THROW(
false, storm::exceptions::InvalidTypeException,
"Unexpected variable type.");
171 out << valuation.
toString(
false) <<
'\n';
176 size_t seed = std::hash<std::vector<bool>>()(valuation->booleanValues);
177 boost::hash_combine(seed, valuation->integerValues);
178 boost::hash_combine(seed, valuation->rationalValues);
183 return *SimpleValuation1 == *SimpleValuation2;
187 return SimpleValuation1->booleanValues < SimpleValuation2->booleanValues || SimpleValuation1->integerValues < SimpleValuation2->integerValues ||
188 SimpleValuation1->rationalValues < SimpleValuation2->rationalValues;
A simple implementation of the valuation interface.
virtual std::string toPrettyString(std::set< storm::expressions::Variable > const &selectedVariables) const
Returns a string representation of the valuation of the selected variables.
virtual void setIntegerValue(Variable const &integerVariable, int_fast64_t value) override
Sets the value of the given integer variable to the provided value.
virtual int_fast64_t getIntegerValue(Variable const &integerVariable) const override
Retrieves the value of the given integer variable.
virtual double getRationalValue(Variable const &rationalVariable) const override
Retrieves the value of the given rational variable.
bool operator==(SimpleValuation const &other) const
Checks whether the two valuations are semantically equivalent.
virtual void setBooleanValue(Variable const &booleanVariable, bool value) override
Sets the value of the given boolean variable to the provided value.
SimpleValuation & operator=(SimpleValuation const &other)
storm::json< storm::RationalNumber > toJson() const
virtual std::string toString(bool pretty=true) const
virtual bool getBooleanValue(Variable const &booleanVariable) const override
Retrieves the value of the given boolean variable.
SimpleValuation()
Creates an empty simple valuation that is associated to no manager and has no variables.
virtual void setRationalValue(Variable const &rationalVariable, double value) override
Sets the value of the given boolean variable to the provided value.
virtual int_fast64_t getBitVectorValue(Variable const &bitVectorVariable) const override
Retrieves the value of the given bit vector variable.
virtual void setBitVectorValue(Variable const &bitVectorVariable, int_fast64_t value) override
Sets the value of the given bit vector variable to the provided value.
bool operator()(SimpleValuation *valuation1, SimpleValuation *valuation2) const
std::size_t operator()(SimpleValuation *valuation) const
bool operator()(SimpleValuation *valuation1, SimpleValuation *valuation2) const
The base class of all valuations of variables.
ExpressionManager const & getManager() const
Retrieves the manager responsible for the variables of this valuation.
void setManager(std::shared_ptr< ExpressionManager const > const &manager)
Sets the manager responsible for the variables in this valuation.
std::shared_ptr< ExpressionManager const > const & getManagerAsSharedPtr() const
Retrieves the manager responsible for the variables of this valuation.
uint_fast64_t getOffset() const
Retrieves the offset of the variable in the group of all equally typed variables.
#define STORM_LOG_THROW(cond, exception, message)
std::ostream & operator<<(std::ostream &stream, BaseExpression const &expression)
nlohmann::basic_json< std::map, std::vector, std::string, bool, int64_t, uint64_t, ValueType > json