Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MultiDimensionalRewardUnfolding.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/optional.hpp>
4
17
18namespace storm {
19namespace modelchecker {
20namespace helper {
21namespace rewardbounded {
22
23template<typename ValueType, bool SingleObjectiveMode>
25 public:
26 typedef typename EpochManager::Epoch Epoch; // The number of reward steps that are "left" for each dimension
28
29 typedef typename std::conditional<SingleObjectiveMode, ValueType, std::vector<ValueType>>::type SolutionType;
30
31 /*
32 *
33 * @param model The (preprocessed) model
34 * @param objectives The (preprocessed) objectives
35 *
36 */
39
47 MultiDimensionalRewardUnfolding(storm::models::sparse::Model<ValueType> const& model, std::shared_ptr<storm::logic::OperatorFormula const> objectiveFormula,
48 std::set<storm::expressions::Variable> const& infinityBoundVariables = {});
49
51
57 Epoch getStartEpoch(bool setUnknownDimsToBottom = false);
58
63 std::vector<Epoch> getEpochComputationOrder(Epoch const& startEpoch, bool stopAtComputedEpochs = false);
64
66
68
72 ValueType getRequiredEpochModelPrecision(Epoch const& startEpoch, ValueType const& precision);
73
77 boost::optional<ValueType> getUpperObjectiveBound(uint64_t objectiveIndex = 0);
78 boost::optional<ValueType> getLowerObjectiveBound(uint64_t objectiveIndex = 0);
79
80 void setSolutionForCurrentEpoch(std::vector<SolutionType>&& inStateSolutions);
81 SolutionType getInitialStateResult(Epoch const& epoch); // Assumes that the initial state is unique
82 SolutionType getInitialStateResult(Epoch const& epoch, uint64_t initialStateIndex);
83
84 EpochManager const& getEpochManager() const;
85 Dimension<ValueType> const& getDimension(uint64_t dim) const;
86
87 private:
88 void setCurrentEpochClass(Epoch const& epoch);
89 void initialize(std::set<storm::expressions::Variable> const& infinityBoundVariables = {});
90
91 void initializeObjectives(std::vector<Epoch>& epochSteps, std::set<storm::expressions::Variable> const& infinityBoundVariables);
92 void computeMaxDimensionValues();
93 void translateLowerBoundInfinityDimensions(std::vector<Epoch>& epochSteps);
94
95 void initializeMemoryProduct(std::vector<Epoch> const& epochSteps);
96
97 template<bool SO = SingleObjectiveMode, typename std::enable_if<SO, int>::type = 0>
98 SolutionType getScaledSolution(SolutionType const& solution, ValueType const& scalingFactor) const;
99 template<bool SO = SingleObjectiveMode, typename std::enable_if<!SO, int>::type = 0>
100 SolutionType getScaledSolution(SolutionType const& solution, ValueType const& scalingFactor) const;
101
102 template<bool SO = SingleObjectiveMode, typename std::enable_if<SO, int>::type = 0>
103 void addScaledSolution(SolutionType& solution, SolutionType const& solutionToAdd, ValueType const& scalingFactor) const;
104 template<bool SO = SingleObjectiveMode, typename std::enable_if<!SO, int>::type = 0>
105 void addScaledSolution(SolutionType& solution, SolutionType const& solutionToAdd, ValueType const& scalingFactor) const;
106
107 template<bool SO = SingleObjectiveMode, typename std::enable_if<SO, int>::type = 0>
108 void setSolutionEntry(SolutionType& solution, uint64_t objIndex, ValueType const& value) const;
109 template<bool SO = SingleObjectiveMode, typename std::enable_if<!SO, int>::type = 0>
110 void setSolutionEntry(SolutionType& solution, uint64_t objIndex, ValueType const& value) const;
111
112 template<bool SO = SingleObjectiveMode, typename std::enable_if<SO, int>::type = 0>
113 std::string solutionToString(SolutionType const& solution) const;
114 template<bool SO = SingleObjectiveMode, typename std::enable_if<!SO, int>::type = 0>
115 std::string solutionToString(SolutionType const& solution) const;
116
117 SolutionType const& getStateSolution(Epoch const& epoch, uint64_t const& productState);
118 struct EpochSolution {
119 uint64_t count;
120 std::shared_ptr<std::vector<uint64_t> const> productStateToSolutionVectorMap;
121 std::vector<SolutionType> solutions;
122 };
123 std::map<Epoch, EpochSolution> epochSolutions;
124 EpochSolution const& getEpochSolution(std::map<Epoch, EpochSolution const*> const& solutions, Epoch const& epoch);
125 SolutionType const& getStateSolution(EpochSolution const& epochSolution, uint64_t const& productState);
126
128 std::vector<storm::modelchecker::multiobjective::Objective<ValueType>> objectives;
129
130 std::unique_ptr<ProductModel<ValueType>> productModel;
131
132 std::vector<uint64_t> epochModelToProductChoiceMap;
133 std::shared_ptr<std::vector<uint64_t> const> productStateToEpochModelInStateMap;
134 std::set<Epoch> possibleEpochSteps;
135
136 EpochModel<ValueType, SingleObjectiveMode> epochModel;
137 boost::optional<Epoch> currentEpoch;
138
139 EpochManager epochManager;
140
141 std::vector<Dimension<ValueType>> dimensions;
142 std::vector<storm::storage::BitVector> objectiveDimensions;
143};
144} // namespace rewardbounded
145} // namespace helper
146} // namespace modelchecker
147} // namespace storm
Epoch getStartEpoch(bool setUnknownDimsToBottom=false)
Retrieves the desired epoch that needs to be analyzed to compute the reward bounded values.
std::conditional< SingleObjectiveMode, ValueType, std::vector< ValueType > >::type SolutionType
EpochModel< ValueType, SingleObjectiveMode > & setCurrentEpoch(Epoch const &epoch)
std::vector< Epoch > getEpochComputationOrder(Epoch const &startEpoch, bool stopAtComputedEpochs=false)
Computes a sequence of epochs that need to be analyzed to get a result at the start epoch.
ValueType getRequiredEpochModelPrecision(Epoch const &startEpoch, ValueType const &precision)
Returns the precision required for the analyzis of each epoch model in order to achieve the given ove...
boost::optional< ValueType > getUpperObjectiveBound(uint64_t objectiveIndex=0)
Returns an upper/lower bound for the objective result in every state (if this bound could be computed...
void setEquationSystemFormatForEpochModel(storm::solver::LinearEquationSolverProblemFormat eqSysFormat)
Base class for all sparse models.
Definition Model.h:33
LabParser.cpp.
Definition cli.cpp:18