#include "storm/solver/TerminationCondition.h" #include "storm/utility/vector.h" #include "storm/adapters/RationalFunctionAdapter.h" #include "storm/utility/macros.h" namespace storm { namespace solver { template bool NoTerminationCondition::terminateNow(std::vector const& currentValues, SolverGuarantee const& guarantee) const { return false; } template bool NoTerminationCondition::requiresGuarantee(SolverGuarantee const&) const { return false; } template TerminateIfFilteredSumExceedsThreshold::TerminateIfFilteredSumExceedsThreshold(storm::storage::BitVector const& filter, ValueType const& threshold, bool strict) : threshold(threshold), filter(filter), strict(strict) { // Intentionally left empty. } template bool TerminateIfFilteredSumExceedsThreshold::terminateNow(std::vector const& currentValues, SolverGuarantee const& guarantee) const { if (guarantee != SolverGuarantee::LessOrEqual) { return false; } STORM_LOG_ASSERT(currentValues.size() == filter.size(), "Vectors sizes mismatch."); ValueType currentThreshold = storm::utility::vector::sum_if(currentValues, filter); return strict ? currentThreshold > this->threshold : currentThreshold >= this->threshold; } template bool TerminateIfFilteredSumExceedsThreshold::requiresGuarantee(SolverGuarantee const& guarantee) const { return guarantee == SolverGuarantee::LessOrEqual; } template TerminateIfFilteredExtremumExceedsThreshold::TerminateIfFilteredExtremumExceedsThreshold(storm::storage::BitVector const& filter, bool strict, ValueType const& threshold, bool useMinimum) : TerminateIfFilteredSumExceedsThreshold(filter, threshold, strict), useMinimum(useMinimum) { // Intentionally left empty. } template bool TerminateIfFilteredExtremumExceedsThreshold::terminateNow(std::vector const& currentValues, SolverGuarantee const& guarantee) const { if (guarantee != SolverGuarantee::LessOrEqual) { return false; } STORM_LOG_ASSERT(currentValues.size() == this->filter.size(), "Vectors sizes mismatch."); ValueType currentValue = useMinimum ? storm::utility::vector::min_if(currentValues, this->filter) : storm::utility::vector::max_if(currentValues, this->filter); return this->strict ? currentValue > this->threshold : currentValue >= this->threshold; } template bool TerminateIfFilteredExtremumExceedsThreshold::requiresGuarantee(SolverGuarantee const& guarantee) const { return guarantee == SolverGuarantee::LessOrEqual; } template TerminateIfFilteredExtremumBelowThreshold::TerminateIfFilteredExtremumBelowThreshold(storm::storage::BitVector const& filter, bool strict, ValueType const& threshold, bool useMinimum) : TerminateIfFilteredSumExceedsThreshold(filter, threshold, strict), useMinimum(useMinimum) { // Intentionally left empty. } template bool TerminateIfFilteredExtremumBelowThreshold::terminateNow(std::vector const& currentValues, SolverGuarantee const& guarantee) const { if (guarantee != SolverGuarantee::GreaterOrEqual) { return false; } STORM_LOG_ASSERT(currentValues.size() == this->filter.size(), "Vectors sizes mismatch."); ValueType currentValue = useMinimum ? storm::utility::vector::min_if(currentValues, this->filter) : storm::utility::vector::max_if(currentValues, this->filter); return this->strict ? currentValue < this->threshold : currentValue <= this->threshold; } template bool TerminateIfFilteredExtremumBelowThreshold::requiresGuarantee(SolverGuarantee const& guarantee) const { return guarantee == SolverGuarantee::GreaterOrEqual; } template class TerminateIfFilteredSumExceedsThreshold; template class TerminateIfFilteredExtremumExceedsThreshold; template class TerminateIfFilteredExtremumBelowThreshold; #ifdef STORM_HAVE_CARL template class TerminateIfFilteredSumExceedsThreshold; template class TerminateIfFilteredExtremumExceedsThreshold; template class TerminateIfFilteredExtremumBelowThreshold; #endif } }