11template<
typename ValueType, storm::OptimizationDirection Dir>
16 : schedulerStorage(schedulerStorage), applyUpdates(applyUpdates), rowGroupIndices(rowGroupIndices) {
23 void firstRow(ValueType&& value, uint64_t rowGroup, uint64_t row) {
24 currChoice = row - rowGroupIndices[rowGroup];
25 best = std::move(value);
28 void nextRow(ValueType&& value, uint64_t rowGroup, uint64_t row) {
30 currChoice = row - rowGroupIndices[rowGroup];
31 }
else if (*best == value) {
34 if (uint64_t rowChoice = row - rowGroupIndices[rowGroup]; rowChoice == schedulerStorage[rowGroup]) {
35 currChoice = rowChoice;
42 currValue = std::move(*best);
44 auto& choice = schedulerStorage[rowGroup];
46 isConverged = choice == currChoice;
62 std::vector<uint64_t>& schedulerStorage;
63 bool const applyUpdates;
64 std::vector<typename ValueIterationOperator<ValueType, false>::IndexType>
const& rowGroupIndices;
71template<
typename ValueType,
typename SolutionType,
bool TrivialRowGrouping>
74 : viOperator(viOperator) {
78template<
typename ValueType,
typename SolutionType,
bool TrivialRowGrouping>
79template<storm::OptimizationDirection Dir, storm::OptimizationDirection RobustDir>
81 std::vector<ValueType>
const& offsets,
82 std::vector<uint64_t>& schedulerStorage,
83 std::vector<SolutionType>* operandOut,
84 boost::optional<std::vector<uint64_t>>
const& robustIndices)
const {
85 bool const applyUpdates = operandOut !=
nullptr;
86 if constexpr (TrivialRowGrouping && std::is_same<SolutionType, double>::value) {
87 STORM_LOG_ASSERT(robustIndices,
"Tracking scheduler with trivial row grouping but no robust indices => there is no scheduler.");
90 return viOperator->template applyRobust<RobustDir>(*operandOut, operandIn, offsets, backend);
92 return viOperator->template applyInPlaceRobust<RobustDir>(operandIn, offsets, backend);
95 STORM_LOG_WARN_COND(!robustIndices,
"Only tracking nondeterminism, not ordering of intervals.");
96 SchedulerTrackingBackend<SolutionType, Dir> backend(schedulerStorage, viOperator->getRowGroupIndices(), applyUpdates);
98 return viOperator->template applyRobust<RobustDir>(*operandOut, operandIn, offsets, backend);
100 return viOperator->template applyInPlaceRobust<RobustDir>(operandIn, offsets, backend);
105template<
typename ValueType,
typename SolutionType,
bool TrivialRowGrouping>
107 std::vector<ValueType>
const& offsets,
109 std::vector<uint64_t>& schedulerStorage,
bool robust,
110 std::vector<SolutionType>* operandOut,
111 boost::optional<std::vector<uint64_t>>
const& robustIndices)
const {
114 if (robust && !TrivialRowGrouping) {
115 return computeScheduler<storm::OptimizationDirection::Maximize, storm::OptimizationDirection::Minimize>(operandIn, offsets, schedulerStorage,
116 operandOut, robustIndices);
118 return computeScheduler<storm::OptimizationDirection::Maximize, storm::OptimizationDirection::Maximize>(operandIn, offsets, schedulerStorage,
119 operandOut, robustIndices);
122 if (robust && !TrivialRowGrouping) {
123 return computeScheduler<storm::OptimizationDirection::Minimize, OptimizationDirection::Maximize>(operandIn, offsets, schedulerStorage, operandOut,
126 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)