|
|
@ -53,6 +53,9 @@ namespace storm { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Build the information structs for the reward models.
|
|
|
|
buildRewardModelInformation(); |
|
|
|
|
|
|
|
// If there are terminal states we need to handle, we now need to translate all labels to expressions.
|
|
|
|
if (this->options.hasTerminalStates()) { |
|
|
|
for (auto const& expressionOrLabelAndBool : this->options.getTerminalStates()) { |
|
|
@ -309,25 +312,6 @@ namespace storm { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType, typename StateType> |
|
|
|
void JaniNextStateGenerator<ValueType, StateType>::performTransientAssignments(storm::jani::detail::ConstAssignments const& transientAssignments, std::function<void (ValueType const&)> const& callback) { |
|
|
|
auto rewardVariableIt = rewardVariables.begin(); |
|
|
|
auto rewardVariableIte = rewardVariables.end(); |
|
|
|
for (auto const& assignment : transientAssignments) { |
|
|
|
while (rewardVariableIt != rewardVariableIte && *rewardVariableIt < assignment.getExpressionVariable()) { |
|
|
|
callback(storm::utility::zero<ValueType>()); |
|
|
|
++rewardVariableIt; |
|
|
|
} |
|
|
|
if (rewardVariableIt == rewardVariableIte) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (*rewardVariableIt == assignment.getExpressionVariable()) { |
|
|
|
callback(ValueType(this->evaluator.asRational(assignment.getAssignedExpression()))); |
|
|
|
++rewardVariableIt; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType, typename StateType> |
|
|
|
std::vector<Choice<ValueType>> JaniNextStateGenerator<ValueType, StateType>::getSilentActionChoices(std::vector<uint64_t> const& locations, CompressedState const& state, StateToIdCallback stateToIdCallback) { |
|
|
|
std::vector<Choice<ValueType>> result; |
|
|
@ -537,13 +521,12 @@ namespace storm { |
|
|
|
|
|
|
|
template<typename ValueType, typename StateType> |
|
|
|
std::size_t JaniNextStateGenerator<ValueType, StateType>::getNumberOfRewardModels() const { |
|
|
|
return 0; |
|
|
|
return rewardVariables.size(); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType, typename StateType> |
|
|
|
RewardModelInformation JaniNextStateGenerator<ValueType, StateType>::getRewardModelInformation(uint64_t const& index) const { |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "Cannot retrieve reward model information."); |
|
|
|
return RewardModelInformation("", false, false, false); |
|
|
|
return rewardModelInformation[index]; |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType, typename StateType> |
|
|
@ -551,6 +534,72 @@ namespace storm { |
|
|
|
return NextStateGenerator<ValueType, StateType>::label(states, initialStateIndices, deadlockStateIndices, {}); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType, typename StateType> |
|
|
|
void JaniNextStateGenerator<ValueType, StateType>::performTransientAssignments(storm::jani::detail::ConstAssignments const& transientAssignments, std::function<void (ValueType const&)> const& callback) { |
|
|
|
auto rewardVariableIt = rewardVariables.begin(); |
|
|
|
auto rewardVariableIte = rewardVariables.end(); |
|
|
|
for (auto const& assignment : transientAssignments) { |
|
|
|
while (rewardVariableIt != rewardVariableIte && *rewardVariableIt < assignment.getExpressionVariable()) { |
|
|
|
callback(storm::utility::zero<ValueType>()); |
|
|
|
++rewardVariableIt; |
|
|
|
} |
|
|
|
if (rewardVariableIt == rewardVariableIte) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (*rewardVariableIt == assignment.getExpressionVariable()) { |
|
|
|
callback(ValueType(this->evaluator.asRational(assignment.getAssignedExpression()))); |
|
|
|
++rewardVariableIt; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType, typename StateType> |
|
|
|
void JaniNextStateGenerator<ValueType, StateType>::buildRewardModelInformation() { |
|
|
|
// Prepare all reward model information structs.
|
|
|
|
for (auto const& variable : rewardVariables) { |
|
|
|
rewardModelInformation.emplace_back(variable.getName(), false, false, false); |
|
|
|
} |
|
|
|
|
|
|
|
// Then fill them.
|
|
|
|
for (auto const& automaton : model.getAutomata()) { |
|
|
|
for (auto const& location : automaton.getLocations()) { |
|
|
|
auto rewardVariableIt = rewardVariables.begin(); |
|
|
|
auto rewardVariableIte = rewardVariables.end(); |
|
|
|
|
|
|
|
for (auto const& assignment : location.getAssignments().getTransientAssignments()) { |
|
|
|
while (rewardVariableIt != rewardVariableIte && *rewardVariableIt < assignment.getExpressionVariable()) { |
|
|
|
++rewardVariableIt; |
|
|
|
} |
|
|
|
if (rewardVariableIt == rewardVariableIte) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (*rewardVariableIt == assignment.getExpressionVariable()) { |
|
|
|
rewardModelInformation[std::distance(rewardVariables.begin(), rewardVariableIt)].setHasStateRewards(); |
|
|
|
++rewardVariableIt; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (auto const& edge : automaton.getEdges()) { |
|
|
|
auto rewardVariableIt = rewardVariables.begin(); |
|
|
|
auto rewardVariableIte = rewardVariables.end(); |
|
|
|
|
|
|
|
for (auto const& assignment : edge.getAssignments().getTransientAssignments()) { |
|
|
|
while (rewardVariableIt != rewardVariableIte && *rewardVariableIt < assignment.getExpressionVariable()) { |
|
|
|
++rewardVariableIt; |
|
|
|
} |
|
|
|
if (rewardVariableIt == rewardVariableIte) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (*rewardVariableIt == assignment.getExpressionVariable()) { |
|
|
|
rewardModelInformation[std::distance(rewardVariables.begin(), rewardVariableIt)].setHasStateActionRewards(); |
|
|
|
++rewardVariableIt; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template class JaniNextStateGenerator<double>; |
|
|
|
|
|
|
|
#ifdef STORM_HAVE_CARL
|
|
|
|