3#include <boost/algorithm/string/join.hpp>
4#include <boost/functional/hash.hpp>
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;
75 if (!manager || manager.get() != &variable.
getManager()) {
79 return variable.
getOffset() < booleanValues.size();
82 return variable.
getOffset() < integerValues.size();
84 return variable.
getOffset() < rationalValues.size();
92 return booleanValues[booleanVariable.
getOffset()];
97 return integerValues[integerVariable.
getOffset()];
102 return integerValues[bitVectorVariable.
getOffset()];
107 return rationalValues[rationalVariable.
getOffset()];
112 booleanValues[booleanVariable.
getOffset()] = value;
117 integerValues[integerVariable.
getOffset()] = value;
122 integerValues[bitVectorVariable.
getOffset()] = value;
127 rationalValues[rationalVariable.
getOffset()] = value;
131 std::vector<std::string> assignments;
132 for (
auto const& variable : selectedVariables) {
133 std::stringstream stream;
134 stream << variable.getName() <<
"=";
135 if (variable.hasBooleanType()) {
136 stream << std::boolalpha << this->
getBooleanValue(variable) << std::noboolalpha;
137 }
else if (variable.hasIntegerType()) {
139 }
else if (variable.hasRationalType()) {
142 STORM_LOG_THROW(
false, storm::exceptions::InvalidTypeException,
"Unexpected variable type.");
144 assignments.push_back(stream.str());
146 return "[" + boost::join(assignments,
", ") +
"]";
151 std::set<storm::expressions::Variable> allVariables;
155 allVariables.insert(e.first);
160 std::stringstream sstr;
163 if (!booleanValues.empty()) {
164 for (
auto element : booleanValues) {
165 sstr << element <<
" ";
169 if (!integerValues.empty()) {
170 for (
auto const& element : integerValues) {
171 sstr << element <<
" ";
175 if (!rationalValues.empty()) {
176 for (
auto const& element : rationalValues) {
177 sstr << element <<
" ";
193 if (variable.second.isBooleanType()) {
194 result[variable.first.getName()] = this->
getBooleanValue(variable.first);
195 }
else if (variable.second.isIntegerType()) {
196 result[variable.first.getName()] = this->
getIntegerValue(variable.first);
197 }
else if (variable.second.isRationalType()) {
200 STORM_LOG_THROW(
false, storm::exceptions::InvalidTypeException,
"Unexpected variable type.");
207 out << valuation.
toString(
false) <<
'\n';
212 size_t seed = std::hash<std::vector<bool>>()(valuation->booleanValues);
213 boost::hash_combine(seed, valuation->integerValues);
214 boost::hash_combine(seed, valuation->rationalValues);
219 return *SimpleValuation1 == *SimpleValuation2;
223 return SimpleValuation1->booleanValues < SimpleValuation2->booleanValues || SimpleValuation1->integerValues < SimpleValuation2->integerValues ||
224 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.
bool contains(Variable const &variable) const
Checks whether this valuation stores a value for the given variable.
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
Valuation(std::shared_ptr< ExpressionManager const > const &manager)
Creates a valuation of all non-auxiliary variables managed by the given manager.
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.
bool hasBooleanType() const
Checks whether the variable is of boolean type.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this variable.
bool hasBitVectorType() const
Checks whether the variable is of a bit vector type.
uint_fast64_t getOffset() const
Retrieves the offset of the variable in the group of all equally typed variables.
bool hasIntegerType() const
Checks whether the variable is of integral type.
bool hasRationalType() const
Checks whether the variable is of rational type.
std::string const & getName() const
Retrieves the name of the variable.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
std::ostream & operator<<(std::ostream &stream, BaseExpression const &expression)
TargetType convertNumber(SourceType const &number)
nlohmann::basic_json< std::map, std::vector, std::string, bool, int64_t, uint64_t, ValueType > json