|
|
@ -1,6 +1,10 @@ |
|
|
|
#pragma once |
|
|
|
#include <memory> |
|
|
|
|
|
|
|
#include "storm/utility/constants.h" |
|
|
|
#include "storm/utility/macros.h" |
|
|
|
|
|
|
|
|
|
|
|
namespace storm { |
|
|
|
|
|
|
|
namespace builder { |
|
|
@ -12,25 +16,32 @@ namespace storm { |
|
|
|
|
|
|
|
|
|
|
|
/*! |
|
|
|
* General super class for appoximation heuristics. |
|
|
|
* General super class for approximation heuristics. |
|
|
|
*/ |
|
|
|
template<typename ValueType> |
|
|
|
class DFTExplorationHeuristic { |
|
|
|
|
|
|
|
public: |
|
|
|
DFTExplorationHeuristic(size_t id); |
|
|
|
explicit DFTExplorationHeuristic(size_t id) : id(id), expand(true), lowerBound(storm::utility::zero<ValueType>()), upperBound(storm::utility::infinity<ValueType>()), depth(0), probability(storm::utility::one<ValueType>()) { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
|
DFTExplorationHeuristic(size_t id, DFTExplorationHeuristic const& predecessor, ValueType rate, ValueType exitRate); |
|
|
|
DFTExplorationHeuristic(size_t id, DFTExplorationHeuristic const& predecessor, ValueType rate, ValueType exitRate) : id(id), expand(false), lowerBound(storm::utility::zero<ValueType>()), upperBound(storm::utility::zero<ValueType>()), depth(predecessor.depth + 1), probability(storm::utility::one<ValueType>()) { |
|
|
|
this->updateHeuristicValues(predecessor, rate, exitRate); |
|
|
|
} |
|
|
|
|
|
|
|
virtual ~DFTExplorationHeuristic() = default; |
|
|
|
|
|
|
|
void setBounds(ValueType lowerBound, ValueType upperBound); |
|
|
|
|
|
|
|
virtual bool updateHeuristicValues(DFTExplorationHeuristic const& predecessor, ValueType rate, ValueType exitRate) = 0; |
|
|
|
|
|
|
|
virtual double getPriority() const = 0; |
|
|
|
void setBounds(ValueType lowerBound, ValueType upperBound) { |
|
|
|
this->lowerBound = lowerBound; |
|
|
|
this->upperBound = upperBound; |
|
|
|
} |
|
|
|
|
|
|
|
virtual bool isSkip(double approximationThreshold) const = 0; |
|
|
|
virtual bool updateHeuristicValues(DFTExplorationHeuristic const& predecessor, ValueType rate, ValueType exitRate) { |
|
|
|
STORM_LOG_ASSERT(!storm::utility::isZero<ValueType>(exitRate), "Exit rate is 0"); |
|
|
|
probability += predecessor.getProbability() * rate/exitRate; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
void markExpand() { |
|
|
|
expand = true; |
|
|
@ -40,7 +51,7 @@ namespace storm { |
|
|
|
return id; |
|
|
|
} |
|
|
|
|
|
|
|
bool isExpand() { |
|
|
|
bool isExpand() const { |
|
|
|
return expand; |
|
|
|
} |
|
|
|
|
|
|
@ -60,6 +71,16 @@ namespace storm { |
|
|
|
return upperBound; |
|
|
|
} |
|
|
|
|
|
|
|
virtual double getPriority() const = 0; |
|
|
|
|
|
|
|
virtual bool isSkip(double approximationThreshold) const { |
|
|
|
return !this->isExpand() && this->getPriority() < approximationThreshold; |
|
|
|
} |
|
|
|
|
|
|
|
virtual bool operator<(DFTExplorationHeuristic<ValueType> const& other) const { |
|
|
|
return this->getPriority() < other.getPriority(); |
|
|
|
} |
|
|
|
|
|
|
|
protected: |
|
|
|
size_t id; |
|
|
|
bool expand; |
|
|
@ -76,7 +97,7 @@ namespace storm { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
|
DFTExplorationHeuristicNone(size_t id, DFTExplorationHeuristicNone<ValueType> const& predecessor, ValueType rate, ValueType exitRate) : DFTExplorationHeuristic<ValueType>(id, predecessor, rate, exitRate) { |
|
|
|
DFTExplorationHeuristicNone(size_t id, DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate) : DFTExplorationHeuristic<ValueType>(id, predecessor, rate, exitRate) { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
@ -91,10 +112,6 @@ namespace storm { |
|
|
|
bool isSkip(double) const override { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
bool operator<(DFTExplorationHeuristicNone<ValueType> const& other) const { |
|
|
|
return this->id > other.id; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
@ -104,7 +121,7 @@ namespace storm { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
|
DFTExplorationHeuristicDepth(size_t id, DFTExplorationHeuristicDepth<ValueType> const& predecessor, ValueType rate, ValueType exitRate) : DFTExplorationHeuristic<ValueType>(id, predecessor, rate, exitRate) { |
|
|
|
DFTExplorationHeuristicDepth(size_t id, DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate) : DFTExplorationHeuristic<ValueType>(id, predecessor, rate, exitRate) { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
@ -116,17 +133,16 @@ namespace storm { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double getPriority() const override { |
|
|
|
return this->depth; |
|
|
|
} |
|
|
|
|
|
|
|
bool isSkip(double approximationThreshold) const override { |
|
|
|
return !this->expand && this->depth > approximationThreshold; |
|
|
|
return !this->expand && this->getPriority() > approximationThreshold; |
|
|
|
} |
|
|
|
|
|
|
|
bool operator<(DFTExplorationHeuristicDepth<ValueType> const& other) const { |
|
|
|
return this->depth > other.depth; |
|
|
|
bool operator<(DFTExplorationHeuristic<ValueType> const& other) const override { |
|
|
|
return this->getPriority() > other.getPriority(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@ -137,21 +153,11 @@ namespace storm { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
|
DFTExplorationHeuristicProbability(size_t id, DFTExplorationHeuristicProbability<ValueType> const& predecessor, ValueType rate, ValueType exitRate) : DFTExplorationHeuristic<ValueType>(id, predecessor, rate, exitRate) { |
|
|
|
DFTExplorationHeuristicProbability(size_t id, DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate) : DFTExplorationHeuristic<ValueType>(id, predecessor, rate, exitRate) { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
|
bool updateHeuristicValues(DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate) override; |
|
|
|
|
|
|
|
double getPriority() const override; |
|
|
|
|
|
|
|
bool isSkip(double approximationThreshold) const override { |
|
|
|
return !this->expand && this->getPriority() < approximationThreshold; |
|
|
|
} |
|
|
|
|
|
|
|
bool operator<(DFTExplorationHeuristicProbability<ValueType> const& other) const { |
|
|
|
return this->getPriority() < other.getPriority(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
@ -161,28 +167,12 @@ namespace storm { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
|
DFTExplorationHeuristicBoundDifference(size_t id, DFTExplorationHeuristicBoundDifference<ValueType> const& predecessor, ValueType rate, ValueType exitRate) : DFTExplorationHeuristic<ValueType>(id, predecessor, rate, exitRate) { |
|
|
|
DFTExplorationHeuristicBoundDifference(size_t id, DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate) : DFTExplorationHeuristic<ValueType>(id, predecessor, rate, exitRate) { |
|
|
|
// Intentionally left empty |
|
|
|
} |
|
|
|
|
|
|
|
void setBounds(ValueType lowerBound, ValueType upperBound); |
|
|
|
|
|
|
|
bool updateHeuristicValues(DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate) override; |
|
|
|
|
|
|
|
double getPriority() const override; |
|
|
|
|
|
|
|
bool isSkip(double approximationThreshold) const override { |
|
|
|
return !this->expand && this->getPriority() < approximationThreshold; |
|
|
|
} |
|
|
|
|
|
|
|
bool operator<(DFTExplorationHeuristicBoundDifference<ValueType> const& other) const { |
|
|
|
return this->getPriority() < other.getPriority(); |
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
ValueType difference; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |