Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
AbstractEquationSolver.h
Go to the documentation of this file.
1#ifndef STORM_SOLVER_ABSTRACTEQUATIONSOLVER_H_
2#define STORM_SOLVER_ABSTRACTEQUATIONSOLVER_H_
3
4#include <boost/optional.hpp>
5#include <chrono>
6#include <iostream>
7#include <memory>
8
12
13namespace storm {
14namespace solver {
15
16template<typename ValueType>
18 public:
20
28
33
38
43 bool terminateNow(std::vector<ValueType> const& values, SolverGuarantee const& guarantee) const;
44
48 bool hasRelevantValues() const;
49
54 boost::optional<storm::storage::BitVector> const& getOptionalRelevantValues() const;
55
59 void setRelevantValues(storm::storage::BitVector&& valuesOfInterest);
60
64 void setRelevantValues(storm::storage::BitVector const& valuesOfInterest);
65
70
71 enum class BoundType { Global, Local, Any };
72
76 bool hasLowerBound(BoundType const& type = BoundType::Any) const;
77
81 bool hasUpperBound(BoundType const& type = BoundType::Any) const;
82
86 void setLowerBound(ValueType const& value);
87
91 void setUpperBound(ValueType const& value);
92
96 void setBounds(ValueType const& lower, ValueType const& upper);
97
101 ValueType const& getLowerBound() const;
102
108 ValueType const& getLowerBound(uint64_t const& index) const;
109
115 ValueType getLowerBound(bool convertLocalBounds) const;
116
120 ValueType const& getUpperBound() const;
121
127 ValueType const& getUpperBound(uint64_t const& index) const;
128
134 ValueType getUpperBound(bool convertLocalBounds) const;
135
139 std::vector<ValueType> const& getLowerBounds() const;
140
144 std::vector<ValueType> const& getUpperBounds() const;
145
149 void setLowerBounds(std::vector<ValueType> const& values);
150
154 void setLowerBounds(std::vector<ValueType>&& values);
155
159 void setUpperBounds(std::vector<ValueType> const& values);
160
164 void setUpperBounds(std::vector<ValueType>&& values);
165
169 void setBounds(std::vector<ValueType> const& lower, std::vector<ValueType> const& upper);
170
172
176 void clearBounds();
177
181 bool isShowProgressSet() const;
182
186 uint64_t getShowProgressDelay() const;
187
191 void startMeasureProgress(uint64_t startingIteration = 0) const;
192
196 void showProgressIterative(uint64_t iterations, boost::optional<uint64_t> const& bound = boost::none) const;
197
198 protected:
205 std::unique_ptr<TerminationCondition<ValueType>> const& getTerminationConditionPointer() const;
206
207 void createUpperBoundsVector(std::vector<ValueType>& upperBoundsVector) const;
208 void createUpperBoundsVector(std::unique_ptr<std::vector<ValueType>>& upperBoundsVector, uint64_t length) const;
209 void createLowerBoundsVector(std::vector<ValueType>& lowerBoundsVector) const;
210
216 void reportStatus(SolverStatus status, boost::optional<uint64_t> const& iterations = boost::none) const;
217
227 SolverStatus updateStatus(SolverStatus status, std::vector<ValueType> const& x, SolverGuarantee const& guarantee, uint64_t iterations,
228 uint64_t maximalNumberOfIterations) const;
229
238 SolverStatus updateStatus(SolverStatus status, bool earlyTermination, uint64_t iterations, uint64_t maximalNumberOfIterations) const;
239
240 // A termination condition to be used (can be unset).
241 std::unique_ptr<TerminationCondition<ValueType>> terminationCondition;
242
243 // A bit vector containing the indices of the relevant values if they were set.
244 boost::optional<storm::storage::BitVector> relevantValues;
245
246 // A lower bound if one was set.
247 boost::optional<ValueType> lowerBound;
248
249 // An upper bound if one was set.
250 boost::optional<ValueType> upperBound;
251
252 // Lower bounds if they were set.
253 boost::optional<std::vector<ValueType>> lowerBounds;
254
255 // Lower bounds if they were set.
256 boost::optional<std::vector<ValueType>> upperBounds;
257
258 private:
259 // Indicates the progress of this solver.
260 mutable boost::optional<storm::utility::ProgressMeasurement> progressMeasurement;
261};
262
263} // namespace solver
264} // namespace storm
265
266#endif /* STORM_SOLVER_ABSTRACTEQUATIONSOLVER_H_ */
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:18
LabParser.cpp.
Definition cli.cpp:18