35template<
typename ValueType,
typename StateType>
41template<
typename ValueType,
typename StateType>
46 hasStateActionRewards(false),
47 evaluateRewardExpressionsAtEdges(false),
48 evaluateRewardExpressionsAtDestinations(false) {
55 if (features.hasArrays()) {
56 arrayEliminatorData = this->model.eliminateArrays(true);
57 this->options.substituteExpressions([this](storm::expressions::Expression const& exp) { return arrayEliminatorData.transformExpression(exp); });
60 STORM_LOG_THROW(features.empty(), storm::exceptions::NotSupportedException,
61 "The explicit next-state generator does not support the following model feature(s): " << features.toString() <<
".");
66 bool hasNonTrivialRewardExpressions =
false;
80 if (!hasNonTrivialRewardExpressions) {
81 for (
auto const& rewExpr : rewardExpressions) {
82 STORM_LOG_ASSERT(rewExpr.second.isVariable(),
"Expected trivial reward expression to be a variable. Got " << rewExpr.second <<
" instead.");
84 if (var.isTransient() && var.hasInitExpression() && !
storm::utility::isZero(var.getInitExpression().evaluateAsRational())) {
85 hasNonTrivialRewardExpressions =
true;
97 evaluateRewardExpressionsAtEdges =
true;
101 this->createSynchronizationInformation();
105 this->variableInformation =
107 this->variableInformation.registerArrayVariableReplacements(arrayEliminatorData);
109 this->transientVariableInformation.registerArrayVariableReplacements(arrayEliminatorData);
110 this->initializeSpecialStates();
113 this->evaluator = std::make_unique<storm::expressions::ExpressionEvaluator<ValueType>>(this->model.
getManager());
114 this->transientVariableInformation.setDefaultValuesInEvaluator(*this->evaluator);
117 buildRewardModelInformation();
122 if (expressionOrLabelAndBool.first.isExpression()) {
123 this->terminalStates.emplace_back(expressionOrLabelAndBool.first.getExpression(), expressionOrLabelAndBool.second);
126 if (!this->isSpecialLabel(expressionOrLabelAndBool.first.getLabel())) {
128 storm::exceptions::InvalidArgumentException,
129 "Terminal states refer to illegal label '" << expressionOrLabelAndBool.first.getLabel() <<
"'.");
133 storm::exceptions::InvalidArgumentException,
134 "Terminal states refer to non-boolean variable '" << expressionOrLabelAndBool.first.getLabel() <<
"'.");
136 "Terminal states refer to non-transient variable '" << expressionOrLabelAndBool.first.getLabel() <<
"'.");
145template<
typename ValueType,
typename StateType>
158template<
typename ValueType,
typename StateType>
160 auto features = model.getModelFeatures();
167 if (!features.empty()) {
168 STORM_LOG_INFO(
"The model can not be build as it contains these unsupported features: " << features.toString());
176template<
typename ValueType,
typename StateType>
178 switch (model.getModelType()) {
188 STORM_LOG_THROW(
false, storm::exceptions::WrongFormatException,
"Invalid model type.");
192template<
typename ValueType,
typename StateType>
194 return model.isDeterministicModel();
197template<
typename ValueType,
typename StateType>
199 return model.isDiscreteTimeModel();
202template<
typename ValueType,
typename StateType>
207template<
typename ValueType,
typename StateType>
209 if (locationVariable.
bitWidth == 0) {
216template<
typename ValueType,
typename StateType>
217void JaniNextStateGenerator<ValueType, StateType>::setLocation(CompressedState& state, LocationVariableInformation
const& locationVariable,
218 uint64_t locationIndex)
const {
219 if (locationVariable.bitWidth != 0) {
220 state.setFromInt(locationVariable.bitOffset, locationVariable.bitWidth, locationIndex);
224template<
typename ValueType,
typename StateType>
225std::vector<uint64_t> JaniNextStateGenerator<ValueType, StateType>::getLocations(CompressedState
const& state)
const {
226 std::vector<uint64_t> result(this->variableInformation.locationVariables.size());
228 auto resultIt = result.begin();
229 for (
auto it = this->variableInformation.locationVariables.begin(), ite = this->variableInformation.locationVariables.end(); it != ite; ++it, ++resultIt) {
230 if (it->bitWidth == 0) {
233 *resultIt = state.getAsInt(it->bitOffset, it->bitWidth);
240template<
typename ValueType,
typename StateType>
242 std::vector<StateType> initialStateIndices;
247 std::unique_ptr<storm::solver::SmtSolver>
solver = factory.
create(model.getExpressionManager());
249 std::vector<storm::expressions::Expression> rangeExpressions = model.getAllRangeExpressions(this->parallelAutomata);
250 for (
auto const& expression : rangeExpressions) {
253 solver->add(model.getInitialStatesExpression(this->parallelAutomata));
263 std::shared_ptr<storm::solver::SmtSolver::ModelReference> model =
solver->getModel();
265 bool variableValue = model->getBooleanValue(booleanVariable.variable);
267 blockingExpression = blockingExpression.
isInitialized() ? blockingExpression || localBlockingExpression : localBlockingExpression;
268 initialState.
set(booleanVariable.bitOffset, variableValue);
271 int_fast64_t variableValue = model->getIntegerValue(integerVariable.variable);
272 if (integerVariable.forceOutOfBoundsCheck || this->getOptions().isExplorationChecksSet()) {
273 STORM_LOG_THROW(variableValue >= integerVariable.lowerBound, storm::exceptions::WrongFormatException,
274 "The initial value for variable " << integerVariable.variable.getName() <<
" is lower than the lower bound.");
275 STORM_LOG_THROW(variableValue <= integerVariable.upperBound, storm::exceptions::WrongFormatException,
276 "The initial value for variable " << integerVariable.variable.getName() <<
" is higher than the upper bound.");
279 blockingExpression = blockingExpression.
isInitialized() ? blockingExpression || localBlockingExpression : localBlockingExpression;
280 initialState.
setFromInt(integerVariable.bitOffset, integerVariable.bitWidth,
281 static_cast<uint_fast64_t
>(variableValue - integerVariable.lowerBound));
285 std::vector<std::set<uint64_t>::const_iterator> initialLocationsIts;
286 std::vector<std::set<uint64_t>::const_iterator> initialLocationsItes;
287 for (
auto const& automatonRef : this->parallelAutomata) {
288 auto const& automaton = automatonRef.get();
289 initialLocationsIts.push_back(automaton.getInitialLocationIndices().cbegin());
290 initialLocationsItes.push_back(automaton.getInitialLocationIndices().cend());
293 initialLocationsIts, initialLocationsItes,
294 [
this, &initialState](uint64_t index, uint64_t value) { setLocation(initialState, this->
variableInformation.locationVariables[index], value); },
295 [&stateToIdCallback, &initialStateIndices, &initialState]() {
297 StateType
id = stateToIdCallback(initialState);
298 initialStateIndices.push_back(
id);
306 solver->add(blockingExpression);
309 STORM_LOG_DEBUG(
"Enumerated " << initialStateIndices.size() <<
" initial states using SMT solving.");
312 std::vector<std::vector<uint64_t>> allValues;
313 for (
auto const& aRef : this->parallelAutomata) {
314 auto const& aInitLocs = aRef.get().getInitialLocationIndices();
315 allValues.emplace_back(aInitLocs.begin(), aInitLocs.end());
317 uint64_t locEndIndex = allValues.size();
319 STORM_LOG_ASSERT(intVar.lowerBound <= intVar.upperBound,
"Expecting variable with non-empty set of possible values.");
323 uint64_t intEndIndex = allValues.size();
325 allValues.resize(allValues.size() + this->variableInformation.booleanVariables.size(),
326 std::vector<uint64_t>({static_cast<uint64_t>(0), static_cast<uint64_t>(1)}));
328 std::vector<std::vector<uint64_t>::const_iterator> its;
329 std::vector<std::vector<uint64_t>::const_iterator> ites;
330 for (
auto const& valVec : allValues) {
331 its.push_back(valVec.cbegin());
332 ites.push_back(valVec.cend());
339 [
this, &initialState, &locEndIndex, &intEndIndex](uint64_t index, uint64_t value) {
341 if (index < locEndIndex) {
344 }
else if (index < intEndIndex) {
347 initialState.
setFromInt(intVar.bitOffset, intVar.bitWidth, value);
353 initialState.
set(boolVar.bitOffset,
static_cast<bool>(value));
356 [&stateToIdCallback, &initialStateIndices, &initialState]() {
358 StateType
id = stateToIdCallback(initialState);
359 initialStateIndices.push_back(
id);
362 STORM_LOG_DEBUG(
"Enumerated " << initialStateIndices.size() <<
" initial states using brute force enumeration.");
364 return initialStateIndices;
367template<
typename ValueType,
typename StateType>
376 auto assignmentIt = assignments.
begin();
377 auto assignmentIte = assignments.end();
380 auto boolIt = this->variableInformation.booleanVariables.begin();
381 for (; assignmentIt != assignmentIte && assignmentIt->lValueIsVariable() && assignmentIt->getExpressionVariable().hasBooleanType(); ++assignmentIt) {
382 while (assignmentIt->getExpressionVariable() != boolIt->variable) {
385 state.
set(boolIt->bitOffset, expressionEvaluator.asBool(assignmentIt->getAssignedExpression()));
389 auto integerIt = this->variableInformation.integerVariables.begin();
390 for (; assignmentIt != assignmentIte && assignmentIt->lValueIsVariable() && assignmentIt->getExpressionVariable().hasIntegerType(); ++assignmentIt) {
391 while (assignmentIt->getExpressionVariable() != integerIt->variable) {
394 int_fast64_t assignedValue = expressionEvaluator.asInt(assignmentIt->getAssignedExpression());
396 if (assignedValue < integerIt->lowerBound || assignedValue > integerIt->upperBound) {
397 state = this->outOfBoundsState;
399 }
else if (integerIt->forceOutOfBoundsCheck || this->options.isExplorationChecksSet()) {
400 STORM_LOG_THROW(assignedValue >= integerIt->lowerBound, storm::exceptions::WrongFormatException,
401 "The update " << assignmentIt->getExpressionVariable().getName() <<
" := " << assignmentIt->getAssignedExpression()
402 <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
403 << assignmentIt->getExpressionVariable().getName() <<
"'.");
404 STORM_LOG_THROW(assignedValue <= integerIt->upperBound, storm::exceptions::WrongFormatException,
405 "The update " << assignmentIt->getExpressionVariable().getName() <<
" := " << assignmentIt->getAssignedExpression()
406 <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
407 << assignmentIt->getExpressionVariable().getName() <<
"'.");
409 state.
setFromInt(integerIt->bitOffset, integerIt->bitWidth, assignedValue - integerIt->lowerBound);
410 STORM_LOG_ASSERT(
static_cast<int_fast64_t
>(state.
getAsInt(integerIt->bitOffset, integerIt->bitWidth)) + integerIt->lowerBound == assignedValue,
411 "Writing to the bit vector bucket failed (read " << state.
getAsInt(integerIt->bitOffset, integerIt->bitWidth) <<
" but wrote "
412 << assignedValue <<
").");
415 for (; assignmentIt != assignmentIte && assignmentIt->lValueIsArrayAccess(); ++assignmentIt) {
416 auto const& arrayIndicesAsExpr = assignmentIt->getLValue().getArrayIndexVector();
417 std::vector<uint64_t> arrayIndices;
418 arrayIndices.reserve(arrayIndicesAsExpr.size());
419 for (
auto const& i : arrayIndicesAsExpr) {
420 arrayIndices.push_back(
static_cast<uint64_t
>(expressionEvaluator.asInt(i)));
422 if (assignmentIt->getAssignedExpression().hasIntegerType()) {
423 IntegerVariableInformation
const& intInfo =
424 this->variableInformation.getIntegerArrayVariableReplacement(assignmentIt->getLValue().getVariable().getExpressionVariable(), arrayIndices);
425 int_fast64_t assignedValue = expressionEvaluator.asInt(assignmentIt->getAssignedExpression());
428 if (assignedValue < intInfo.lowerBound || assignedValue > intInfo.upperBound) {
429 state = this->outOfBoundsState;
432 STORM_LOG_THROW(assignedValue >= intInfo.lowerBound, storm::exceptions::WrongFormatException,
433 "The update " << assignmentIt->getLValue() <<
" := " << assignmentIt->getAssignedExpression()
434 <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
435 << assignmentIt->getExpressionVariable().getName() <<
"'.");
436 STORM_LOG_THROW(assignedValue <= intInfo.upperBound, storm::exceptions::WrongFormatException,
437 "The update " << assignmentIt->getLValue() <<
" := " << assignmentIt->getAssignedExpression()
438 <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
439 << assignmentIt->getExpressionVariable().getName() <<
"'.");
441 state.
setFromInt(intInfo.bitOffset, intInfo.bitWidth, assignedValue - intInfo.lowerBound);
442 STORM_LOG_ASSERT(
static_cast<int_fast64_t
>(state.
getAsInt(intInfo.bitOffset, intInfo.bitWidth)) + intInfo.lowerBound == assignedValue,
443 "Writing to the bit vector bucket failed (read " << state.
getAsInt(intInfo.bitOffset, intInfo.bitWidth) <<
" but wrote "
444 << assignedValue <<
").");
445 }
else if (assignmentIt->getAssignedExpression().hasBooleanType()) {
446 BooleanVariableInformation
const& boolInfo =
447 this->variableInformation.getBooleanArrayVariableReplacement(assignmentIt->getLValue().getVariable().getExpressionVariable(), arrayIndices);
448 state.
set(boolInfo.bitOffset, expressionEvaluator.asBool(assignmentIt->getAssignedExpression()));
450 STORM_LOG_THROW(
false, storm::exceptions::UnexpectedException,
"Unhandled type of base variable.");
455 STORM_LOG_ASSERT(assignmentIt == assignmentIte,
"Not all assignments were consumed.");
458template<
typename ValueType,
typename StateType>
459void JaniNextStateGenerator<ValueType, StateType>::applyTransientUpdate(TransientVariableValuation<ValueType>& transientValuation,
461 storm::expressions::ExpressionEvaluator<ValueType>
const& expressionEvaluator)
const {
462 auto assignmentIt = transientAssignments.
begin();
463 auto assignmentIte = transientAssignments.
end();
466 auto boolIt = this->transientVariableInformation.booleanVariableInformation.begin();
467 for (; assignmentIt != assignmentIte && assignmentIt->lValueIsVariable() && assignmentIt->getExpressionVariable().hasBooleanType(); ++assignmentIt) {
468 while (assignmentIt->getExpressionVariable() != boolIt->variable) {
471 transientValuation.booleanValues.emplace_back(&(*boolIt), expressionEvaluator.asBool(assignmentIt->getAssignedExpression()));
474 auto integerIt = this->transientVariableInformation.integerVariableInformation.begin();
475 for (; assignmentIt != assignmentIte && assignmentIt->lValueIsVariable() && assignmentIt->getExpressionVariable().hasIntegerType(); ++assignmentIt) {
476 while (assignmentIt->getExpressionVariable() != integerIt->variable) {
479 int64_t assignedValue = expressionEvaluator.asInt(assignmentIt->getAssignedExpression());
481 STORM_LOG_THROW(!integerIt->lowerBound || assignedValue >= integerIt->lowerBound.get(), storm::exceptions::WrongFormatException,
482 "The update " << assignmentIt->getExpressionVariable().getName() <<
" := " << assignmentIt->getAssignedExpression()
483 <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
484 << assignmentIt->getExpressionVariable().getName() <<
"'.");
485 STORM_LOG_THROW(!integerIt->upperBound || assignedValue <= integerIt->upperBound.get(), storm::exceptions::WrongFormatException,
486 "The update " << assignmentIt->getExpressionVariable().getName() <<
" := " << assignmentIt->getAssignedExpression()
487 <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
488 << assignmentIt->getExpressionVariable().getName() <<
"'.");
490 transientValuation.integerValues.emplace_back(&(*integerIt), assignedValue);
493 auto rationalIt = this->transientVariableInformation.rationalVariableInformation.begin();
494 for (; assignmentIt != assignmentIte && assignmentIt->lValueIsVariable() && assignmentIt->getExpressionVariable().hasRationalType(); ++assignmentIt) {
495 while (assignmentIt->getExpressionVariable() != rationalIt->variable) {
498 transientValuation.rationalValues.emplace_back(&(*rationalIt), expressionEvaluator.asRational(assignmentIt->getAssignedExpression()));
502 for (; assignmentIt != assignmentIte && assignmentIt->lValueIsArrayAccess(); ++assignmentIt) {
503 auto const& arrayIndicesAsExpr = assignmentIt->getLValue().getArrayIndexVector();
504 std::vector<uint64_t> arrayIndices;
505 arrayIndices.reserve(arrayIndicesAsExpr.size());
506 for (
auto const& i : arrayIndicesAsExpr) {
507 arrayIndices.push_back(
static_cast<uint64_t
>(expressionEvaluator.asInt(i)));
509 storm::expressions::Type
const& baseType = assignmentIt->getLValue().getVariable().getExpressionVariable().getType();
511 auto const& intInfo = this->transientVariableInformation.getIntegerArrayVariableReplacement(
512 assignmentIt->getLValue().getVariable().getExpressionVariable(), arrayIndices);
513 int64_t assignedValue = expressionEvaluator.asInt(assignmentIt->getAssignedExpression());
515 STORM_LOG_THROW(assignedValue >= intInfo.lowerBound, storm::exceptions::WrongFormatException,
516 "The update " << assignmentIt->getLValue() <<
" := " << assignmentIt->getAssignedExpression()
517 <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
518 << assignmentIt->getExpressionVariable().getName() <<
"'.");
519 STORM_LOG_THROW(assignedValue <= intInfo.upperBound, storm::exceptions::WrongFormatException,
520 "The update " << assignmentIt->getLValue() <<
" := " << assignmentIt->getAssignedExpression()
521 <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
522 << assignmentIt->getExpressionVariable().getName() <<
"'.");
524 transientValuation.integerValues.emplace_back(&intInfo, assignedValue);
526 auto const& boolInfo = this->transientVariableInformation.getBooleanArrayVariableReplacement(
527 assignmentIt->getLValue().getVariable().getExpressionVariable(), arrayIndices);
528 transientValuation.booleanValues.emplace_back(&boolInfo, expressionEvaluator.asBool(assignmentIt->getAssignedExpression()));
530 auto const& rationalInfo = this->transientVariableInformation.getRationalArrayVariableReplacement(
531 assignmentIt->getLValue().getVariable().getExpressionVariable(), arrayIndices);
532 transientValuation.rationalValues.emplace_back(&rationalInfo, expressionEvaluator.asRational(assignmentIt->getAssignedExpression()));
534 STORM_LOG_THROW(
false, storm::exceptions::UnexpectedException,
"Unhandled type of base variable.");
539 STORM_LOG_ASSERT(assignmentIt == assignmentIte,
"Not all assignments were consumed.");
542template<
typename ValueType,
typename StateType>
543TransientVariableValuation<ValueType> JaniNextStateGenerator<ValueType, StateType>::getTransientVariableValuationAtLocations(
544 std::vector<uint64_t>
const& locations, storm::expressions::ExpressionEvaluator<ValueType>
const& evaluator)
const {
545 uint64_t automatonIndex = 0;
546 TransientVariableValuation<ValueType> transientVariableValuation;
547 for (
auto const& automatonRef : this->parallelAutomata) {
548 auto const& automaton = automatonRef.get();
549 uint64_t currentLocationIndex = locations[automatonIndex];
550 storm::jani::Location
const& location = automaton.getLocation(currentLocationIndex);
555 return transientVariableValuation;
558template<
typename ValueType,
typename StateType>
561 transientVariableInformation.setDefaultValuesInEvaluator(
evaluator);
562 auto transientVariableValuation = getTransientVariableValuationAtLocations(getLocations(
state),
evaluator);
563 transientVariableValuation.setInEvaluator(
evaluator, this->
getOptions().isExplorationChecksSet());
566template<
typename ValueType,
typename StateType>
573 builder.addIntegerVariable(v.variable, 0, v.highestValue);
576 builder.addBooleanVariable(v.variable);
579 builder.addIntegerVariable(v.variable, v.lowerBound, v.upperBound);
582 for (
auto const& varInfo : transientVariableInformation.booleanVariableInformation) {
583 builder.addBooleanVariable(varInfo.variable);
585 for (
auto const& varInfo : transientVariableInformation.integerVariableInformation) {
586 builder.addIntegerVariable(varInfo.variable, varInfo.lowerBound.value_or(std::numeric_limits<int64_t>::min()),
587 varInfo.upperBound.value_or(std::numeric_limits<int64_t>::max()));
589 for (
auto const& varInfo : transientVariableInformation.rationalVariableInformation) {
590 if (std::is_same_v<ValueType, storm::RationalNumber>) {
591 uint64_t
const bitSize = std::max<uint64_t>(64, this->
getOptions().getReservedBitsForUnboundedVariables());
592 builder.addRationalVariable(varInfo.variable, bitSize * 2);
594 STORM_LOG_THROW((std::is_same_v<ValueType, double>), storm::exceptions::NotSupportedException,
595 "State valuations for transient variables of the given value type are not supported.");
596 builder.addDoubleVariable(varInfo.variable);
602template<
typename ValueType,
typename StateType>
608 auto transientVariableValuation = getTransientVariableValuationAtLocations(getLocations(*this->state), *this->evaluator);
609 transientVariableValuation.setInValuations(currentStateIndex, transientVariableInformation, valuations.
getStorage());
612template<
typename ValueType,
typename StateType>
620 std::vector<uint64_t> locations = getLocations(*this->state);
624 auto transientVariableValuation = getTransientVariableValuationAtLocations(locations, *this->evaluator);
625 transientVariableValuation.setInEvaluator(*this->evaluator, this->
getOptions().isExplorationChecksSet());
632 if (this->evaluator->asBool(expressionBool.first) == expressionBool.second) {
634 this->transientVariableInformation.setDefaultValuesInEvaluator(*this->evaluator);
641 this->transientVariableInformation.setDefaultValuesInEvaluator(*this->evaluator);
645 std::vector<Choice<ValueType>> allChoices;
646 if (this->
getOptions().isApplyMaximalProgressAssumptionSet()) {
649 if (allChoices.empty()) {
651 allChoices = getActionChoices(locations, *this->state, stateToIdCallback,
EdgeFilter::WithRate);
654 allChoices = getActionChoices(locations, *this->state, stateToIdCallback);
656 std::size_t totalNumberOfChoices = allChoices.size();
660 if (totalNumberOfChoices == 0) {
677 for (
auto const& choice : allChoices) {
678 for (
auto const& stateProbabilityPair : choice) {
680 globalChoice.
addProbability(stateProbabilityPair.first, stateProbabilityPair.second / totalNumberOfChoices);
682 globalChoice.
addProbability(stateProbabilityPair.first, stateProbabilityPair.second);
687 totalExitRate += choice.getTotalMass();
692 for (
auto const& choice : allChoices) {
693 if (hasStateActionRewards) {
694 for (uint_fast64_t rewardVariableIndex = 0; rewardVariableIndex < rewardExpressions.size(); ++rewardVariableIndex) {
695 stateActionRewards[rewardVariableIndex] += choice.getRewards()[rewardVariableIndex] * choice.getTotalMass() / totalExitRate;
703 globalChoice.
addRewards(std::move(stateActionRewards));
707 allChoices.push_back(std::move(globalChoice));
711 for (
auto& choice : allChoices) {
720template<
typename ValueType,
typename StateType>
725 boost::optional<ValueType> exitRate = boost::none;
727 exitRate = this->evaluator->asRational(edge.
getRate());
730 Choice<ValueType> choice(outputActionIndex,
static_cast<bool>(exitRate));
731 std::vector<ValueType> stateActionRewards;
734 TransientVariableValuation<ValueType> transientVariableValuation;
740 transientVariableValuation.clear();
742 transientVariableValuation.setInEvaluator(*this->evaluator, this->getOptions().isExplorationChecksSet());
744 stateActionRewards = evaluateRewardExpressions();
745 transientVariableInformation.setDefaultValuesInEvaluator(*this->evaluator);
754 bool evaluatorChanged =
false;
761 applyUpdate(newState, destination, this->variableInformation.locationVariables[automatonIndex], assignmentLevel, *this->evaluator);
762 if (hasTransientAssignments) {
764 "Transition rewards are not supported and scaling to action rewards is disabled.");
765 transientVariableValuation.clear();
768 transientVariableValuation.setInEvaluator(*this->evaluator, this->getOptions().isExplorationChecksSet());
769 evaluatorChanged =
true;
771 if (assignmentLevel < highestLevel) {
772 while (assignmentLevel < highestLevel) {
775 evaluatorChanged =
true;
776 applyUpdate(newState, destination, this->variableInformation.locationVariables[automatonIndex], assignmentLevel, *this->evaluator);
777 if (hasTransientAssignments) {
778 transientVariableValuation.clear();
781 transientVariableValuation.setInEvaluator(*this->evaluator, this->getOptions().isExplorationChecksSet());
782 evaluatorChanged =
true;
786 if (evaluateRewardExpressionsAtDestinations) {
788 evaluatorChanged =
true;
789 addEvaluatedRewardExpressions(stateActionRewards, probability);
792 if (evaluatorChanged) {
795 if (hasTransientAssignments) {
796 this->transientVariableInformation.setDefaultValuesInEvaluator(*this->evaluator);
800 StateType stateIndex = stateToIdCallback(newState);
803 probability = exitRate ? exitRate.get() * probability : probability;
804 choice.addProbability(stateIndex, probability);
807 probabilitySum += probability;
813 choice.addRewards(std::move(stateActionRewards));
818 storm::exceptions::WrongFormatException,
"Probabilities do not sum to one for edge (actually sum to " << probabilitySum <<
").");
824template<
typename ValueType,
typename StateType>
825void JaniNextStateGenerator<ValueType, StateType>::generateSynchronizedDistribution(storm::storage::BitVector
const& state,
826 AutomataEdgeSets
const& edgeCombination,
827 std::vector<EdgeSetWithIndices::const_iterator>
const& iteratorList,
828 storm::generator::Distribution<StateType, ValueType>& distribution,
829 std::vector<ValueType>& stateActionRewards, EdgeIndexSet& edgeIndices,
830 StateToIdCallback stateToIdCallback) {
832 int64_t lowestDestinationAssignmentLevel = std::numeric_limits<int64_t>::max();
833 int64_t highestDestinationAssignmentLevel = std::numeric_limits<int64_t>::min();
834 int64_t lowestEdgeAssignmentLevel = std::numeric_limits<int64_t>::max();
835 int64_t highestEdgeAssignmentLevel = std::numeric_limits<int64_t>::min();
836 uint64_t numDestinations = 1;
837 for (uint_fast64_t i = 0;
i < iteratorList.size(); ++
i) {
838 if (this->getOptions().isBuildChoiceOriginsSet()) {
839 auto automatonIndex = model.
getAutomatonIndex(parallelAutomata[edgeCombination[i].first].get().getName());
842 storm::jani::Edge
const& edge = *iteratorList[
i]->second;
853 TransientVariableValuation<ValueType> transientVariableValuation;
854 if (evaluateRewardExpressionsAtEdges && lowestEdgeAssignmentLevel <= highestEdgeAssignmentLevel) {
855 for (int64_t assignmentLevel = lowestEdgeAssignmentLevel; assignmentLevel <= highestEdgeAssignmentLevel; ++assignmentLevel) {
856 transientVariableValuation.clear();
857 for (uint_fast64_t i = 0;
i < iteratorList.size(); ++
i) {
858 storm::jani::Edge
const& edge = *iteratorList[
i]->second;
861 transientVariableValuation.setInEvaluator(*this->evaluator, this->getOptions().isExplorationChecksSet());
864 transientVariableInformation.setDefaultValuesInEvaluator(*this->evaluator);
867 std::vector<storm::jani::EdgeDestination const*> destinations;
868 std::vector<LocationVariableInformation const*> locationVars;
869 destinations.reserve(iteratorList.size());
870 locationVars.reserve(iteratorList.size());
872 for (uint64_t destinationId = 0; destinationId < numDestinations; ++destinationId) {
874 destinations.clear();
875 locationVars.clear();
876 transientVariableValuation.clear();
880 uint64_t destinationIndex = destinationId;
881 for (uint64_t i = 0;
i < iteratorList.size(); ++
i) {
882 storm::jani::Edge
const& edge = *iteratorList[
i]->second;
885 destinations.push_back(&edge.
getDestination(localDestinationIndex));
886 locationVars.push_back(&this->variableInformation.locationVariables[edgeCombination[i].first]);
888 ValueType probability = this->evaluator->asRational(destinations.back()->getProbability());
890 successorProbability *= probability * this->evaluator->asRational(edge.
getRate());
892 successorProbability *= probability;
898 applyUpdate(successorState, *destinations.back(), *locationVars.back(), lowestDestinationAssignmentLevel, *this->evaluator);
899 applyTransientUpdate(transientVariableValuation,
900 destinations.back()->getOrderedAssignments().getTransientAssignments(lowestDestinationAssignmentLevel), *this->evaluator);
904 bool evaluatorChanged =
false;
906 for (int64_t assignmentLevel = lowestDestinationAssignmentLevel + 1; assignmentLevel <= highestDestinationAssignmentLevel; ++assignmentLevel) {
908 transientVariableValuation.setInEvaluator(*this->evaluator, this->getOptions().isExplorationChecksSet());
909 transientVariableValuation.clear();
910 evaluatorChanged =
true;
911 auto locationVarIt = locationVars.begin();
912 for (
auto const& destPtr : destinations) {
913 applyUpdate(successorState, *destPtr, **locationVarIt, assignmentLevel, *this->evaluator);
914 applyTransientUpdate(transientVariableValuation, destinations.back()->getOrderedAssignments().getTransientAssignments(assignmentLevel),
919 if (!transientVariableValuation.empty()) {
920 evaluatorChanged =
true;
921 transientVariableValuation.setInEvaluator(*this->evaluator, this->getOptions().isExplorationChecksSet());
923 if (evaluateRewardExpressionsAtDestinations) {
925 evaluatorChanged =
true;
926 addEvaluatedRewardExpressions(stateActionRewards, successorProbability);
928 if (evaluatorChanged) {
931 this->transientVariableInformation.setDefaultValuesInEvaluator(*this->evaluator);
934 StateType
id = stateToIdCallback(successorState);
935 distribution.
add(
id, successorProbability);
940template<
typename ValueType,
typename StateType>
941void JaniNextStateGenerator<ValueType, StateType>::expandSynchronizingEdgeCombination(AutomataEdgeSets
const& edgeCombination, uint64_t outputActionIndex,
942 CompressedState
const& state, StateToIdCallback stateToIdCallback,
943 std::vector<Choice<ValueType>>& newChoices) {
946 checkGlobalVariableWritesValid(edgeCombination);
949 std::vector<EdgeSetWithIndices::const_iterator> iteratorList(edgeCombination.size());
952 for (
size_t i = 0;
i < edgeCombination.size(); ++
i) {
953 iteratorList[
i] = edgeCombination[
i].second.cbegin();
956 storm::generator::Distribution<StateType, ValueType> distribution;
961 distribution.
clear();
963 EdgeIndexSet edgeIndices;
967 generateSynchronizedDistribution(state, edgeCombination, iteratorList, distribution, stateActionRewards, edgeIndices, stateToIdCallback);
973 newChoices.emplace_back(outputActionIndex);
976 Choice<ValueType>& choice = newChoices.back();
979 if (this->getOptions().isBuildChoiceOriginsSet()) {
980 choice.addOriginData(boost::any(std::move(edgeIndices)));
984 choice.addRewards(std::move(stateActionRewards));
988 choice.reserve(std::distance(distribution.
begin(), distribution.
end()));
989 for (
auto const& stateProbability : distribution) {
990 choice.addProbability(stateProbability.getState(), stateProbability.getValue());
993 probabilitySum += stateProbability.getValue();
1000 storm::exceptions::WrongFormatException,
1001 "Sum of update probabilities do not sum to one for some edge (actually sum to " << probabilitySum <<
").");
1011 bool movedIterator =
false;
1012 for (uint64_t j = 0; !movedIterator && j < iteratorList.size(); ++j) {
1014 if (iteratorList[j] != edgeCombination[j].second.end()) {
1015 movedIterator =
true;
1018 iteratorList[j] = edgeCombination[j].second.begin();
1022 done = !movedIterator;
1026template<
typename ValueType,
typename StateType>
1027std::vector<Choice<ValueType>> JaniNextStateGenerator<ValueType, StateType>::getActionChoices(std::vector<uint64_t>
const& locations,
1028 CompressedState
const& state, StateToIdCallback stateToIdCallback,
1029 EdgeFilter
const& edgeFilter) {
1030 std::vector<Choice<ValueType>> result;
1034 std::vector<EdgeSetWithIndices const*> edgeSetsMemory;
1036 std::vector<typename EdgeSetWithIndices::const_iterator> edgeIteratorMemory;
1038 for (OutputAndEdges
const& outputAndEdges : edges) {
1039 auto const& edges = outputAndEdges.second;
1040 if (edges.size() == 1) {
1042 auto const& nonsychingEdges = edges.front();
1043 uint64_t automatonIndex = nonsychingEdges.first;
1045 auto edgesIt = nonsychingEdges.second.find(locations[automatonIndex]);
1046 if (edgesIt != nonsychingEdges.second.end()) {
1047 for (
auto const& indexAndEdge : edgesIt->second) {
1048 if (edgeFilter != EdgeFilter::All) {
1049 STORM_LOG_ASSERT(edgeFilter == EdgeFilter::WithRate || edgeFilter == EdgeFilter::WithoutRate,
"Unexpected edge filter.");
1050 if ((edgeFilter == EdgeFilter::WithRate) != indexAndEdge.second->hasRate()) {
1054 if (!this->evaluator->asBool(indexAndEdge.second->getGuard())) {
1058 uint64_t actionIndex = outputAndEdges.first ? outputAndEdges.first.get() : indexAndEdge.second->getActionIndex();
1059 result.push_back(expandNonSynchronizingEdge(*indexAndEdge.second, actionIndex, automatonIndex, state, stateToIdCallback));
1061 if (this->getOptions().isBuildChoiceOriginsSet()) {
1062 auto modelAutomatonIndex = model.
getAutomatonIndex(parallelAutomata[automatonIndex].get().getName());
1064 result.back().addOriginData(boost::any(std::move(edgeIndex)));
1067 if (this->getOptions().isBuildChoiceLabelsSet()) {
1078 STORM_LOG_ASSERT(outputAndEdges.first,
"Need output action index for synchronization.");
1080 uint64_t outputActionIndex = outputAndEdges.first.get();
1083 bool productiveCombination =
true;
1086 edgeSetsMemory.clear();
1087 for (
auto const& automatonAndEdges : outputAndEdges.second) {
1088 uint64_t automatonIndex = automatonAndEdges.first;
1089 LocationsAndEdges
const& locationsAndEdges = automatonAndEdges.second;
1090 auto edgesIt = locationsAndEdges.find(locations[automatonIndex]);
1091 if (edgesIt == locationsAndEdges.end()) {
1092 productiveCombination =
false;
1095 edgeSetsMemory.push_back(&edgesIt->second);
1098 if (productiveCombination) {
1100 edgeIteratorMemory.clear();
1101 for (
auto const& edgesIt : edgeSetsMemory) {
1102 bool atLeastOneEdge =
false;
1103 EdgeSetWithIndices
const& edgeSetWithIndices = *edgesIt;
1104 for (
auto indexAndEdgeIt = edgeSetWithIndices.begin(), indexAndEdgeIte = edgeSetWithIndices.end(); indexAndEdgeIt != indexAndEdgeIte;
1107 if (edgeFilter != EdgeFilter::All) {
1108 STORM_LOG_ASSERT(edgeFilter == EdgeFilter::WithRate || edgeFilter == EdgeFilter::WithoutRate,
"Unexpected edge filter.");
1109 if ((edgeFilter == EdgeFilter::WithRate) != indexAndEdgeIt->second->hasRate()) {
1114 if (!this->evaluator->asBool(indexAndEdgeIt->second->getGuard())) {
1119 atLeastOneEdge =
true;
1120 edgeIteratorMemory.push_back(indexAndEdgeIt);
1125 if (!atLeastOneEdge) {
1126 productiveCombination =
false;
1133 if (productiveCombination) {
1134 AutomataEdgeSets automataEdgeSets;
1135 automataEdgeSets.reserve(outputAndEdges.second.size());
1136 STORM_LOG_ASSERT(edgeSetsMemory.size() == outputAndEdges.second.size(),
"Unexpected number of edge sets stored.");
1137 STORM_LOG_ASSERT(edgeIteratorMemory.size() == outputAndEdges.second.size(),
"Unexpected number of edge iterators stored.");
1138 auto edgeSetIt = edgeSetsMemory.begin();
1139 auto edgeIteratorIt = edgeIteratorMemory.begin();
1140 for (
auto const& automatonAndEdges : outputAndEdges.second) {
1141 EdgeSetWithIndices enabledEdgesOfAutomaton;
1142 uint64_t automatonIndex = automatonAndEdges.first;
1143 EdgeSetWithIndices
const& edgeSetWithIndices = **edgeSetIt;
1144 auto indexAndEdgeIt = *edgeIteratorIt;
1146 enabledEdgesOfAutomaton.emplace_back(*indexAndEdgeIt);
1147 auto indexAndEdgeIte = edgeSetWithIndices.end();
1148 for (++indexAndEdgeIt; indexAndEdgeIt != indexAndEdgeIte; ++indexAndEdgeIt) {
1150 if (edgeFilter != EdgeFilter::All) {
1151 STORM_LOG_ASSERT(edgeFilter == EdgeFilter::WithRate || edgeFilter == EdgeFilter::WithoutRate,
"Unexpected edge filter.");
1152 if ((edgeFilter == EdgeFilter::WithRate) != indexAndEdgeIt->second->hasRate()) {
1157 if (!this->evaluator->asBool(indexAndEdgeIt->second->getGuard())) {
1161 enabledEdgesOfAutomaton.emplace_back(*indexAndEdgeIt);
1163 automataEdgeSets.emplace_back(std::move(automatonIndex), std::move(enabledEdgesOfAutomaton));
1168 expandSynchronizingEdgeCombination(automataEdgeSets, outputActionIndex, state, stateToIdCallback, result);
1176template<
typename ValueType,
typename StateType>
1177void JaniNextStateGenerator<ValueType, StateType>::checkGlobalVariableWritesValid(AutomataEdgeSets
const& enabledEdges)
const {
1180 std::map<storm::expressions::Variable, uint64_t> writtenGlobalVariables;
1181 for (
auto edgeSetIt = enabledEdges.begin(), edgeSetIte = enabledEdges.end(); edgeSetIt != edgeSetIte; ++edgeSetIt) {
1182 for (
auto const& indexAndEdge : edgeSetIt->second) {
1183 for (
auto const& globalVariable : indexAndEdge.second->getWrittenGlobalVariables()) {
1184 auto it = writtenGlobalVariables.find(globalVariable);
1186 auto index = std::distance(enabledEdges.begin(), edgeSetIt);
1187 if (it != writtenGlobalVariables.end()) {
1188 STORM_LOG_THROW(it->second ==
static_cast<uint64_t
>(index), storm::exceptions::WrongFormatException,
1189 "Multiple writes to global variable '" << globalVariable.getName() <<
"' in synchronizing edges.");
1191 writtenGlobalVariables.emplace(globalVariable, index);
1198template<
typename ValueType,
typename StateType>
1200 return rewardExpressions.size();
1203template<
typename ValueType,
typename StateType>
1205 return rewardModelInformation[index];
1208template<
typename ValueType,
typename StateType>
1210 std::vector<StateType>
const& initialStateIndices,
1211 std::vector<StateType>
const& deadlockStateIndices,
1212 std::vector<StateType>
const& unexploredStateIndices) {
1215 std::vector<std::pair<std::string, storm::expressions::Expression>> transientVariableExpressions;
1216 for (
auto const& variable : model.getGlobalVariables().getTransientVariables()) {
1217 if (variable.getType().isBasicType() && variable.getType().asBasicType().isBooleanType()) {
1218 if (this->options.
isBuildAllLabelsSet() || this->options.getLabelNames().find(variable.getName()) != this->options.getLabelNames().end()) {
1219 transientVariableExpressions.emplace_back(variable.getName(), variable.getExpressionVariable().getExpression());
1224 transientVariableExpressions);
1227template<
typename ValueType,
typename StateType>
1228std::vector<ValueType> JaniNextStateGenerator<ValueType, StateType>::evaluateRewardExpressions()
const {
1229 std::vector<ValueType> result;
1230 result.reserve(rewardExpressions.size());
1231 for (
auto const& rewardExpression : rewardExpressions) {
1232 result.push_back(this->evaluator->asRational(rewardExpression.second));
1237template<
typename ValueType,
typename StateType>
1238void JaniNextStateGenerator<ValueType, StateType>::addEvaluatedRewardExpressions(std::vector<ValueType>& rewards, ValueType
const& factor)
const {
1239 STORM_LOG_ASSERT(rewards.size() == rewardExpressions.size(),
"Reward count mismatch.");
1240 auto rewIt = rewards.begin();
1241 for (
auto const& rewardExpression : rewardExpressions) {
1242 (*rewIt) += factor * this->evaluator->asRational(rewardExpression.second);
1247template<
typename ValueType,
typename StateType>
1248void JaniNextStateGenerator<ValueType, StateType>::buildRewardModelInformation() {
1249 for (
auto const& rewardModel : rewardExpressions) {
1250 storm::jani::RewardModelInformation info(this->model, rewardModel.second);
1251 rewardModelInformation.emplace_back(rewardModel.first, info.hasStateRewards(),
false,
false);
1253 "Transition rewards are not supported and a reduction to action-based rewards was not possible.");
1254 if (info.hasTransitionRewards()) {
1255 evaluateRewardExpressionsAtDestinations =
true;
1257 if (info.hasActionRewards() || (this->options.isScaleAndLiftTransitionRewardsSet() && info.hasTransitionRewards())) {
1258 hasStateActionRewards =
true;
1259 rewardModelInformation.back().setHasStateActionRewards();
1262 if (!hasStateActionRewards) {
1263 evaluateRewardExpressionsAtDestinations =
false;
1264 evaluateRewardExpressionsAtEdges =
false;
1268template<
typename ValueType,
typename StateType>
1269void JaniNextStateGenerator<ValueType, StateType>::createSynchronizationInformation() {
1274 this->parallelAutomata.push_back(automaton);
1276 LocationsAndEdges locationsAndEdges;
1277 uint64_t edgeIndex = 0;
1278 for (
auto const& edge : automaton.getEdges()) {
1283 AutomataAndEdges automataAndEdges;
1284 automataAndEdges.emplace_back(std::make_pair(0, std::move(locationsAndEdges)));
1286 this->edges.emplace_back(std::make_pair(boost::none, std::move(automataAndEdges)));
1289 storm::jani::ParallelComposition
const& parallelComposition = topLevelComposition.
asParallelComposition();
1291 uint64_t automatonIndex = 0;
1293 STORM_LOG_THROW(composition->isAutomatonComposition(), storm::exceptions::WrongFormatException,
"Expected flat parallel composition.");
1294 STORM_LOG_THROW(composition->asAutomatonComposition().getInputEnabledActions().empty(), storm::exceptions::NotSupportedException,
1295 "Input-enabled actions are not supported right now.");
1297 this->parallelAutomata.push_back(this->model.
getAutomaton(composition->asAutomatonComposition().getAutomatonName()));
1300 LocationsAndEdges locationsAndEdges;
1301 uint64_t edgeIndex = 0;
1302 for (
auto const& edge : parallelAutomata.back().get().getEdges()) {
1309 if (!locationsAndEdges.empty()) {
1310 AutomataAndEdges automataAndEdges;
1311 automataAndEdges.emplace_back(std::make_pair(automatonIndex, std::move(locationsAndEdges)));
1312 this->edges.emplace_back(std::make_pair(boost::none, std::move(automataAndEdges)));
1318 uint64_t outputActionIndex = this->model.
getActionIndex(vector.getOutput());
1320 AutomataAndEdges automataAndEdges;
1321 bool atLeastOneEdge =
true;
1322 uint64_t automatonIndex = 0;
1323 for (
auto const& element : vector.getInput()) {
1325 LocationsAndEdges locationsAndEdges;
1327 uint64_t edgeIndex = 0;
1328 for (
auto const& edge : parallelAutomata[automatonIndex].get().getEdges()) {
1334 if (locationsAndEdges.empty()) {
1335 atLeastOneEdge =
false;
1338 automataAndEdges.emplace_back(std::make_pair(automatonIndex, std::move(locationsAndEdges)));
1343 if (atLeastOneEdge) {
1344 this->edges.emplace_back(std::make_pair(outputActionIndex, std::move(automataAndEdges)));
1349 STORM_LOG_TRACE(
"Number of synchronizations: " << this->edges.size() <<
".");
1352template<
typename ValueType,
typename StateType>
1354 std::vector<boost::any>& dataForChoiceOrigins)
const {
1355 if (!this->
getOptions().isBuildChoiceOriginsSet()) {
1359 std::vector<uint_fast64_t> identifiers;
1360 identifiers.reserve(dataForChoiceOrigins.size());
1362 std::map<EdgeIndexSet, uint_fast64_t> edgeIndexSetToIdentifierMap;
1365 edgeIndexSetToIdentifierMap.insert(std::make_pair(
EdgeIndexSet(), 0));
1366 uint_fast64_t currentIdentifier = 1;
1367 for (boost::any& originData : dataForChoiceOrigins) {
1368 STORM_LOG_ASSERT(originData.empty() || boost::any_cast<EdgeIndexSet>(&originData) !=
nullptr,
1369 "Origin data has unexpected type: " << originData.type().name() <<
".");
1371 EdgeIndexSet currentEdgeIndexSet = originData.empty() ?
EdgeIndexSet() : boost::any_cast<EdgeIndexSet>(std::move(originData));
1372 auto insertionRes = edgeIndexSetToIdentifierMap.emplace(std::move(currentEdgeIndexSet), currentIdentifier);
1373 identifiers.push_back(insertionRes.first->second);
1374 if (insertionRes.second) {
1375 ++currentIdentifier;
1379 std::vector<EdgeIndexSet> identifierToEdgeIndexSetMapping(currentIdentifier);
1380 for (
auto const& setIdPair : edgeIndexSetToIdentifierMap) {
1381 identifierToEdgeIndexSetMapping[setIdPair.second] = setIdPair.first;
1384 return std::make_shared<storm::storage::sparse::JaniChoiceOrigins>(std::make_shared<storm::jani::Model>(model), std::move(identifiers),
1385 std::move(identifierToEdgeIndexSetMapping));
1388template<
typename ValueType,
typename StateType>
1390 STORM_LOG_WARN(
"There are no observation labels in JANI currenty");
1394template<
typename ValueType,
typename StateType>
1395void JaniNextStateGenerator<ValueType, StateType>::checkValid()
const {
1398 std::vector<std::reference_wrapper<storm::jani::Constant const>> undefinedConstants = model.
getUndefinedConstants();
1399 std::stringstream stream;
1400 bool printComma =
false;
1401 for (
auto const& constant : undefinedConstants) {
1407 stream << constant.get().getName() <<
" (" << constant.get().getType() <<
")";
1410 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Program still contains these undefined constants: " + stream.str() +
".");
1413 "The input model contains undefined constants that influence the graph structure of the underlying model, which is not allowed.");
1417template class JaniNextStateGenerator<double>;
1418template class JaniNextStateGenerator<storm::RationalNumber>;
1419template class JaniNextStateGenerator<storm::RationalFunction>;
uint64_t getReservedBitsForUnboundedVariables() const
std::set< std::string > const & getRewardModelNames() const
Which reward models are built.
bool isScaleAndLiftTransitionRewardsSet() const
bool isBuildAllRewardModelsSet() const
bool isBuildChoiceLabelsSet() const
bool isBuildChoiceOriginsSet() const
std::vector< std::pair< LabelOrExpression, bool > > const & getTerminalStates() const
bool isExplorationChecksSet() const
bool isBuildAllLabelsSet() const
bool hasTerminalStates() const
bool isAddOverlappingGuardLabelSet() const
bool isAddOutOfBoundsStateSet() const
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
bool isInitialized() const
Checks whether the object encapsulates a base-expression.
Expression integer(int_fast64_t value) const
Creates an expression that characterizes the given integer literal.
bool isBooleanType() const
Checks whether this type is a boolean type.
bool isIntegerType() const
Checks whether this type is an integral type.
bool isRationalType() const
Checks whether this type is a rational type.
storm::expressions::Expression getExpression() const
Retrieves an expression that represents the variable.
void clear()
Clears this distribution.
ContainerType::iterator begin()
Access to iterators over the entries of the distribution.
void compress()
Compresses the internal storage by summing the values of entries which agree on the index.
ContainerType::iterator end()
void add(DistributionEntry< IndexType, ValueType > const &entry)
Adds the given entry to the distribution.
storm::storage::FlatSet< uint_fast64_t > EdgeIndexSet
virtual ModelType getModelType() const override
static storm::jani::ModelFeatures getSupportedJaniFeatures()
Returns the jani features with which this builder can deal natively.
virtual std::shared_ptr< storm::storage::sparse::ChoiceOrigins > generateChoiceOrigins(std::vector< boost::any > &dataForChoiceOrigins) const override
virtual StateBehavior< ValueType, StateType > expand(StateToIdCallback const &stateToIdCallback) override
virtual bool isDiscreteTimeModel() const override
virtual std::vector< StateType > getInitialStates(StateToIdCallback const &stateToIdCallback) override
JaniNextStateGenerator(storm::jani::Model const &model, NextStateGeneratorOptions const &options=NextStateGeneratorOptions())
virtual storm::builder::RewardModelInformation getRewardModelInformation(uint64_t const &index) const override
virtual bool isDeterministicModel() const override
virtual bool isPartiallyObservable() const override
virtual std::size_t getNumberOfRewardModels() const override
static bool canHandle(storm::jani::Model const &model)
A quick check to detect whether the given model is not supported.
NextStateGenerator< ValueType, StateType >::StateToIdCallback StateToIdCallback
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={}) override
virtual void addStateValuation(storm::storage::sparse::state_type const ¤tStateIndex, storm::storage::sparse::Valuations &valuations) const override
Adds the valuation for the currently loaded state to the given builder.
virtual void unpackTransientVariableValuesIntoEvaluator(CompressedState const &state, storm::expressions::ExpressionEvaluator< ValueType > &evaluator) const override
Sets the values of all transient variables in the current state to the given evaluator.
virtual storm::storage::sparse::Valuations initializeStateValuations() const override
Initializes state valuations by adding the appropriate variables.
std::unique_ptr< storm::expressions::ExpressionEvaluator< BaseValueType > > evaluator
void postprocess(StateBehavior< ValueType, uint32_t > &result)
boost::optional< std::vector< uint64_t > > overlappingGuardStates
CompressedState const * state
NextStateGeneratorOptions const & getOptions() const
std::vector< std::pair< storm::expressions::Expression, bool > > terminalStates
NextStateGeneratorOptions options
VariableInformation variableInformation
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
void addChoice(Choice< ValueType, StateType > &&choice)
Adds the given choice to the behavior of the state.
void addStateRewards(std::vector< ValueType > &&stateRewards)
Adds the given state rewards to the behavior of the state.
void setExpanded(bool newValue=true)
Sets whether the state was expanded.
std::string const & getName() const
Returns the name of the location.
std::string const & getAutomatonName() const
Retrieves the name of the automaton this composition element refers to.
bool isBooleanType() const
virtual bool isAutomatonComposition() const
virtual bool isParallelComposition() const
AutomatonComposition const & asAutomatonComposition() const
ParallelComposition const & asParallelComposition() const
storm::expressions::Expression const & getProbability() const
Retrieves the probability of choosing this destination.
bool hasTransientAssignment() const
Retrieves whether this destination has transient assignments.
OrderedAssignments const & getOrderedAssignments() const
Retrieves the assignments to make when choosing this destination.
uint64_t getLocationIndex() const
Retrieves the id of the destination location.
uint64_t getActionIndex() const
Retrieves the id of the action with which this edge is labeled.
std::vector< EdgeDestination > const & getDestinations() const
Retrieves the destinations of this edge.
bool hasRate() const
Retrieves whether this edge has an associated rate.
uint64_t getSourceLocationIndex() const
Retrieves the index of the source location.
OrderedAssignments const & getAssignments() const
Retrieves the assignments of this edge.
storm::expressions::Expression const & getRate() const
Retrieves the rate of this edge.
int64_t const & getHighestAssignmentLevel() const
Retrieves the highest assignment level occurring in a destination assignment If no assignment exists,...
std::size_t getNumberOfDestinations() const
Retrieves the number of destinations of this edge.
int64_t const & getLowestAssignmentLevel() const
Retrieves the lowest assignment level occurring in a destination assignment.
EdgeDestination const & getDestination(uint64_t index) const
Retrieves the destination with the given index.
virtual bool isBasicType() const
BasicType const & asBasicType() const
OrderedAssignments const & getAssignments() const
Retrieves the assignments of this location.
ModelFeatures & add(ModelFeature const &modelFeature)
void remove(ModelFeature const &modelFeature)
bool hasUndefinedConstants() const
Retrieves whether the model still has undefined constants.
storm::expressions::ExpressionManager & getManager() const
Retrieves the expression manager responsible for the expressions in the model.
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
storm::expressions::Expression getRewardModelExpression(std::string const &identifier) const
Retrieves the defining reward expression of the reward model with the given identifier.
static uint64_t encodeAutomatonAndEdgeIndices(uint64_t automatonIndex, uint64_t edgeIndex)
Encode and decode a tuple of automaton and edge index in one 64-bit index.
Composition const & getSystemComposition() const
Retrieves the system composition expression.
void liftTransientEdgeDestinationAssignments(int64_t maxLevel=0)
Lifts the common edge destination assignments of transient variables to edge assignments.
static const uint64_t SILENT_ACTION_INDEX
The index of the silent action.
bool hasNonTrivialRewardExpression() const
Returns true iff there is a non-trivial reward model, i.e., a reward model that does not consist of a...
bool undefinedConstantsAreGraphPreserving() const
Checks that undefined constants (parameters) of the model preserve the graph of the underlying model.
void pushEdgeAssignmentsToDestinations()
Action const & getAction(uint64_t index) const
Retrieves the action with the given index.
std::vector< std::pair< std::string, storm::expressions::Expression > > getAllRewardModelExpressions() const
Retrieves all available reward model names and expressions of the model.
bool isNonTrivialRewardModelExpression(std::string const &identifier) const
Returns true iff the given identifier corresponds to a non-trivial reward expression i....
void simplifyComposition()
Attempts to simplify the composition.
ModelFeatures const & getModelFeatures() const
Retrieves the enabled model features.
Automaton & getAutomaton(std::string const &name)
Retrieves the automaton with the given name.
bool hasNonTrivialInitialStates() const
Retrieves whether there are non-trivial initial states in the model or any of the contained automata.
uint64_t getActionIndex(std::string const &name) const
Get the index of the action.
bool usesAssignmentLevels(bool onlyTransient=false) const
Retrieves whether the model uses an assignment level other than zero.
uint64_t getAutomatonIndex(std::string const &name) const
Retrieves the index of the given automaton.
std::vector< std::reference_wrapper< Constant const > > getUndefinedConstants() const
Retrieves all undefined constants of the model.
bool hasMultipleLevels(bool onlyTransient=false) const
Checks whether the assignments have several levels.
bool empty(bool onlyTransient=false) const
Retrieves whether this set of assignments is empty.
int64_t getLowestLevel(bool onlyTransient=false) const
Retrieves the lowest level among all assignments.
detail::ConstAssignments getNonTransientAssignments() const
Returns all non-transient assignments in this set of assignments.
detail::ConstAssignments getTransientAssignments() const
Returns all transient assignments in this set of assignments.
int64_t getHighestLevel(bool onlyTransient=false) const
Retrieves the highest level among all assignments.
std::vector< SynchronizationVector > const & getSynchronizationVectors() const
Retrieves the synchronization vectors of the parallel composition.
std::vector< std::shared_ptr< Composition > > const & getSubcompositions() const
Retrieves the subcompositions of the parallel composition.
static bool isNoActionInput(std::string const &action)
storm::expressions::Variable const & getExpressionVariable() const
Retrieves the associated expression variable.
bool hasVariable(std::string const &name) const
Retrieves whether this variable set contains a variable with the given name.
Variable const & getVariable(std::string const &name) const
Retrieves the variable with the given name.
This class manages the labeling of the state space with a number of (atomic) labels.
A bit vector that is internally represented as a vector of 64-bit values.
void setFromInt(uint64_t bitIndex, uint64_t numberOfBits, uint64_t value)
Sets the selected number of lowermost bits of the provided value at the given bit index.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
uint64_t getAsInt(uint64_t bitIndex, uint64_t numberOfBits) const
Retrieves the content of the current bit vector at the given index for the given number of bits as an...
static uint_fast64_t getIdentifierForChoicesWithNoOrigin()
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
virtual std::unique_ptr< storm::solver::SmtSolver > create(storm::expressions::ExpressionManager &manager) const
Creates a new SMT solver instance.
#define STORM_LOG_INFO(message)
#define STORM_LOG_WARN(message)
#define STORM_LOG_DEBUG(message)
#define STORM_LOG_TRACE(message)
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
SFTBDDChecker::ValueType ValueType
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::storage::BitVector CompressedState
storm::builder::BuilderOptions NextStateGeneratorOptions
storm::adapters::DereferenceIteratorAdapter< std::vector< std::shared_ptr< Assignment > > const > ConstAssignments
@ MultiObjectiveProperties
bool isDiscreteTimeModel(ModelType const &modelType)
void forEach(std::vector< IteratorType > const &its, std::vector< IteratorType > const &ites, std::function< void(uint64_t, decltype(*std::declval< IteratorType >()))> const &setValueCallback, std::function< bool()> const &newCombinationCallback)
std::vector< T > buildVectorForRange(T min, T max)
Constructs a vector [min, min+1, ...., max-1].
bool isConstant(ValueType const &)
bool isZero(ValueType const &a)
void addOriginData(boost::any const &data)
Adds the given data that specifies the origin of this choice w.r.t.
void addRewards(std::vector< ValueType > &&values)
Adds the given choices rewards to this choice.
void addProbability(StateType const &state, ValueType const &value)
Adds the given probability value to the given state in the underlying distribution.