diff --git a/src/storm/solver/AbstractEquationSolver.cpp b/src/storm/solver/AbstractEquationSolver.cpp index c068e5d31..ecfa4600e 100644 --- a/src/storm/solver/AbstractEquationSolver.cpp +++ b/src/storm/solver/AbstractEquationSolver.cpp @@ -125,7 +125,22 @@ namespace storm { ValueType const& AbstractEquationSolver::getLowerBound() const { return lowerBound.get(); } - + + template + ValueType const& AbstractEquationSolver::getLowerBound(uint64_t const& index) const { + if (lowerBounds) { + STORM_LOG_ASSERT(index < lowerBounds->size(), "Invalid row index " << index << " for vector of size " << lowerBounds->size()); + if (lowerBound) { + return std::max(lowerBound.get(), lowerBounds.get()[index]); + } else { + return lowerBounds.get()[index]; + } + } else { + STORM_LOG_ASSERT(lowerBound, "Lower bound requested but was not specified before."); + return lowerBound.get(); + } + } + template ValueType AbstractEquationSolver::getLowerBound(bool convertLocalBounds) const { if (lowerBound) { @@ -142,6 +157,21 @@ namespace storm { return upperBound.get(); } + template + ValueType const& AbstractEquationSolver::getUpperBound(uint64_t const& index) const { + if (upperBounds) { + STORM_LOG_ASSERT(index < upperBounds->size(), "Invalid row index " << index << " for vector of size " << upperBounds->size()); + if (upperBound) { + return std::min(upperBound.get(), upperBounds.get()[index]); + } else { + return upperBounds.get()[index]; + } + } else { + STORM_LOG_ASSERT(upperBound, "Upper bound requested but was not specified before."); + return upperBound.get(); + } + } + template ValueType AbstractEquationSolver::getUpperBound(bool convertLocalBounds) const { if (upperBound) { diff --git a/src/storm/solver/AbstractEquationSolver.h b/src/storm/solver/AbstractEquationSolver.h index 0301ad42e..4dca210f8 100644 --- a/src/storm/solver/AbstractEquationSolver.h +++ b/src/storm/solver/AbstractEquationSolver.h @@ -100,6 +100,13 @@ namespace storm { */ ValueType const& getLowerBound() const; + /*! + * Retrieves the lower bound for the variable with the given index (if there is any lower bound). + * @pre some lower bound (local or global) has been specified + * @return the largest lower bound known for the given row + */ + ValueType const& getLowerBound(uint64_t const& index) const; + /*! * Retrieves the lower bound (if there is any). * If the given flag is true and if there are only local bounds, @@ -112,6 +119,13 @@ namespace storm { */ ValueType const& getUpperBound() const; + /*! + * Retrieves the upper bound for the variable with the given index (if there is any upper bound). + * @pre some upper bound (local or global) has been specified + * @return the smallest upper bound known for the given row + */ + ValueType const& getUpperBound(uint64_t const& index) const; + /*! * Retrieves the upper bound (if there is any). * If the given flag is true and if there are only local bounds,