diff --git a/src/modelchecker/dft/DFTModelChecker.cpp b/src/modelchecker/dft/DFTModelChecker.cpp index 205e658f3..692f61735 100644 --- a/src/modelchecker/dft/DFTModelChecker.cpp +++ b/src/modelchecker/dft/DFTModelChecker.cpp @@ -187,6 +187,7 @@ namespace storm { ++iteration; STORM_LOG_INFO("Result after iteration " << iteration << ": (" << std::setprecision(10) << approxResult.first << ", " << approxResult.second << ")"); + STORM_LOG_THROW(!storm::utility::isInfinity(approxResult.first) && !storm::utility::isInfinity(approxResult.second), storm::exceptions::NotSupportedException, "Approximation does not work if result might be infinity."); } while (!isApproximationSufficient(approxResult.first, approxResult.second, approximationError)); STORM_LOG_INFO("Finished approximation after " << iteration << " iteration" << (iteration > 1 ? "s." : ".")); diff --git a/src/utility/constants.cpp b/src/utility/constants.cpp index c3184c194..c787b7d91 100644 --- a/src/utility/constants.cpp +++ b/src/utility/constants.cpp @@ -40,7 +40,11 @@ namespace storm { return true; } - + template + bool isInfinity(ValueType const& a) { + return a == infinity(); + } + #ifdef STORM_HAVE_CARL template<> bool isOne(storm::RationalFunction const& a) { @@ -56,7 +60,7 @@ namespace storm { bool isConstant(storm::RationalFunction const& a) { return a.isConstant(); } - + template<> bool isOne(storm::Polynomial const& a) { return a.isOne(); @@ -71,13 +75,19 @@ namespace storm { bool isConstant(storm::Polynomial const& a) { return a.isConstant(); } - + template<> storm::RationalFunction infinity() { // FIXME: this should be treated more properly. return storm::RationalFunction(-1.0); } - + + template<> + bool isInfinity(storm::RationalFunction const& a) { + // FIXME: this should be treated more properly. + return a == infinity(); + } + template<> bool isOne(storm::RationalNumber const& a) { return carl::isOne(a); @@ -166,7 +176,8 @@ namespace storm { template bool isOne(double const& value); template bool isZero(double const& value); template bool isConstant(double const& value); - + template bool isInfinity(double const& value); + template double one(); template double zero(); template double infinity(); @@ -182,7 +193,8 @@ namespace storm { template bool isOne(float const& value); template bool isZero(float const& value); template bool isConstant(float const& value); - + template bool isInfinity(float const& value); + template float one(); template float zero(); template float infinity(); @@ -198,7 +210,8 @@ namespace storm { template bool isOne(int const& value); template bool isZero(int const& value); template bool isConstant(int const& value); - + template bool isInfinity(int const& value); + template int one(); template int zero(); template int infinity(); @@ -214,6 +227,7 @@ namespace storm { template bool isOne(storm::storage::sparse::state_type const& value); template bool isZero(storm::storage::sparse::state_type const& value); template bool isConstant(storm::storage::sparse::state_type const& value); + template bool isInfinity(storm::storage::sparse::state_type const& value); template uint32_t one(); template uint32_t zero(); @@ -235,7 +249,8 @@ namespace storm { template bool isOne(RationalFunction const& value); template bool isZero(RationalFunction const& value); template bool isConstant(RationalFunction const& value); - + template bool isInfinity(RationalFunction const& value); + template RationalFunction one(); template RationalFunction zero(); template storm::RationalFunction infinity(); @@ -251,7 +266,8 @@ namespace storm { template bool isOne(RationalNumber const& value); template bool isZero(RationalNumber const& value); template bool isConstant(RationalNumber const& value); - + template bool isInfinity(RationalNumber const& value); + template RationalNumber one(); template RationalNumber zero(); @@ -261,7 +277,8 @@ namespace storm { template bool isOne(Interval const& value); template bool isZero(Interval const& value); template bool isConstant(Interval const& value); - + template bool isInfinity(Interval const& value); + template Interval one(); template Interval zero(); diff --git a/src/utility/constants.h b/src/utility/constants.h index 80222b74f..b80b61777 100644 --- a/src/utility/constants.h +++ b/src/utility/constants.h @@ -38,7 +38,10 @@ namespace storm { template bool isConstant(ValueType const& a); - + + template + bool isInfinity(ValueType const& a); + template ValueType pow(ValueType const& value, uint_fast64_t exponent); @@ -56,4 +59,4 @@ namespace storm { } } -#endif /* STORM_UTILITY_CONSTANTS_H_ */ \ No newline at end of file +#endif /* STORM_UTILITY_CONSTANTS_H_ */