15template<
typename ValueType>
17 if (storm::settings::getModule<storm::settings::modules::GeneralSettings>().isVerboseSet()) {
22template<
typename ValueType>
24 this->terminationCondition = std::move(terminationCondition);
27template<
typename ValueType>
29 this->terminationCondition =
nullptr;
32template<
typename ValueType>
34 return static_cast<bool>(this->terminationCondition);
37template<
typename ValueType>
39 return *terminationCondition;
42template<
typename ValueType>
44 return terminationCondition;
47template<
typename ValueType>
49 if (!this->hasCustomTerminationCondition()) {
53 return this->getTerminationCondition().
terminateNow(values, guarantee);
56template<
typename ValueType>
58 return static_cast<bool>(relevantValues);
61template<
typename ValueType>
63 return relevantValues.
get();
66template<
typename ValueType>
68 return relevantValues;
71template<
typename ValueType>
73 this->relevantValues = std::move(relevantValues);
76template<
typename ValueType>
78 this->relevantValues = relevantValues;
81template<
typename ValueType>
83 relevantValues = boost::none;
86template<
typename ValueType>
88 if (type == BoundType::Any) {
89 return static_cast<bool>(lowerBound) ||
static_cast<bool>(lowerBounds);
90 }
else if (type == BoundType::Global) {
91 return static_cast<bool>(lowerBound);
92 }
else if (type == BoundType::Local) {
93 return static_cast<bool>(lowerBounds);
98template<
typename ValueType>
100 if (type == BoundType::Any) {
101 return static_cast<bool>(upperBound) ||
static_cast<bool>(upperBounds);
102 }
else if (type == BoundType::Global) {
103 return static_cast<bool>(upperBound);
104 }
else if (type == BoundType::Local) {
105 return static_cast<bool>(upperBounds);
110template<
typename ValueType>
115template<
typename ValueType>
120template<
typename ValueType>
122 setLowerBound(lower);
123 setUpperBound(upper);
126template<
typename ValueType>
128 return lowerBound.get();
131template<
typename ValueType>
134 STORM_LOG_ASSERT(index < lowerBounds->size(),
"Invalid row index " << index <<
" for vector of size " << lowerBounds->size());
136 return std::max(lowerBound.get(), lowerBounds.get()[index]);
138 return lowerBounds.get()[index];
141 STORM_LOG_ASSERT(lowerBound,
"Lower bound requested but was not specified before.");
142 return lowerBound.get();
146template<
typename ValueType>
149 return lowerBound.get();
150 }
else if (convertLocalBounds) {
151 return *std::min_element(lowerBounds->begin(), lowerBounds->end());
153 STORM_LOG_THROW(
false, storm::exceptions::InvalidOperationException,
"No lower bound available but some was requested.");
157template<
typename ValueType>
159 return upperBound.get();
162template<
typename ValueType>
165 STORM_LOG_ASSERT(index < upperBounds->size(),
"Invalid row index " << index <<
" for vector of size " << upperBounds->size());
167 return std::min(upperBound.get(), upperBounds.get()[index]);
169 return upperBounds.get()[index];
172 STORM_LOG_ASSERT(upperBound,
"Upper bound requested but was not specified before.");
173 return upperBound.get();
177template<
typename ValueType>
180 return upperBound.get();
181 }
else if (convertLocalBounds) {
182 return *std::max_element(upperBounds->begin(), upperBounds->end());
184 STORM_LOG_THROW(
false, storm::exceptions::InvalidOperationException,
"No upper bound available but some was requested.");
188template<
typename ValueType>
190 return lowerBounds.get();
193template<
typename ValueType>
195 return upperBounds.get();
198template<
typename ValueType>
200 lowerBounds = values;
203template<
typename ValueType>
205 lowerBounds = std::move(values);
208template<
typename ValueType>
210 upperBounds = values;
213template<
typename ValueType>
215 upperBounds = std::move(values);
218template<
typename ValueType>
220 setLowerBounds(lower);
221 setUpperBounds(upper);
224template<
typename ValueType>
240template<
typename ValueType>
242 lowerBound = boost::none;
243 upperBound = boost::none;
244 lowerBounds = boost::none;
245 upperBounds = boost::none;
248template<
typename ValueType>
250 if (this->hasLowerBound(BoundType::Local)) {
251 lowerBoundsVector = this->getLowerBounds();
253 ValueType lowerBound = this->hasLowerBound(BoundType::Global) ? this->getLowerBound() : storm::utility::zero<ValueType>();
254 for (
auto& e : lowerBoundsVector) {
260template<
typename ValueType>
263 if (this->hasUpperBound(BoundType::Global)) {
264 upperBoundsVector.assign(upperBoundsVector.size(), this->getUpperBound());
266 upperBoundsVector.assign(this->getUpperBounds().begin(), this->getUpperBounds().end());
270template<
typename ValueType>
273 if (!upperBoundsVector) {
274 if (this->hasUpperBound(BoundType::Local)) {
275 STORM_LOG_ASSERT(length == this->getUpperBounds().size(),
"Mismatching sizes.");
276 upperBoundsVector = std::make_unique<std::vector<ValueType>>(this->getUpperBounds());
278 upperBoundsVector = std::make_unique<std::vector<ValueType>>(length, this->getUpperBound());
281 createUpperBoundsVector(*upperBoundsVector);
285template<
typename ValueType>
287 return this->progressMeasurement.is_initialized();
290template<
typename ValueType>
292 STORM_LOG_ASSERT(this->isShowProgressSet(),
"Tried to get the progress message delay but progress is not shown.");
293 return this->progressMeasurement->getShowProgressDelay();
296template<
typename ValueType>
298 if (this->isShowProgressSet()) {
299 this->progressMeasurement->startNewMeasurement(startingIteration);
303template<
typename ValueType>
305 if (this->isShowProgressSet()) {
307 this->progressMeasurement->setMaxCount(bound.get());
309 this->progressMeasurement->updateProgress(iteration);
313template<
typename ValueType>
318 STORM_LOG_TRACE(
"Iterative solver converged after " << iterations.get() <<
" iterations.");
321 STORM_LOG_TRACE(
"Iterative solver terminated early after " << iterations.get() <<
" iterations.");
324 STORM_LOG_WARN(
"Iterative solver did not converge after " << iterations.get() <<
" iterations.");
327 STORM_LOG_WARN(
"Iterative solver was aborted after " << iterations.get() <<
" iterations.");
330 STORM_LOG_THROW(
false, storm::exceptions::InvalidStateException,
"Iterative solver terminated unexpectedly.");
341 STORM_LOG_ASSERT(
false,
"Non-iterative solver should not exceed maximal number of iterations.");
348 STORM_LOG_THROW(
false, storm::exceptions::InvalidStateException,
"Solver terminated unexpectedly.");
353template<
typename ValueType>
355 uint64_t maximalNumberOfIterations)
const {
357 if (earlyTermination) {
359 }
else if (iterations >= maximalNumberOfIterations) {
368template<
typename ValueType>
370 uint64_t iterations, uint64_t maximalNumberOfIterations)
const {
371 return this->updateStatus(status, this->hasCustomTerminationCondition() && this->getTerminationCondition().terminateNow(x, guarantee), iterations,
372 maximalNumberOfIterations);
uint64_t getShowProgressDelay() const
Retrieves the delay between progress emissions.
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.
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< 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,...
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.
virtual bool terminateNow(std::vector< ValueType > const ¤tValues, SolverGuarantee const &guarantee=SolverGuarantee::None) const
Retrieves whether the guarantee provided by the solver for the current result is sufficient to termin...
A bit vector that is internally represented as a vector of 64-bit values.
bool get(uint64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
A class that provides convenience operations to display run times.
#define STORM_LOG_WARN(message)
#define STORM_LOG_TRACE(message)
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
@ MaximalIterationsExceeded
bool isTerminate()
Check whether the program should terminate (due to some abort signal).