51 this->evaluator = std::make_unique<storm::expressions::ExpressionEvaluator<ValueType>>(program.
getManager());
55 rewardModels.push_back(rewardModel);
59 for (
auto const& rewardModelName : this->options.getRewardModelNames()) {
61 rewardModels.push_back(this->program.
getRewardModel(rewardModelName));
63 STORM_LOG_THROW(rewardModelName.empty(), storm::exceptions::InvalidArgumentException,
64 "Cannot build unknown reward model '" << rewardModelName <<
"'.");
66 "Reference to standard reward model is ambiguous.");
72 if (rewardModels.empty() && !this->options.getRewardModelNames().empty()) {
78 for (
auto const& rewardModel : rewardModels) {
79 hasStateActionRewards |= rewardModel.get().hasStateActionRewards();
84 for (
auto const& expressionOrLabelAndBool : this->options.getTerminalStates()) {
85 if (expressionOrLabelAndBool.first.isExpression()) {
86 this->terminalStates.push_back(std::make_pair(expressionOrLabelAndBool.first.getExpression(), expressionOrLabelAndBool.second));
88 if (program.
hasLabel(expressionOrLabelAndBool.first.getLabel())) {
89 this->terminalStates.push_back(
90 std::make_pair(this->program.
getLabelExpression(expressionOrLabelAndBool.first.getLabel()), expressionOrLabelAndBool.second));
93 STORM_LOG_THROW(this->isSpecialLabel(expressionOrLabelAndBool.first.getLabel()), storm::exceptions::InvalidArgumentException,
94 "Terminal states refer to illegal label '" << expressionOrLabelAndBool.first.getLabel() <<
"'.");
106template<
typename ValueType,
typename StateType>
112template<
typename ValueType,
typename StateType>
115#ifdef STORM_HAVE_CARL
120 std::vector<std::reference_wrapper<storm::prism::Constant const>> undefinedConstants = program.
getUndefinedConstants();
121 std::stringstream stream;
122 bool printComma =
false;
123 for (
auto const& constant : undefinedConstants) {
129 stream << constant.get().getName() <<
" (" << constant.get().getType() <<
")";
132 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Program still contains these undefined constants: " + stream.str());
134#ifdef STORM_HAVE_CARL
138 "The program contains undefined constants that appear in some places other than update probabilities and reward value expressions, "
139 "which is not admitted. Undefined constants are: "
145template<
typename ValueType,
typename StateType>
161 STORM_LOG_THROW(
false, storm::exceptions::WrongFormatException,
"Invalid model type.");
165template<
typename ValueType,
typename StateType>
170template<
typename ValueType,
typename StateType>
175template<
typename ValueType,
typename StateType>
180template<
typename ValueType,
typename StateType>
182 std::vector<StateType> initialStateIndices;
187 std::vector<std::vector<uint64_t>> allValues;
188 for (
auto const& intVar : this->variableInformation.integerVariables) {
189 STORM_LOG_ASSERT(intVar.lowerBound <= intVar.upperBound,
"Expecting variable with non-empty set of possible values.");
191 allValues.push_back(storm::utility::vector::buildVectorForRange<uint64_t>(
static_cast<uint64_t
>(0), intVar.upperBound + 1 - intVar.lowerBound));
193 uint64_t intEndIndex = allValues.size();
195 allValues.resize(allValues.size() + this->variableInformation.booleanVariables.size(),
196 std::vector<uint64_t>({static_cast<uint64_t>(0), static_cast<uint64_t>(1)}));
198 std::vector<std::vector<uint64_t>::const_iterator> its;
199 std::vector<std::vector<uint64_t>::const_iterator> ites;
200 for (
auto const& valVec : allValues) {
201 its.push_back(valVec.cbegin());
202 ites.push_back(valVec.cend());
206 CompressedState initialState(this->variableInformation.getTotalBitOffset(
true));
209 [
this, &initialState, &intEndIndex](uint64_t index, uint64_t value) {
211 if (index < intEndIndex) {
213 auto const& intVar = this->variableInformation.integerVariables[index];
214 initialState.
setFromInt(intVar.bitOffset, intVar.bitWidth, value);
217 STORM_LOG_ASSERT(index - intEndIndex < this->variableInformation.booleanVariables.size(),
"Unexpected index");
218 auto const& boolVar = this->variableInformation.booleanVariables[index - intEndIndex];
220 initialState.
set(boolVar.bitOffset,
static_cast<bool>(value));
223 [&stateToIdCallback, &initialStateIndices, &initialState]() {
225 StateType
id = stateToIdCallback(initialState);
226 initialStateIndices.push_back(
id);
229 STORM_LOG_DEBUG(
"Enumerated " << initialStateIndices.size() <<
" initial states using brute force enumeration.");
233 std::unique_ptr<storm::solver::SmtSolver> solver = factory.
create(program.
getManager());
236 for (
auto const& expression : rangeExpressions) {
237 solver->add(expression);
244 CompressedState initialState(this->variableInformation.getTotalBitOffset(
true));
249 std::shared_ptr<storm::solver::SmtSolver::ModelReference> model = solver->getModel();
250 for (
auto const& booleanVariable : this->variableInformation.booleanVariables) {
251 bool variableValue = model->getBooleanValue(booleanVariable.variable);
253 blockingExpression = blockingExpression.
isInitialized() ? blockingExpression || localBlockingExpression : localBlockingExpression;
254 initialState.
set(booleanVariable.bitOffset, variableValue);
256 for (
auto const& integerVariable : this->variableInformation.integerVariables) {
257 int_fast64_t variableValue = model->getIntegerValue(integerVariable.variable);
259 blockingExpression = blockingExpression.
isInitialized() ? blockingExpression || localBlockingExpression : localBlockingExpression;
260 initialState.
setFromInt(integerVariable.bitOffset, integerVariable.bitWidth,
261 static_cast<uint_fast64_t
>(variableValue - integerVariable.lowerBound));
265 StateType
id = stateToIdCallback(initialState);
266 initialStateIndices.push_back(
id);
272 solver->add(blockingExpression);
275 STORM_LOG_DEBUG(
"Enumerated " << initialStateIndices.size() <<
" initial states using SMT solving.");
278 return initialStateIndices;
281template<
typename ValueType,
typename StateType>
288 for (
auto const& rewardModel : rewardModels) {
289 ValueType stateRewardValue = storm::utility::zero<ValueType>();
290 if (rewardModel.get().hasStateRewards()) {
291 for (
auto const& stateReward : rewardModel.get().getStateRewards()) {
292 if (this->evaluator->asBool(stateReward.getStatePredicateExpression())) {
293 stateRewardValue += ValueType(this->evaluator->asRational(stateReward.getRewardValueExpression()));
301 if (!this->terminalStates.empty()) {
302 for (
auto const& expressionBool : this->terminalStates) {
303 if (this->evaluator->asBool(expressionBool.first) == expressionBool.second) {
304 if (!isPartiallyObservable()) {
310 std::vector<Choice<ValueType>> allChoices = getSelfLoopsForAllActions(*this->state, stateToIdCallback);
311 if (allChoices.size() != 0) {
312 for (
auto& choice : allChoices) {
316 this->postprocess(result);
327 std::vector<Choice<ValueType>> allChoices;
328 if (this->getOptions().isApplyMaximalProgressAssumptionSet()) {
330 allChoices = getAsynchronousChoices(*this->state, stateToIdCallback, CommandFilter::Probabilistic);
331 addSynchronousChoices(allChoices, *this->state, stateToIdCallback, CommandFilter::Probabilistic);
332 if (allChoices.empty()) {
334 allChoices = getAsynchronousChoices(*this->state, stateToIdCallback, CommandFilter::Markovian);
335 addSynchronousChoices(allChoices, *this->state, stateToIdCallback, CommandFilter::Markovian);
338 allChoices = getAsynchronousChoices(*this->state, stateToIdCallback);
339 addSynchronousChoices(allChoices, *this->state, stateToIdCallback);
342 std::size_t totalNumberOfChoices = allChoices.size();
346 if (totalNumberOfChoices == 0) {
351 if (this->isDeterministicModel() && totalNumberOfChoices > 1) {
355 this->overlappingGuardStates->push_back(stateToIdCallback(*this->state));
360 ValueType totalExitRate = this->isDiscreteTimeModel() ?
static_cast<ValueType
>(totalNumberOfChoices) : storm::utility::zero<ValueType>();
363 for (
auto const& choice : allChoices) {
364 for (
auto const& stateProbabilityPair : choice) {
365 if (this->isDiscreteTimeModel()) {
366 globalChoice.
addProbability(stateProbabilityPair.first, stateProbabilityPair.second / totalNumberOfChoices);
368 globalChoice.
addProbability(stateProbabilityPair.first, stateProbabilityPair.second);
372 if (hasStateActionRewards && !this->isDiscreteTimeModel()) {
373 totalExitRate += choice.getTotalMass();
377 globalChoice.
addLabels(choice.getLabels());
386 for (
auto const& rewardModel : rewardModels) {
387 ValueType stateActionRewardValue = storm::utility::zero<ValueType>();
388 if (rewardModel.get().hasStateActionRewards()) {
389 for (
auto const& stateActionReward : rewardModel.get().getStateActionRewards()) {
390 for (
auto const& choice : allChoices) {
391 if (stateActionReward.getActionIndex() == choice.getActionIndex() &&
392 this->evaluator->asBool(stateActionReward.getStatePredicateExpression())) {
393 stateActionRewardValue +=
394 ValueType(this->evaluator->asRational(stateActionReward.getRewardValueExpression())) * choice.getTotalMass();
399 if (hasStateActionRewards) {
400 globalChoice.
addReward(stateActionRewardValue / totalExitRate);
406 allChoices.push_back(std::move(globalChoice));
411 auto choiceIt = allChoices.begin();
413 "State '" << this->stateToString(*this->state)
414 <<
"' features a choice without player index.");
417 "State '" << this->stateToString(*this->state)
418 <<
"' features a choice with invalid player index.");
419 for (++choiceIt; choiceIt != allChoices.end(); ++choiceIt) {
421 "State '" << this->stateToString(*this->state)
422 <<
"' features a choice without player index.");
424 "State '" << this->stateToString(*this->state)
425 <<
"' features a choice with invalid player index.");
426 STORM_LOG_THROW(statePlayerIndex == choiceIt->getPlayerIndex(), storm::exceptions::WrongFormatException,
427 "The player for state '" << this->stateToString(*this->state) <<
"' is not unique. At least one choice is owned by player '"
428 << statePlayerIndex <<
"' while another is owned by player '" << choiceIt->getPlayerIndex() <<
"'.");
433 for (
auto& choice : allChoices) {
437 this->postprocess(result);
442template<
typename ValueType,
typename StateType>
444 return this->evaluator->asBool(expr);
447template<
typename ValueType,
typename StateType>
460 auto boolIt = this->variableInformation.booleanVariables.begin();
461 for (; assignmentIt != assignmentIte && assignmentIt->getExpression().hasBooleanType(); ++assignmentIt) {
462 while (assignmentIt->getVariable() != boolIt->variable) {
465 newState.set(boolIt->bitOffset, this->evaluator->asBool(assignmentIt->getExpression()));
469 auto integerIt = this->variableInformation.integerVariables.begin();
470 for (; assignmentIt != assignmentIte && assignmentIt->getExpression().hasIntegerType(); ++assignmentIt) {
471 while (assignmentIt->getVariable() != integerIt->variable) {
474 int_fast64_t assignedValue = this->evaluator->asInt(assignmentIt->getExpression());
476 if (assignedValue < integerIt->lowerBound || assignedValue > integerIt->upperBound) {
477 return this->outOfBoundsState;
479 }
else if (integerIt->forceOutOfBoundsCheck || this->options.isExplorationChecksSet()) {
480 STORM_LOG_THROW(assignedValue >= integerIt->lowerBound, storm::exceptions::WrongFormatException,
481 "The update " << update <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
482 << assignmentIt->getVariableName() <<
"'.");
483 STORM_LOG_THROW(assignedValue <= integerIt->upperBound, storm::exceptions::WrongFormatException,
484 "The update " << update <<
" leads to an out-of-bounds value (" << assignedValue <<
") for the variable '"
485 << assignmentIt->getVariableName() <<
"'.");
487 newState.setFromInt(integerIt->bitOffset, integerIt->bitWidth, assignedValue - integerIt->lowerBound);
488 STORM_LOG_ASSERT(
static_cast<int_fast64_t
>(newState.getAsInt(integerIt->bitOffset, integerIt->bitWidth)) + integerIt->lowerBound == assignedValue,
489 "Writing to the bit vector bucket failed (read " << newState.getAsInt(integerIt->bitOffset, integerIt->bitWidth) <<
" but wrote "
490 << assignedValue <<
").");
494 STORM_LOG_ASSERT(assignmentIt == assignmentIte,
"Not all assignments were consumed.");
510template<
typename ValueType,
typename StateType>
511boost::optional<std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>>>
519 std::vector<ActiveCommandData> activeCommands;
524 if (!module.hasActionIndex(actionIndex)) {
528 std::set<uint_fast64_t>
const& commandIndices =
module.getCommandIndicesByActionIndex(actionIndex);
532 if (commandIndices.empty()) {
537 bool hasOneEnabledCommand =
false;
538 for (
auto commandIndexIt = commandIndices.begin(), commandIndexIte = commandIndices.end(); commandIndexIt != commandIndexIte; ++commandIndexIt) {
540 if (!isCommandPotentiallySynchronizing(command)) {
543 if (commandFilter != CommandFilter::All) {
544 STORM_LOG_ASSERT(commandFilter == CommandFilter::Markovian || commandFilter == CommandFilter::Probabilistic,
"Unexpected command filter.");
545 if ((commandFilter == CommandFilter::Markovian) != command.
isMarkovian()) {
551 hasOneEnabledCommand =
true;
552 activeCommands.emplace_back(&module, &commandIndices, commandIndexIt);
557 if (!hasOneEnabledCommand) {
563 std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>> result;
566 for (
auto const& activeCommand : activeCommands) {
567 std::vector<std::reference_wrapper<storm::prism::Command const>> commands;
569 auto commandIndexIt = activeCommand.currentCommandIndexIt;
571 commands.push_back(activeCommand.modulePtr->getCommand(*commandIndexIt));
574 auto commandIndexIte = activeCommand.commandIndicesPtr->end();
575 for (++commandIndexIt; commandIndexIt != commandIndexIte; ++commandIndexIt) {
577 if (commandFilter != CommandFilter::All) {
578 STORM_LOG_ASSERT(commandFilter == CommandFilter::Markovian || commandFilter == CommandFilter::Probabilistic,
"Unexpected command filter.");
579 if ((commandFilter == CommandFilter::Markovian) != command.
isMarkovian()) {
584 commands.push_back(command);
588 result.push_back(std::move(commands));
595template<
typename ValueType,
typename StateType>
596std::vector<Choice<ValueType>> PrismNextStateGenerator<ValueType, StateType>::getAsynchronousChoices(
CompressedState const& state,
597 StateToIdCallback stateToIdCallback,
598 CommandFilter
const& commandFilter) {
599 std::vector<Choice<ValueType>> result;
606 for (uint_fast64_t j = 0; j <
module.getNumberOfCommands(); ++j) {
610 if (isCommandPotentiallySynchronizing(command))
613 if (commandFilter != CommandFilter::All) {
614 STORM_LOG_ASSERT(commandFilter == CommandFilter::Markovian || commandFilter == CommandFilter::Probabilistic,
"Unexpected command filter.");
615 if ((commandFilter == CommandFilter::Markovian) != command.
isMarkovian()) {
619 if (this->actionMask !=
nullptr) {
631 Choice<ValueType>& choice = result.back();
636 choice.addOriginData(boost::any(std::move(commandIndex)));
640 ValueType probabilitySum = storm::utility::zero<ValueType>();
645 if (probability != storm::utility::zero<ValueType>()) {
648 StateType stateIndex = stateToIdCallback(applyUpdate(state, update));
651 choice.addProbability(stateIndex, probability);
653 probabilitySum += probability;
659 for (
auto const& rewardModel : rewardModels) {
660 ValueType stateActionRewardValue = storm::utility::zero<ValueType>();
661 if (rewardModel.get().hasStateActionRewards()) {
662 for (
auto const& stateActionReward : rewardModel.get().getStateActionRewards()) {
663 if (stateActionReward.getActionIndex() == choice.getActionIndex() &&
664 this->evaluator->asBool(stateActionReward.getStatePredicateExpression())) {
665 stateActionRewardValue +=
ValueType(this->evaluator->asRational(stateActionReward.getRewardValueExpression()));
669 choice.addReward(stateActionRewardValue);
679 auto const playerOfModule = moduleIndexToPlayerIndexMap.at(i);
681 "Module " << module.getName() <<
" is not owned by any player but has at least one enabled, unlabeled command.");
682 choice.setPlayerIndex(playerOfModule);
685 auto const playerOfAction = actionIndexToPlayerIndexMap.at(command.
getActionIndex());
688 choice.setPlayerIndex(playerOfAction);
695 "Probabilities do not sum to one for command '" << command <<
"' (actually sum to " << probabilitySum <<
").");
703template<
typename ValueType,
typename StateType>
704std::vector<Choice<ValueType>> PrismNextStateGenerator<ValueType, StateType>::getSelfLoopsForAllActions(
CompressedState const& state,
705 StateToIdCallback stateToIdCallback,
706 CommandFilter
const& commandFilter) {
707 std::vector<Choice<ValueType>> result;
715 for (uint_fast64_t j = 0; j <
module.getNumberOfCommands(); ++j) {
719 if (isCommandPotentiallySynchronizing(command))
722 if (this->actionMask !=
nullptr) {
734 Choice<ValueType>& choice = result.back();
739 choice.addOriginData(boost::any(std::move(commandIndex)));
741 choice.addProbability(stateToIdCallback(*this->state), storm::utility::one<ValueType>());
744 for (
auto const& rewardModel : rewardModels) {
745 ValueType stateActionRewardValue = storm::utility::zero<ValueType>();
746 if (rewardModel.get().hasStateActionRewards()) {
747 for (
auto const& stateActionReward : rewardModel.get().getStateActionRewards()) {
748 if (stateActionReward.getActionIndex() == choice.getActionIndex() &&
749 this->evaluator->asBool(stateActionReward.getStatePredicateExpression())) {
750 stateActionRewardValue +=
ValueType(this->evaluator->asRational(stateActionReward.getRewardValueExpression()));
754 choice.addReward(stateActionRewardValue);
764 for (uint_fast64_t actionIndex : program.getSynchronizingActionIndices()) {
765 if (this->actionMask !=
nullptr) {
766 if (!this->actionMask->query(*
this, actionIndex)) {
770 boost::optional<std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>>> optionalActiveCommandLists =
771 getActiveCommandsByActionIndex(actionIndex, commandFilter);
774 if (optionalActiveCommandLists) {
775 std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>>
const& activeCommandList = optionalActiveCommandLists.get();
776 std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>::const_iterator> iteratorList(activeCommandList.size());
779 for (
size_t i = 0;
i < activeCommandList.size(); ++
i) {
780 iteratorList[
i] = activeCommandList[
i].cbegin();
789 result.push_back(Choice<ValueType>(actionIndex));
792 Choice<ValueType>& choice = result.back();
799 CommandSet commandIndices;
800 for (uint_fast64_t i = 0;
i < iteratorList.size(); ++
i) {
801 commandIndices.insert(iteratorList[i]->get().getGlobalIndex());
803 choice.addOriginData(boost::any(std::move(commandIndices)));
805 choice.addProbability(stateToIdCallback(*this->state), storm::utility::one<ValueType>());
808 for (
auto const& rewardModel : rewardModels) {
809 ValueType stateActionRewardValue = storm::utility::zero<ValueType>();
810 if (rewardModel.get().hasStateActionRewards()) {
811 for (
auto const& stateActionReward : rewardModel.get().getStateActionRewards()) {
812 if (stateActionReward.getActionIndex() == choice.getActionIndex() &&
813 this->evaluator->asBool(stateActionReward.getStatePredicateExpression())) {
814 stateActionRewardValue +=
ValueType(this->evaluator->asRational(stateActionReward.getRewardValueExpression()));
818 choice.addReward(stateActionRewardValue);
822 bool movedIterator =
false;
823 for (int_fast64_t j = iteratorList.size() - 1; !movedIterator && j >= 0; --j) {
825 if (iteratorList[j] != activeCommandList[j].end()) {
826 movedIterator =
true;
829 iteratorList[j] = activeCommandList[j].begin();
833 done = !movedIterator;
841template<
typename ValueType,
typename StateType>
842void PrismNextStateGenerator<ValueType, StateType>::generateSynchronizedDistribution(
844 std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>::const_iterator>
const& iteratorList,
846 if (storm::utility::isZero<ValueType>(probability)) {
850 if (position >= iteratorList.size()) {
851 StateType
id = stateToIdCallback(state);
852 distribution.
add(
id, probability);
857 generateSynchronizedDistribution(applyUpdate(state, update), probability * this->evaluator->asRational(update.
getLikelihoodExpression()),
858 position + 1, iteratorList, distribution, stateToIdCallback);
863template<
typename ValueType,
typename StateType>
864void PrismNextStateGenerator<ValueType, StateType>::addSynchronousChoices(std::vector<Choice<ValueType>>& choices,
CompressedState const& state,
865 StateToIdCallback stateToIdCallback, CommandFilter
const& commandFilter) {
866 for (uint_fast64_t actionIndex : program.getSynchronizingActionIndices()) {
867 if (this->actionMask !=
nullptr) {
868 if (!this->actionMask->query(*
this, actionIndex)) {
872 boost::optional<std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>>> optionalActiveCommandLists =
873 getActiveCommandsByActionIndex(actionIndex, commandFilter);
876 if (optionalActiveCommandLists) {
877 std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>>
const& activeCommandList = optionalActiveCommandLists.get();
878 std::vector<std::vector<std::reference_wrapper<storm::prism::Command const>>::const_iterator> iteratorList(activeCommandList.size());
881 for (
size_t i = 0;
i < activeCommandList.size(); ++
i) {
882 iteratorList[
i] = activeCommandList[
i].cbegin();
890 distribution.
clear();
891 generateSynchronizedDistribution(state, storm::utility::one<ValueType>(), 0, iteratorList, distribution, stateToIdCallback);
897 choices.push_back(Choice<ValueType>(actionIndex));
900 Choice<ValueType>& choice = choices.back();
906 <<
" is not owned by any player but has at least one enabled, unlabeled (synchronized) command.");
907 choice.setPlayerIndex(playerOfAction);
915 CommandSet commandIndices;
916 for (uint_fast64_t i = 0;
i < iteratorList.size(); ++
i) {
917 commandIndices.insert(iteratorList[i]->get().getGlobalIndex());
919 choice.addOriginData(boost::any(std::move(commandIndices)));
923 ValueType probabilitySum = storm::utility::zero<ValueType>();
924 choice.reserve(std::distance(distribution.
begin(), distribution.
end()));
925 for (
auto const& stateProbability : distribution) {
926 choice.addProbability(stateProbability.getState(), stateProbability.getValue());
928 probabilitySum += stateProbability.getValue();
935 storm::exceptions::WrongFormatException,
936 "Sum of update probabilities do not some to one for some command (actually sum to " << probabilitySum <<
").");
940 for (
auto const& rewardModel : rewardModels) {
941 ValueType stateActionRewardValue = storm::utility::zero<ValueType>();
942 if (rewardModel.get().hasStateActionRewards()) {
943 for (
auto const& stateActionReward : rewardModel.get().getStateActionRewards()) {
944 if (stateActionReward.getActionIndex() == choice.getActionIndex() &&
945 this->evaluator->asBool(stateActionReward.getStatePredicateExpression())) {
946 stateActionRewardValue +=
ValueType(this->evaluator->asRational(stateActionReward.getRewardValueExpression()));
950 choice.addReward(stateActionRewardValue);
954 bool movedIterator =
false;
955 for (int_fast64_t j = iteratorList.size() - 1; !movedIterator && j >= 0; --j) {
957 if (iteratorList[j] != activeCommandList[j].end()) {
958 movedIterator =
true;
961 iteratorList[j] = activeCommandList[j].begin();
965 done = !movedIterator;
971template<
typename ValueType,
typename StateType>
976template<
typename ValueType,
typename StateType>
978 std::vector<StateType>
const& initialStateIndices,
979 std::vector<StateType>
const& deadlockStateIndices,
980 std::vector<StateType>
const& unexploredStateIndices) {
982 std::vector<std::pair<std::string, storm::expressions::Expression>> labels;
984 for (
auto const& label : program.
getLabels()) {
985 labels.push_back(std::make_pair(label.getName(), label.getStatePredicateExpression()));
988 for (
auto const& labelName : this->options.
getLabelNames()) {
992 STORM_LOG_THROW(this->isSpecialLabel(labelName), storm::exceptions::InvalidArgumentException,
993 "Cannot build labeling for unknown label '" << labelName <<
"'.");
1001template<
typename ValueType,
typename StateType>
1011 result.setFromInt(64 * i, 64, this->evaluator->asInt(program.
getObservationLabels()[i].getStatePredicateExpression()));
1016template<
typename ValueType,
typename StateType>
1017void PrismNextStateGenerator<ValueType, StateType>::extendStateInformation(
storm::json<ValueType>& result)
const {
1023template<
typename ValueType,
typename StateType>
1025 return rewardModels.size();
1028template<
typename ValueType,
typename StateType>
1035template<
typename ValueType,
typename StateType>
1037 std::vector<boost::any>& dataForChoiceOrigins)
const {
1038 if (!this->getOptions().isBuildChoiceOriginsSet()) {
1042 std::vector<uint_fast64_t> identifiers;
1043 identifiers.reserve(dataForChoiceOrigins.size());
1045 std::map<CommandSet, uint_fast64_t> commandSetToIdentifierMap;
1048 commandSetToIdentifierMap.insert(std::make_pair(
CommandSet(), 0));
1049 uint_fast64_t currentIdentifier = 1;
1050 for (boost::any& originData : dataForChoiceOrigins) {
1051 STORM_LOG_ASSERT(originData.empty() || boost::any_cast<CommandSet>(&originData) !=
nullptr,
1052 "Origin data has unexpected type: " << originData.type().name() <<
".");
1054 CommandSet currentCommandSet = originData.empty() ?
CommandSet() : boost::any_cast<CommandSet>(std::move(originData));
1055 auto insertionRes = commandSetToIdentifierMap.insert(std::make_pair(std::move(currentCommandSet), currentIdentifier));
1056 identifiers.push_back(insertionRes.first->second);
1057 if (insertionRes.second) {
1058 ++currentIdentifier;
1062 std::vector<CommandSet> identifierToCommandSetMapping(currentIdentifier);
1063 for (
auto const& setIdPair : commandSetToIdentifierMap) {
1064 identifierToCommandSetMapping[setIdPair.second] = setIdPair.first;
1067 return std::make_shared<storm::storage::sparse::PrismChoiceOrigins>(std::make_shared<storm::prism::Program>(program), std::move(identifiers),
1068 std::move(identifierToCommandSetMapping));