10template<
typename ValueType, storm::OptimizationDirection Dir>
15 : schedulerStorage(schedulerStorage), applyUpdates(applyUpdates), rowGroupIndices(rowGroupIndices) {
22 void firstRow(ValueType&& value, uint64_t rowGroup, uint64_t row) {
23 currChoice = row - rowGroupIndices[rowGroup];
24 best = std::move(value);
27 void nextRow(ValueType&& value, uint64_t rowGroup, uint64_t row) {
29 currChoice = row - rowGroupIndices[rowGroup];
30 }
else if (*best == value) {
33 if (uint64_t rowChoice = row - rowGroupIndices[rowGroup]; rowChoice == schedulerStorage[rowGroup]) {
34 currChoice = rowChoice;
41 currValue = std::move(*best);
43 auto& choice = schedulerStorage[rowGroup];
45 isConverged = choice == currChoice;
61 std::vector<uint64_t>& schedulerStorage;
62 bool const applyUpdates;
63 std::vector<typename ValueIterationOperator<ValueType, false>::IndexType>
const& rowGroupIndices;
70template<
typename ValueType,
typename SolutionType,
bool TrivialRowGrouping>
73 : viOperator(viOperator) {
77template<
typename ValueType,
typename SolutionType,
bool TrivialRowGrouping>
78template<storm::OptimizationDirection Dir, storm::OptimizationDirection RobustDir>
80 std::vector<ValueType>
const& offsets,
81 std::vector<uint64_t>& schedulerStorage,
82 std::vector<SolutionType>* operandOut,
83 boost::optional<std::vector<uint64_t>>
const& robustIndices)
const {
84 bool const applyUpdates = operandOut !=
nullptr;
85 if constexpr (TrivialRowGrouping && std::is_same<SolutionType, double>::value) {
86 STORM_LOG_ASSERT(robustIndices,
"Tracking scheduler with trivial row grouping but no robust indices => there is no scheduler.");
89 return viOperator->template applyRobust<RobustDir>(*operandOut, operandIn, offsets, backend);
91 return viOperator->template applyInPlaceRobust<RobustDir>(operandIn, offsets, backend);
94 STORM_LOG_WARN_COND(!robustIndices,
"Only tracking nondeterminism, not ordering of intervals.");
95 SchedulerTrackingBackend<SolutionType, Dir> backend(schedulerStorage, viOperator->getRowGroupIndices(), applyUpdates);
97 return viOperator->template applyRobust<RobustDir>(*operandOut, operandIn, offsets, backend);
99 return viOperator->template applyInPlaceRobust<RobustDir>(operandIn, offsets, backend);
104template<
typename ValueType,
typename SolutionType,
bool TrivialRowGrouping>
106 std::vector<ValueType>
const& offsets,
108 std::vector<uint64_t>& schedulerStorage,
bool robust,
109 std::vector<SolutionType>* operandOut,
110 boost::optional<std::vector<uint64_t>>
const& robustIndices)
const {
113 if (robust && !TrivialRowGrouping) {
114 return computeScheduler<storm::OptimizationDirection::Maximize, storm::OptimizationDirection::Minimize>(operandIn, offsets, schedulerStorage,
115 operandOut, robustIndices);
117 return computeScheduler<storm::OptimizationDirection::Maximize, storm::OptimizationDirection::Maximize>(operandIn, offsets, schedulerStorage,
118 operandOut, robustIndices);
121 if (robust && !TrivialRowGrouping) {
122 return computeScheduler<storm::OptimizationDirection::Minimize, OptimizationDirection::Maximize>(operandIn, offsets, schedulerStorage, operandOut,
125 return computeScheduler<storm::OptimizationDirection::Minimize, OptimizationDirection::Minimize>(operandIn, offsets, schedulerStorage, operandOut,
bool constexpr abort() const
void endOfIteration() const
SchedulerTrackingBackend(std::vector< uint64_t > &schedulerStorage, std::vector< typename ValueIterationOperator< ValueType, false >::IndexType > const &rowGroupIndices, bool applyUpdates)
void applyUpdate(ValueType &currValue, uint64_t rowGroup)
void firstRow(ValueType &&value, uint64_t rowGroup, uint64_t row)
void nextRow(ValueType &&value, uint64_t rowGroup, uint64_t row)
Helper class to extract optimal scheduler choices from a MinMax equation system solution.
bool computeScheduler(std::vector< SolutionType > &operandIn, std::vector< ValueType > const &offsets, storm::OptimizationDirection const &dir, std::vector< uint64_t > &schedulerStorage, bool robust, std::vector< SolutionType > *operandOut=nullptr, boost::optional< std::vector< uint64_t > > const &robustIndices=boost::none) const
Computes the optimal choices from the given solution.
SchedulerTrackingHelper(std::shared_ptr< ValueIterationOperator< ValueType, TrivialRowGrouping, SolutionType > > viOperator)
Initializes this helper with the given value iteration operator.
This class represents the Value Iteration Operator (also known as Bellman operator).
storm::storage::sparse::state_type IndexType
Stores and manages an extremal (maximal or minimal) value.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_WARN_COND(cond, message)
bool constexpr maximize(OptimizationDirection d)