18 changed files with 238 additions and 74 deletions
-
54src/solver/AllowEarlyTerminationCondition.cpp
-
54src/solver/AllowEarlyTerminationCondition.h
-
4src/solver/GmmxxMinMaxLinearEquationSolver.cpp
-
4src/solver/MinMaxLinearEquationSolver.cpp
-
9src/solver/MinMaxLinearEquationSolver.h
-
4src/solver/NativeMinMaxLinearEquationSolver.cpp
-
3src/solver/SolverSelectionOptions.h
-
62src/utility/solver.cpp
-
34src/utility/solver.h
-
4test/functional/modelchecker/GmmxxHybridMdpPrctlModelCheckerTest.cpp
-
8test/functional/modelchecker/GmmxxMdpPrctlModelCheckerTest.cpp
-
5test/functional/modelchecker/NativeHybridMdpPrctlModelCheckerTest.cpp
-
18test/functional/modelchecker/NativeMdpPrctlModelCheckerTest.cpp
-
8test/functional/modelchecker/TopologicalValueIterationMdpPrctlModelCheckerTest.cpp
-
29test/functional/solver/GmmxxMinMaxLinearEquationSolverTest.cpp
-
4test/performance/modelchecker/GmmxxMdpPrctlModelCheckerTest.cpp
-
4test/performance/modelchecker/NativeMdpPrctlModelCheckerTest.cpp
-
4test/performance/modelchecker/TopologicalValueIterationMdpPrctlModelCheckerTest.cpp
@ -0,0 +1,54 @@ |
|||
#include "AllowEarlyTerminationCondition.h"
|
|||
#include "src/utility/vector.h"
|
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
|
|||
template<typename ValueType> |
|||
TerminateAfterFilteredSumPassesThresholdValue<ValueType>::TerminateAfterFilteredSumPassesThresholdValue(storm::storage::BitVector const& filter, ValueType threshold, bool terminateIfAbove) : |
|||
terminationThreshold(threshold), filter(filter), terminateIfAboveThreshold(terminateIfAbove) |
|||
{ |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
template<typename ValueType> |
|||
bool TerminateAfterFilteredSumPassesThresholdValue<ValueType>::terminateNow(const std::vector<ValueType>& currentValues) const { |
|||
assert(currentValues.size() >= filter.size()); |
|||
ValueType currentThreshold = storm::utility::vector::sum_if(currentValues, filter); |
|||
|
|||
if(this->terminateIfAboveThreshold) { |
|||
return currentThreshold >= this->terminationThreshold; |
|||
} else { |
|||
return currentThreshold <= this->terminationThreshold; |
|||
} |
|||
|
|||
} |
|||
|
|||
template<typename ValueType> |
|||
TerminateAfterFilteredExtremumPassesThresholdValue<ValueType>::TerminateAfterFilteredExtremumPassesThresholdValue(storm::storage::BitVector const& filter, ValueType threshold, bool terminateIfAbove, bool useMinimum) : |
|||
terminationThreshold(threshold), filter(filter), terminateIfAboveThreshold(terminateIfAbove), useMinimumAsExtremum(useMinimum) |
|||
{ |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
template<typename ValueType> |
|||
bool TerminateAfterFilteredExtremumPassesThresholdValue<ValueType>::terminateNow(const std::vector<ValueType>& currentValues) const { |
|||
assert(currentValues.size() >= filter.size()); |
|||
|
|||
ValueType initVal = terminateIfAboveThreshold ? terminationThreshold - 1 : terminationThreshold + 1; |
|||
ValueType currentThreshold = useMinimumAsExtremum ? storm::utility::vector::max_if(currentValues, filter, initVal) : storm::utility::vector::max_if(currentValues, filter, initVal); |
|||
|
|||
if(this->terminateIfAboveThreshold) { |
|||
return currentThreshold >= this->terminationThreshold; |
|||
} else { |
|||
return currentThreshold <= this->terminationThreshold; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
template class TerminateAfterFilteredExtremumPassesThresholdValue<double>; |
|||
template class TerminateAfterFilteredSumPassesThresholdValue<double>; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,54 @@ |
|||
#ifndef ALLOWEARLYTERMINATIONCONDITION_H |
|||
#define ALLOWEARLYTERMINATIONCONDITION_H |
|||
|
|||
#include <vector> |
|||
#include "src/storage/BitVector.h" |
|||
|
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
template<typename ValueType> |
|||
class AllowEarlyTerminationCondition { |
|||
public: |
|||
virtual bool terminateNow(std::vector<ValueType> const& currentValues) const = 0; |
|||
}; |
|||
|
|||
template<typename ValueType> |
|||
class NoEarlyTerminationCondition : public AllowEarlyTerminationCondition<ValueType> { |
|||
public: |
|||
bool terminateNow(std::vector<ValueType> const& currentValues) const { return false; } |
|||
}; |
|||
|
|||
template<typename ValueType> |
|||
class TerminateAfterFilteredSumPassesThresholdValue : public AllowEarlyTerminationCondition<ValueType> { |
|||
public: |
|||
TerminateAfterFilteredSumPassesThresholdValue(storm::storage::BitVector const& filter, ValueType threshold, bool terminateAbove); |
|||
bool terminateNow(std::vector<ValueType> const& currentValues) const; |
|||
|
|||
protected: |
|||
ValueType terminationThreshold; |
|||
storm::storage::BitVector filter; |
|||
bool terminateIfAboveThreshold; |
|||
}; |
|||
|
|||
template<typename ValueType> |
|||
class TerminateAfterFilteredExtremumPassesThresholdValue : public AllowEarlyTerminationCondition<ValueType>{ |
|||
public: |
|||
TerminateAfterFilteredExtremumPassesThresholdValue(storm::storage::BitVector const& filter, ValueType threshold, bool terminateAbove, bool useMinimum); |
|||
bool terminateNow(std::vector<ValueType> const& currentValue) const; |
|||
|
|||
protected: |
|||
ValueType terminationThreshold; |
|||
storm::storage::BitVector filter; |
|||
bool terminateIfAboveThreshold; |
|||
bool useMinimumAsExtremum; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
#endif /* ALLOWEARLYTERMINATIONCONDITION_H */ |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue