21template<
typename ValueType,
typename StateType>
27template<
typename ValueType,
typename StateType>
29 uint64_t actionIndex) {
30 auto val =
generator.currentStateToSimpleValuation();
31 bool res = func(val, actionIndex);
35template<
typename ValueType,
typename StateType>
50template<
typename ValueType,
typename StateType>
63template<
typename ValueType,
typename StateType>
66template<
typename ValueType,
typename StateType>
71template<
typename ValueType,
typename StateType>
76template<
typename ValueType,
typename StateType>
81 if (
options.isAddOverlappingGuardLabelSet()) {
86template<
typename ValueType,
typename StateType>
92 for (
auto const& v : variableInformation.locationVariables) {
93 builder.addIntegerVariable(v.variable, 0, v.highestValue);
95 for (
auto const& v : variableInformation.booleanVariables) {
99 builder.addIntegerVariable(v.variable, v.lowerBound, v.upperBound);
104template<
typename ValueType,
typename StateType>
109 builder.addBooleanVariable(v.variable);
112 for (
auto const& v : variableInformation.integerVariables) {
114 builder.addIntegerVariable(v.variable, v.lowerBound, v.upperBound);
117 for (
auto const& l : variableInformation.observationLabels) {
118 if (l.variable.hasBooleanType()) {
119 builder.addBooleanVariable(l.variable);
121 STORM_LOG_ASSERT(l.variable.hasIntegerType(),
"Observation label " << l.variable.getName() <<
" has neither boolean nor integer type.");
122 builder.addIntegerVariable(l.variable, std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::max());
129template<
typename ValueType,
typename StateType>
135 this->state = &
state;
138template<
typename ValueType,
typename StateType>
140 if (expression.
isTrue()) {
143 return evaluator->asBool(expression);
146template<
typename ValueType,
typename StateType>
151template<
typename ValueType,
typename StateType>
157template<
typename ValueType,
typename StateType>
166template<
typename ValueType,
typename StateType>
169 std::vector<StateType>
const& deadlockStateIndices, std::vector<StateType>
const& unexploredStateIndices,
170 std::vector<std::pair<std::string, storm::expressions::Expression>> labelsAndExpressions) {
171 labelsAndExpressions.insert(labelsAndExpressions.end(), this->options.getExpressionLabels().begin(), this->options.getExpressionLabels().end());
174 std::sort(labelsAndExpressions.begin(), labelsAndExpressions.end(),
175 [](std::pair<std::string, storm::expressions::Expression>
const& a, std::pair<std::string, storm::expressions::Expression>
const& b) {
176 return a.first < b.first;
178 auto it = std::unique(labelsAndExpressions.begin(), labelsAndExpressions.end(),
179 [](std::pair<std::string, storm::expressions::Expression>
const& a, std::pair<std::string, storm::expressions::Expression>
const& b) {
180 return a.first == b.first;
182 labelsAndExpressions.resize(std::distance(labelsAndExpressions.begin(), it));
188 for (
auto const&
label : labelsAndExpressions) {
192 auto const& states = stateStorage.
stateToId;
193 for (
auto const& stateIndexPair : states) {
197 for (
auto const&
label : labelsAndExpressions) {
205 auto addSpecialLabel = [&result](std::string
const&
label,
auto const& indices) {
208 for (
auto index : indices) {
213 addSpecialLabel(
"init", initialStateIndices);
214 addSpecialLabel(
"deadlock", deadlockStateIndices);
215 if (!unexploredStateIndices.empty()) {
216 addSpecialLabel(
"unexplored", unexploredStateIndices);
218 if (this->
options.isAddOverlappingGuardLabelSet()) {
220 "Label 'overlap_guards' is reserved when adding overlapping guard labels.");
225 "Label 'out_of_bounds' is reserved when adding out of bounds states.");
232template<
typename ValueType,
typename StateType>
234 return label ==
"init" ||
label ==
"deadlock" ||
label ==
"unexplored" ||
label ==
"overlap_guards" ||
label ==
"out_of_bounds";
237template<
typename ValueType,
typename StateType>
244template<
typename ValueType,
typename StateType>
248 bool foundPreviousMarkovianChoice =
false;
250 uint64_t numberOfChoicesToDelete = 0;
252 for (uint_fast64_t index = 0; index + numberOfChoicesToDelete < result.
getNumberOfChoices();) {
256 if (foundPreviousMarkovianChoice) {
265 ++numberOfChoicesToDelete;
269 std::swap(result.
getChoices().front(), choice);
271 foundPreviousMarkovianChoice =
true;
280 if (numberOfChoicesToDelete > 0) {
286template<
typename ValueType,
typename StateType>
291template<
typename ValueType,
typename StateType>
298template<
typename ValueType,
typename StateType>
303template<
typename ValueType,
typename StateType>
308template<
typename ValueType,
typename StateType>
310 std::vector<boost::any>& )
const {
311 STORM_LOG_ERROR_COND(!
options.isBuildChoiceOriginsSet(),
"Generating choice origins is not supported for the considered model format.");
315template<
typename ValueType,
typename StateType>
317 if (this->
mask.size() == 0) {
324template<
typename ValueType,
typename StateType>
326 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Generating player mappings is not supported for this model input format.");
329template<
typename ValueType,
typename StateType>
332 "Remapping of Ids during model building is not supported for overlapping guard statements.");
bool isTrue() const
Checks if the expression is equal to the boolean literal true.
This class is responsible for managing a set of typed variables and all expressions using these varia...
A simple implementation of the valuation interface.
Action masks are arguments you can give to the state generator that limit which states are generated.
virtual std::shared_ptr< storm::storage::sparse::ChoiceOrigins > generateChoiceOrigins(std::vector< boost::any > &dataForChoiceOrigins) const
NextStateGenerator(storm::expressions::ExpressionManager const &expressionManager, VariableInformation const &variableInformation, NextStateGeneratorOptions const &options, std::shared_ptr< ActionMask< ValueType, StateType > > const &=nullptr)
virtual std::map< std::string, storm::storage::PlayerIndex > getPlayerNameToIndexMap() const
std::shared_ptr< storm::expressions::ExpressionManager const > expressionManager
The expression manager used for evaluating expressions.
bool isSpecialLabel(std::string const &label) const
Checks if the input label has a special purpose (e.g.
std::unique_ptr< storm::expressions::ExpressionEvaluator< BaseValueType > > evaluator
An evaluator used to evaluate expressions.
std::shared_ptr< ActionMask< ValueType, StateType > > actionMask
virtual ~NextStateGenerator()
virtual storm::storage::BitVector evaluateObservationLabels(CompressedState const &state) const =0
void initializeSpecialStates()
Initializes the out-of-bounds state and states with overlapping guards.
std::string stateToString(CompressedState const &state) const
virtual storm::storage::sparse::Valuations initializeStateValuations() const
Initializes state valuations by adding the appropriate variables.
storm::utility::ConstantsComparator< ValueType > comparator
A comparator used to approximately compare constants, e.g., whether they sum to one....
void postprocess(StateBehavior< ValueType, StateType > &result)
boost::optional< std::vector< uint64_t > > overlappingGuardStates
A map that stores the indices of states with overlapping guards.
CompressedState const * state
The currently loaded state.
uint32_t observabilityClass(CompressedState const &state) const
virtual void extendStateInformation(storm::json< BaseValueType > &stateInfo) const
virtual ModelType getModelType() const =0
virtual storm::storage::sparse::Valuations initializeObservationValuations() const
NextStateGeneratorOptions const & getOptions() const
storm::expressions::SimpleValuation currentStateToSimpleValuation() const
CompressedState outOfBoundsState
A state that encodes the outOfBoundsState.
storm::storage::BitVector mask
The mask to compute the observability class (Constructed upon first use).
virtual void addStateValuation(storm::storage::sparse::state_type const ¤tStateIndex, storm::storage::sparse::Valuations &valuations) const
Adds the valuation for the currently loaded state to the given builder.
storm::json< ValueType > currentStateToJson(bool onlyObservable=false) const
void load(CompressedState const &state)
bool satisfies(storm::expressions::Expression const &expression) const
std::unordered_map< storm::storage::BitVector, uint32_t > observabilityMap
NextStateGeneratorOptions options
The options to be used for next-state generation.
void remapStateIds(std::function< StateType(StateType const &)> const &remapping)
Performs a remapping of all values stored by applying the given remapping.
uint64_t getStateSize() const
VariableInformation const & getVariableInformation() const
virtual storm::storage::sparse::Valuations makeObservationValuation() const
Adds the valuation for the currently loaded state.
virtual void unpackTransientVariableValuesIntoEvaluator(CompressedState const &state, storm::expressions::ExpressionEvaluator< BaseValueType > &evaluator) const
VariableInformation variableInformation
Information about how the variables are packed.
virtual storm::models::sparse::StateLabeling label(storm::storage::sparse::StateStorage< StateType > const &stateStorage, std::vector< StateType > const &initialStateIndices={}, std::vector< StateType > const &deadlockStateIndices={}, std::vector< StateType > const &unexploredStateIndices={})=0
std::vector< Choice< ValueType, StateType > > const & getChoices() const
Retrieves the vector of choices.
std::size_t getNumberOfChoices() const
Retrieves the number of choices in the behavior.
A particular instance of the action mask that uses a callback function to evaluate whether an action ...
StateValuationFunctionMask(std::function< bool(storm::expressions::SimpleValuation const &, uint64_t)> const &f)
bool query(storm::generator::NextStateGenerator< ValueType, StateType > const &generator, uint64_t actionIndex) override
void addLabel(std::string const &label)
Adds a new label to the labelings.
bool containsLabel(std::string const &label) const
Checks whether a label is registered within this labeling.
This class manages the labeling of the state space with a number of (atomic) labels.
void addLabelToState(std::string const &label, storm::storage::sparse::state_type state)
Adds a label to a given state.
ValueType getValue(storm::storage::BitVector const &key) const
Retrieves the value associated with the given key (if any).
bool contains(storm::storage::BitVector const &key) const
Checks if the given key is already contained in the map.
Helper to incrementally build a ValuationClassDescription, i.e.
Provides access to valuations of variables for a set of entities (e.g.
ValuationsStorage const & getStorage() const
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_ERROR_COND(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
void unpackStateIntoEvaluator(CompressedState const &state, VariableInformation const &variableInformation, storm::expressions::ExpressionEvaluator< ValueType > &evaluator)
Unpacks the compressed state into the evaluator.
void unpackStateAppendToValuations(CompressedState const &state, VariableInformation const &variableInformation, storm::storage::sparse::ValuationsStorage &valuations)
Appends the values of the variables in the given state to the valuations object.
storm::expressions::SimpleValuation unpackStateIntoValuation(CompressedState const &state, VariableInformation const &variableInformation, storm::expressions::ExpressionManager const &manager)
Converts the compressed state into an explicit representation in the form of a valuation.
uint32_t unpackStateToObservabilityClass(CompressedState const &state, storm::storage::BitVector const &observationVector, std::unordered_map< storm::storage::BitVector, uint32_t > &observabilityMap, storm::storage::BitVector const &mask)
std::string toString(CompressedState const &state, VariableInformation const &variableInformation)
Returns a (human readable) string representation of the variable valuation encoded by the given state...
CompressedState createOutOfBoundsState(VariableInformation const &varInfo, bool roundTo64Bit)
storm::storage::BitVector CompressedState
storm::builder::BuilderOptions NextStateGeneratorOptions
void unpackObservationClassIntoValuations(CompressedState const &observationClass, uint64_t const observationClassIndex, VariableInformation const &variableInformation, storm::storage::sparse::ValuationsStorage &valuations)
Sets the values of observable variables and observation expressions to the given observationClassInde...
storm::storage::BitVector computeObservabilityMask(VariableInformation const &variableInformation)
storm::json< ValueType > unpackStateIntoJson(CompressedState const &state, VariableInformation const &variableInformation, bool onlyObservable)
nlohmann::basic_json< std::map, std::vector, std::string, bool, int64_t, uint64_t, ValueType > json
bool isMarkovian() const
Retrieves whether the choice is Markovian.
uint64_t getNumberOfStates() const
storm::storage::BitVectorHashMap< StateType > stateToId