9template<
typename ValueType, storm::OptimizationDirection Dir>
14 : schedulerStorage(schedulerStorage), applyUpdates(applyUpdates), rowGroupIndices(rowGroupIndices) {
21 void firstRow(ValueType&& value, uint64_t rowGroup, uint64_t row) {
22 currChoice = row - rowGroupIndices[rowGroup];
23 best = std::move(value);
26 void nextRow(ValueType&& value, uint64_t rowGroup, uint64_t row) {
28 currChoice = row - rowGroupIndices[rowGroup];
29 }
else if (*best == value) {
32 if (uint64_t rowChoice = row - rowGroupIndices[rowGroup]; rowChoice == schedulerStorage[rowGroup]) {
33 currChoice = rowChoice;
40 currValue = std::move(*best);
42 auto& choice = schedulerStorage[rowGroup];
44 isConverged = choice == currChoice;
60 std::vector<uint64_t>& schedulerStorage;
61 bool const applyUpdates;
62 std::vector<typename ValueIterationOperator<ValueType, false>::IndexType>
const& rowGroupIndices;
69template<
typename ValueType,
typename SolutionType>
71 : viOperator(viOperator) {
75template<
typename ValueType,
typename SolutionType>
76template<storm::OptimizationDirection Dir, storm::OptimizationDirection RobustDir>
78 std::vector<uint64_t>& schedulerStorage, std::vector<SolutionType>* operandOut)
const {
79 bool const applyUpdates = operandOut !=
nullptr;
82 return viOperator->template applyRobust<RobustDir>(*operandOut, operandIn, offsets, backend);
84 return viOperator->template applyInPlaceRobust<RobustDir>(operandIn, offsets, backend);
88template<
typename ValueType,
typename SolutionType>
91 bool robust, std::vector<SolutionType>* operandOut)
const {
94 return computeScheduler<storm::OptimizationDirection::Maximize, storm::OptimizationDirection::Minimize>(operandIn, offsets, schedulerStorage,
97 return computeScheduler<storm::OptimizationDirection::Maximize, storm::OptimizationDirection::Maximize>(operandIn, offsets, schedulerStorage,
102 return computeScheduler<storm::OptimizationDirection::Minimize, OptimizationDirection::Maximize>(operandIn, offsets, schedulerStorage, operandOut);
104 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) const
Computes the optimal choices from the given solution.
SchedulerTrackingHelper(std::shared_ptr< ValueIterationOperator< ValueType, false, 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.
bool constexpr maximize(OptimizationDirection d)