Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
AbstractEquationSolver.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/optional.hpp>
4#include <chrono>
5#include <iostream>
6#include <memory>
7
11
12namespace storm {
13namespace solver {
14
15template<typename ValueType>
17 public:
19
27
32
37
42 bool terminateNow(std::vector<ValueType> const& values, SolverGuarantee const& guarantee) const;
43
47 bool hasRelevantValues() const;
48
53 boost::optional<storm::storage::BitVector> const& getOptionalRelevantValues() const;
54
58 void setRelevantValues(storm::storage::BitVector&& valuesOfInterest);
59
63 void setRelevantValues(storm::storage::BitVector const& valuesOfInterest);
64
69
70 enum class BoundType { Global, Local, Any };
71
75 bool hasLowerBound(BoundType const& type = BoundType::Any) const;
76
80 bool hasUpperBound(BoundType const& type = BoundType::Any) const;
81
85 void setLowerBound(ValueType const& value);
86
90 void setUpperBound(ValueType const& value);
91
95 void setBounds(ValueType const& lower, ValueType const& upper);
96
100 ValueType const& getLowerBound() const;
101
107 ValueType const& getLowerBound(uint64_t const& index) const;
108
114 ValueType getLowerBound(bool convertLocalBounds) const;
115
119 ValueType const& getUpperBound() const;
120
126 ValueType const& getUpperBound(uint64_t const& index) const;
127
133 ValueType getUpperBound(bool convertLocalBounds) const;
134
138 std::vector<ValueType> const& getLowerBounds() const;
139
143 std::vector<ValueType> const& getUpperBounds() const;
144
148 void setLowerBounds(std::vector<ValueType> const& values);
149
153 void setLowerBounds(std::vector<ValueType>&& values);
154
158 void setUpperBounds(std::vector<ValueType> const& values);
159
163 void setUpperBounds(std::vector<ValueType>&& values);
164
168 void setBounds(std::vector<ValueType> const& lower, std::vector<ValueType> const& upper);
169
171
175 void clearBounds();
176
180 bool isShowProgressSet() const;
181
185 uint64_t getShowProgressDelay() const;
186
190 void startMeasureProgress(uint64_t startingIteration = 0) const;
191
195 void showProgressIterative(uint64_t iterations, boost::optional<uint64_t> const& bound = boost::none) const;
196
197 protected:
204 std::unique_ptr<TerminationCondition<ValueType>> const& getTerminationConditionPointer() const;
205
206 void createUpperBoundsVector(std::vector<ValueType>& upperBoundsVector) const;
207 void createUpperBoundsVector(std::unique_ptr<std::vector<ValueType>>& upperBoundsVector, uint64_t length) const;
208 void createLowerBoundsVector(std::vector<ValueType>& lowerBoundsVector) const;
209
215 void reportStatus(SolverStatus status, boost::optional<uint64_t> const& iterations = boost::none) const;
216
226 SolverStatus updateStatus(SolverStatus status, std::vector<ValueType> const& x, SolverGuarantee const& guarantee, uint64_t iterations,
227 uint64_t maximalNumberOfIterations) const;
228
237 SolverStatus updateStatus(SolverStatus status, bool earlyTermination, uint64_t iterations, uint64_t maximalNumberOfIterations) const;
238
239 // A termination condition to be used (can be unset).
240 std::unique_ptr<TerminationCondition<ValueType>> terminationCondition;
241
242 // A bit vector containing the indices of the relevant values if they were set.
243 boost::optional<storm::storage::BitVector> relevantValues;
244
245 // A lower bound if one was set.
246 boost::optional<ValueType> lowerBound;
247
248 // An upper bound if one was set.
249 boost::optional<ValueType> upperBound;
250
251 // Lower bounds if they were set.
252 boost::optional<std::vector<ValueType>> lowerBounds;
253
254 // Lower bounds if they were set.
255 boost::optional<std::vector<ValueType>> upperBounds;
256
257 private:
258 // Indicates the progress of this solver.
259 mutable boost::optional<storm::utility::ProgressMeasurement> progressMeasurement;
260};
261
262} // namespace solver
263} // namespace storm
uint64_t getShowProgressDelay() const
Retrieves the delay between progress emissions.
std::unique_ptr< TerminationCondition< ValueType > > terminationCondition
void clearRelevantValues()
Removes the values of interest (if there were any).
void setUpperBound(ValueType const &value)
Sets an upper bound for the solution that can potentially be used by the solver.
void createLowerBoundsVector(std::vector< ValueType > &lowerBoundsVector) const
std::vector< ValueType > const & getLowerBounds() const
Retrieves a vector containing the lower bounds (if there are any).
bool hasUpperBound(BoundType const &type=BoundType::Any) const
Retrieves whether this solver has an upper bound.
bool hasLowerBound(BoundType const &type=BoundType::Any) const
Retrieves whether this solver has a lower bound.
void showProgressIterative(uint64_t iterations, boost::optional< uint64_t > const &bound=boost::none) const
Shows progress if this solver is asked to do so.
storm::storage::BitVector const & getRelevantValues() const
Retrieves the relevant values (if there are any).
std::unique_ptr< TerminationCondition< ValueType > > const & getTerminationConditionPointer() const
void setLowerBound(ValueType const &value)
Sets a lower bound for the solution that can potentially be used by the solver.
ValueType const & getUpperBound() const
Retrieves the upper bound (if there is any).
void setUpperBounds(std::vector< ValueType > const &values)
Sets upper bounds for the solution that can potentially be used by the solver.
void setRelevantValues(storm::storage::BitVector &&valuesOfInterest)
Sets the relevant values.
bool terminateNow(std::vector< ValueType > const &values, SolverGuarantee const &guarantee) const
Checks whether the solver can terminate wrt.
void setBounds(ValueType const &lower, ValueType const &upper)
Sets bounds for the solution that can potentially be used by the solver.
void startMeasureProgress(uint64_t startingIteration=0) const
Starts to measure progress.
boost::optional< std::vector< ValueType > > upperBounds
void createUpperBoundsVector(std::vector< ValueType > &upperBoundsVector) const
void setBoundsFromOtherSolver(AbstractEquationSolver< ValueType > const &other)
void resetTerminationCondition()
Removes a previously set custom termination condition.
std::vector< ValueType > const & getUpperBounds() const
Retrieves a vector containing the upper bounds (if there are any).
bool isShowProgressSet() const
Retrieves whether progress is to be shown.
void clearBounds()
Removes all specified solution bounds.
TerminationCondition< ValueType > const & getTerminationCondition() const
Retrieves the custom termination condition (if any was set).
bool hasRelevantValues() const
Retrieves whether this solver has particularly relevant values.
bool hasCustomTerminationCondition() const
Retrieves whether a custom termination condition has been set.
boost::optional< std::vector< ValueType > > lowerBounds
boost::optional< storm::storage::BitVector > const & getOptionalRelevantValues() const
ValueType const & getLowerBound() const
Retrieves the lower bound (if there is any).
void setTerminationCondition(std::unique_ptr< TerminationCondition< ValueType > > terminationCondition)
Sets a custom termination condition that is used together with the regular termination condition of t...
SolverStatus updateStatus(SolverStatus status, std::vector< ValueType > const &x, SolverGuarantee const &guarantee, uint64_t iterations, uint64_t maximalNumberOfIterations) const
Update the status of the solver with respect to convergence, early termination, abortion,...
boost::optional< storm::storage::BitVector > relevantValues
void reportStatus(SolverStatus status, boost::optional< uint64_t > const &iterations=boost::none) const
Report the current status of the solver.
void setLowerBounds(std::vector< ValueType > const &values)
Sets lower bounds for the solution that can potentially be used by the solver.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16