You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.8 KiB
72 lines
2.8 KiB
#include "storm/logic/InstantaneousRewardFormula.h"
|
|
|
|
#include "storm/logic/FormulaVisitor.h"
|
|
|
|
#include "storm/utility/macros.h"
|
|
#include "storm/exceptions/InvalidPropertyException.h"
|
|
#include "storm/exceptions/InvalidOperationException.h"
|
|
|
|
namespace storm {
|
|
namespace logic {
|
|
InstantaneousRewardFormula::InstantaneousRewardFormula(storm::expressions::Expression const& bound, TimeBoundType const& timeBoundType) : timeBoundType(timeBoundType), bound(bound) {
|
|
// Intentionally left empty.
|
|
}
|
|
|
|
bool InstantaneousRewardFormula::isInstantaneousRewardFormula() const {
|
|
return true;
|
|
}
|
|
|
|
bool InstantaneousRewardFormula::isRewardPathFormula() const {
|
|
return true;
|
|
}
|
|
|
|
boost::any InstantaneousRewardFormula::accept(FormulaVisitor const& visitor, boost::any const& data) const {
|
|
return visitor.visit(*this, data);
|
|
}
|
|
|
|
TimeBoundType const& InstantaneousRewardFormula::getTimeBoundType() const {
|
|
return timeBoundType;
|
|
}
|
|
|
|
bool InstantaneousRewardFormula::isStepBounded() const {
|
|
return timeBoundType == TimeBoundType::Steps;
|
|
}
|
|
|
|
bool InstantaneousRewardFormula::isTimeBounded() const {
|
|
return timeBoundType == TimeBoundType::Time;
|
|
}
|
|
|
|
bool InstantaneousRewardFormula::hasIntegerBound() const {
|
|
return bound.hasIntegerType();
|
|
}
|
|
|
|
storm::expressions::Expression const& InstantaneousRewardFormula::getBound() const {
|
|
return bound;
|
|
}
|
|
|
|
template <>
|
|
double InstantaneousRewardFormula::getBound() const {
|
|
checkNoVariablesInBound(bound);
|
|
double value = bound.evaluateAsDouble();
|
|
STORM_LOG_THROW(value >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number.");
|
|
return value;
|
|
}
|
|
|
|
template <>
|
|
uint64_t InstantaneousRewardFormula::getBound() const {
|
|
checkNoVariablesInBound(bound);
|
|
uint64_t value = bound.evaluateAsInt();
|
|
STORM_LOG_THROW(value >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number.");
|
|
return value;
|
|
}
|
|
|
|
void InstantaneousRewardFormula::checkNoVariablesInBound(storm::expressions::Expression const& bound) {
|
|
STORM_LOG_THROW(!bound.containsVariables(), storm::exceptions::InvalidOperationException, "Cannot evaluate time-instant '" << bound << "' as it contains undefined constants.");
|
|
}
|
|
|
|
std::ostream& InstantaneousRewardFormula::writeToStream(std::ostream& out) const {
|
|
out << "I=" << this->getBound();
|
|
return out;
|
|
}
|
|
}
|
|
}
|