Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SchedulerTrackingHelper.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/optional.hpp>
4#include <cstdint>
5#include <memory>
6#include <vector>
7
11
12namespace storm::solver::helper {
13
14template<typename ValueType, storm::OptimizationDirection Dir, bool TrivialRowGrouping>
16 public:
17 RobustSchedulerTrackingBackend(std::vector<uint64_t>& schedulerStorage, std::vector<uint64_t> const& robustIndices, bool applyUpdates)
18 : schedulerStorage(schedulerStorage), robustIndices(robustIndices), applyUpdates(applyUpdates) {
19 // intentionally empty
20 }
22 isConverged = true;
23 }
24
25 void processRobustRow(ValueType&& value, uint64_t row, std::vector<std::pair<ValueType, std::pair<ValueType, uint64_t>>> const& info) {
26 currStart = robustIndices[row];
27 for (uint64_t i = 0; i < info.size(); ++i) {
28 isConverged &= schedulerStorage[currStart + i] == info[i].second.second;
29 schedulerStorage[currStart + i] = info[i].second.second;
30 }
31 best = value;
32 }
33
34 void applyUpdate(ValueType& currValue, uint64_t /* rowGroup */) {
35 if (applyUpdates) {
36 currValue = best;
37 }
38 }
39
40 void endOfIteration() const {}
41
42 bool converged() const {
43 return isConverged;
44 }
45
46 bool constexpr abort() const {
47 return false;
48 }
49
50 private:
51 std::vector<uint64_t>& schedulerStorage;
52 std::vector<uint64_t> const& robustIndices;
53
54 ValueType best;
55
56 uint64_t currStart;
57
58 bool const applyUpdates;
59
60 bool isConverged;
61
62 std::vector<std::pair<uint64_t, ValueType>> currValues;
63};
64
68template<typename ValueType, typename SolutionType = ValueType, bool TrivialRowGrouping = false>
70 public:
75
90 bool computeScheduler(std::vector<SolutionType>& operandIn, std::vector<ValueType> const& offsets, storm::OptimizationDirection const& dir,
91 std::vector<uint64_t>& schedulerStorage, UncertaintyResolutionMode uncertaintyResolutionMode,
92 std::vector<SolutionType>* operandOut = nullptr, boost::optional<std::vector<uint64_t>> const& robustIndices = boost::none) const;
93
94 private:
98 template<storm::OptimizationDirection Dir, storm::OptimizationDirection RobustDir>
99 bool computeScheduler(std::vector<SolutionType>& operandIn, std::vector<ValueType> const& offsets, std::vector<uint64_t>& schedulerStorage,
100 std::vector<SolutionType>* operandOut, boost::optional<std::vector<uint64_t>> const& robustIndices = boost::none) const;
101
102 private:
103 std::shared_ptr<ValueIterationOperator<ValueType, TrivialRowGrouping, SolutionType>> viOperator;
104};
105
106} // namespace storm::solver::helper
RobustSchedulerTrackingBackend(std::vector< uint64_t > &schedulerStorage, std::vector< uint64_t > const &robustIndices, bool applyUpdates)
void processRobustRow(ValueType &&value, uint64_t row, std::vector< std::pair< ValueType, std::pair< ValueType, uint64_t > > > const &info)
bool computeScheduler(std::vector< SolutionType > &operandIn, std::vector< ValueType > const &offsets, storm::OptimizationDirection const &dir, std::vector< uint64_t > &schedulerStorage, UncertaintyResolutionMode uncertaintyResolutionMode, 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).
solver::OptimizationDirection OptimizationDirection