|
|
@ -15,6 +15,13 @@ namespace storm { |
|
|
|
// Intentionally left empty
|
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
void DFTExplorationHeuristic<ValueType>::setHeuristicValues(size_t depth, ValueType rate, ValueType exitRate) { |
|
|
|
this->depth = std::min(this->depth, depth); |
|
|
|
this->rate = std::max(this->rate, rate); |
|
|
|
this->exitRate = std::max(this->exitRate, exitRate); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
bool DFTExplorationHeuristic<ValueType>::isSkip(double approximationThreshold, ApproximationHeuristic heuristic) const { |
|
|
|
if (!skip) { |
|
|
@ -26,8 +33,9 @@ namespace storm { |
|
|
|
case ApproximationHeuristic::DEPTH: |
|
|
|
return depth > approximationThreshold; |
|
|
|
case ApproximationHeuristic::RATERATIO: |
|
|
|
// TODO Matthias: implement
|
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Heuristic rate ration does not work."); |
|
|
|
return getRateRatio() < approximationThreshold; |
|
|
|
default: |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Heuristic not known."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -36,52 +44,41 @@ namespace storm { |
|
|
|
skip = false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
size_t DFTExplorationHeuristic<ValueType>::getDepth() const { |
|
|
|
return depth; |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
void DFTExplorationHeuristic<ValueType>::setHeuristicValues(size_t depth, ValueType rate, ValueType exitRate) { |
|
|
|
this->depth = depth; |
|
|
|
this->rate = rate; |
|
|
|
this->exitRate = exitRate; |
|
|
|
bool DFTExplorationHeuristic<ValueType>::compare(DFTExplorationHeuristic<ValueType> other, ApproximationHeuristic heuristic) { |
|
|
|
switch (heuristic) { |
|
|
|
case ApproximationHeuristic::NONE: |
|
|
|
// Just use memory address for comparing
|
|
|
|
// TODO Matthias: better idea?
|
|
|
|
return this > &other; |
|
|
|
case ApproximationHeuristic::DEPTH: |
|
|
|
return this->depth > other.depth; |
|
|
|
case ApproximationHeuristic::RATERATIO: |
|
|
|
return this->getRateRatio() < other.getRateRatio(); |
|
|
|
default: |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Heuristic not known."); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
double DFTExplorationHeuristic<ValueType>::getPriority() const { |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Approximation works only for double."); |
|
|
|
} |
|
|
|
|
|
|
|
template<> |
|
|
|
double DFTExplorationHeuristic<double>::getPriority() const { |
|
|
|
// TODO Matthias: change according to heuristic
|
|
|
|
//return rate/exitRate;
|
|
|
|
return depth; |
|
|
|
double DFTExplorationHeuristic<double>::getRateRatio() const { |
|
|
|
return rate/exitRate; |
|
|
|
} |
|
|
|
|
|
|
|
template<> |
|
|
|
double DFTExplorationHeuristic<storm::RationalFunction>::getPriority() const { |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Approximation works only for double."); |
|
|
|
/*std::cout << (rate / exitRate) << " < " << threshold << ": " << (number < threshold) << std::endl;
|
|
|
|
std::map<storm::Variable, storm::RationalNumber> mapping; |
|
|
|
storm::RationalFunction eval(number.evaluate(mapping)); |
|
|
|
std::cout << "Evaluated: " << eval << std::endl; |
|
|
|
return eval < threshold;*/ |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
bool compareDepth(std::shared_ptr<storm::storage::DFTState<ValueType>> stateA, std::shared_ptr<storm::storage::DFTState<ValueType>> stateB) { |
|
|
|
return stateA->getPriority() > stateB->getPriority(); |
|
|
|
double DFTExplorationHeuristic<storm::RationalFunction>::getRateRatio() const { |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Heuristic rate ration does not work."); |
|
|
|
} |
|
|
|
|
|
|
|
template class DFTExplorationHeuristic<double>; |
|
|
|
template bool compareDepth(std::shared_ptr<storm::storage::DFTState<double>>, std::shared_ptr<storm::storage::DFTState<double>>); |
|
|
|
|
|
|
|
#ifdef STORM_HAVE_CARL
|
|
|
|
template class DFTExplorationHeuristic<storm::RationalFunction>; |
|
|
|
template bool compareDepth(std::shared_ptr<storm::storage::DFTState<storm::RationalFunction>>, std::shared_ptr<storm::storage::DFTState<storm::RationalFunction>>); |
|
|
|
#endif
|
|
|
|
} |
|
|
|
} |