Browse Source

formulae with rational number bounds

Former-commit-id: 17755ccf84
tempestpy_adaptions
sjunges 8 years ago
parent
commit
cf583ec9dd
  1. 2
      src/counterexamples/MILPMinimalLabelSetGenerator.h
  2. 2
      src/counterexamples/SMTMinimalCommandSetGenerator.h
  3. 6
      src/logic/Bound.h
  4. 10
      src/logic/OperatorFormula.cpp
  5. 19
      src/logic/OperatorFormula.h
  6. 2
      src/modelchecker/AbstractModelChecker.cpp
  7. 6
      src/modelchecker/CheckTask.h
  8. 2
      src/parser/FormulaParser.cpp
  9. 4
      src/permissivesched/PermissiveSchedulers.cpp

2
src/counterexamples/MILPMinimalLabelSetGenerator.h

@ -985,7 +985,7 @@ namespace storm {
STORM_LOG_THROW(probabilityOperator.getSubformula().isUntilFormula() || probabilityOperator.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Path formula is required to be of the form 'phi U psi' for counterexample generation."); STORM_LOG_THROW(probabilityOperator.getSubformula().isUntilFormula() || probabilityOperator.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Path formula is required to be of the form 'phi U psi' for counterexample generation.");
bool strictBound = comparisonType == storm::logic::ComparisonType::Less; bool strictBound = comparisonType == storm::logic::ComparisonType::Less;
double threshold = probabilityOperator.getThreshold();
double threshold = probabilityOperator.getThresholdAs<double>();
storm::storage::BitVector phiStates; storm::storage::BitVector phiStates;
storm::storage::BitVector psiStates; storm::storage::BitVector psiStates;

2
src/counterexamples/SMTMinimalCommandSetGenerator.h

@ -1762,7 +1762,7 @@ namespace storm {
STORM_LOG_THROW(probabilityOperator.getSubformula().isUntilFormula() || probabilityOperator.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Path formula is required to be of the form 'phi U psi' for counterexample generation."); STORM_LOG_THROW(probabilityOperator.getSubformula().isUntilFormula() || probabilityOperator.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Path formula is required to be of the form 'phi U psi' for counterexample generation.");
bool strictBound = comparisonType == storm::logic::ComparisonType::Less; bool strictBound = comparisonType == storm::logic::ComparisonType::Less;
double threshold = probabilityOperator.getThreshold();
double threshold = probabilityOperator.getThresholdAs<double>();
storm::storage::BitVector phiStates; storm::storage::BitVector phiStates;
storm::storage::BitVector psiStates; storm::storage::BitVector psiStates;

6
src/logic/Bound.h

@ -2,6 +2,7 @@
#define STORM_LOGIC_BOUND_H_ #define STORM_LOGIC_BOUND_H_
#include "src/logic/ComparisonType.h" #include "src/logic/ComparisonType.h"
#include "src/utility/constants.h"
namespace storm { namespace storm {
namespace logic { namespace logic {
@ -11,6 +12,11 @@ namespace storm {
// Intentionally left empty. // Intentionally left empty.
} }
template<typename OtherValueType>
Bound<OtherValueType> convertToOtherValueType() const {
return Bound<OtherValueType>(comparisonType, storm::utility::convertNumber<OtherValueType>(threshold));
}
ComparisonType comparisonType; ComparisonType comparisonType;
ValueType threshold; ValueType threshold;

10
src/logic/OperatorFormula.cpp

@ -2,7 +2,7 @@
namespace storm { namespace storm {
namespace logic { namespace logic {
OperatorInformation::OperatorInformation(boost::optional<storm::solver::OptimizationDirection> const& optimizationDirection, boost::optional<Bound<double>> const& bound) : optimalityType(optimizationDirection), bound(bound) {
OperatorInformation::OperatorInformation(boost::optional<storm::solver::OptimizationDirection> const& optimizationDirection, boost::optional<Bound<RationalNumber>> const& bound) : optimalityType(optimizationDirection), bound(bound) {
// Intentionally left empty. // Intentionally left empty.
} }
@ -22,19 +22,19 @@ namespace storm {
operatorInformation.bound.get().comparisonType = newComparisonType; operatorInformation.bound.get().comparisonType = newComparisonType;
} }
double OperatorFormula::getThreshold() const {
RationalNumber const& OperatorFormula::getThreshold() const {
return operatorInformation.bound.get().threshold; return operatorInformation.bound.get().threshold;
} }
void OperatorFormula::setThreshold(double newThreshold) {
void OperatorFormula::setThreshold(RationalNumber const& newThreshold) {
operatorInformation.bound.get().threshold = newThreshold; operatorInformation.bound.get().threshold = newThreshold;
} }
Bound<double> const& OperatorFormula::getBound() const {
Bound<RationalNumber> const& OperatorFormula::getBound() const {
return operatorInformation.bound.get(); return operatorInformation.bound.get();
} }
void OperatorFormula::setBound(Bound<double> const& newBound) {
void OperatorFormula::setBound(Bound<RationalNumber> const& newBound) {
operatorInformation.bound = newBound; operatorInformation.bound = newBound;
} }

19
src/logic/OperatorFormula.h

@ -7,13 +7,16 @@
#include "src/logic/Bound.h" #include "src/logic/Bound.h"
#include "src/solver/OptimizationDirection.h" #include "src/solver/OptimizationDirection.h"
#include "src/adapters/CarlAdapter.h"
#include "src/utility/constants.h"
namespace storm { namespace storm {
namespace logic { namespace logic {
struct OperatorInformation { struct OperatorInformation {
OperatorInformation(boost::optional<storm::solver::OptimizationDirection> const& optimizationDirection = boost::none, boost::optional<Bound<double>> const& bound = boost::none);
OperatorInformation(boost::optional<storm::solver::OptimizationDirection> const& optimizationDirection = boost::none, boost::optional<Bound<RationalNumber>> const& bound = boost::none);
boost::optional<storm::solver::OptimizationDirection> optimalityType; boost::optional<storm::solver::OptimizationDirection> optimalityType;
boost::optional<Bound<double>> bound;
boost::optional<Bound<RationalNumber>> bound;
}; };
class OperatorFormula : public UnaryStateFormula { class OperatorFormula : public UnaryStateFormula {
@ -28,10 +31,14 @@ namespace storm {
bool hasBound() const; bool hasBound() const;
ComparisonType getComparisonType() const; ComparisonType getComparisonType() const;
void setComparisonType(ComparisonType newComparisonType); void setComparisonType(ComparisonType newComparisonType);
double getThreshold() const;
void setThreshold(double newThreshold);
Bound<double> const& getBound() const;
void setBound(Bound<double> const& newBound);
RationalNumber const& getThreshold() const;
template<typename ValueType=RationalNumber>
ValueType getThresholdAs() const {
return storm::utility::convertNumber<ValueType>(this->getThreshold());
}
void setThreshold(RationalNumber const& newThreshold);
Bound<RationalNumber> const& getBound() const;
void setBound(Bound<RationalNumber> const& newBound);
// Optimality-type-related accessors. // Optimality-type-related accessors.
bool hasOptimalityType() const; bool hasOptimalityType() const;

2
src/modelchecker/AbstractModelChecker.cpp

@ -183,7 +183,7 @@ namespace storm {
if (stateFormula.hasBound()) { if (stateFormula.hasBound()) {
STORM_LOG_THROW(result->isQuantitative(), storm::exceptions::InvalidOperationException, "Unable to perform comparison operation on non-quantitative result."); STORM_LOG_THROW(result->isQuantitative(), storm::exceptions::InvalidOperationException, "Unable to perform comparison operation on non-quantitative result.");
return result->asQuantitativeCheckResult().compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getThreshold());
return result->asQuantitativeCheckResult().compareAgainstBound(stateFormula.getComparisonType(), stateFormula.getThresholdAs<double>());
} else { } else {
return result; return result;
} }

6
src/modelchecker/CheckTask.h

@ -45,7 +45,7 @@ namespace storm {
if (operatorFormula.hasBound()) { if (operatorFormula.hasBound()) {
if (onlyInitialStatesRelevant) { if (onlyInitialStatesRelevant) {
this->bound = operatorFormula.getBound();
this->bound = operatorFormula.getBound().convertToOtherValueType<ValueType>();
} }
if (!optimizationDirection) { if (!optimizationDirection) {
@ -58,7 +58,7 @@ namespace storm {
storm::logic::ProbabilityOperatorFormula const& probabilityOperatorFormula = formula.asProbabilityOperatorFormula(); storm::logic::ProbabilityOperatorFormula const& probabilityOperatorFormula = formula.asProbabilityOperatorFormula();
if (probabilityOperatorFormula.hasBound()) { if (probabilityOperatorFormula.hasBound()) {
if (probabilityOperatorFormula.getThreshold() == storm::utility::zero<ValueType>() || probabilityOperatorFormula.getThreshold() == storm::utility::one<ValueType>()) {
if (storm::utility::isZero(probabilityOperatorFormula.getThreshold()) || storm::utility::isOne(probabilityOperatorFormula.getThreshold())) {
this->qualitative = true; this->qualitative = true;
} }
} }
@ -67,7 +67,7 @@ namespace storm {
this->rewardModel = rewardOperatorFormula.getOptionalRewardModelName(); this->rewardModel = rewardOperatorFormula.getOptionalRewardModelName();
if (rewardOperatorFormula.hasBound()) { if (rewardOperatorFormula.hasBound()) {
if (rewardOperatorFormula.getThreshold() == storm::utility::zero<ValueType>()) {
if (storm::utility::isZero(rewardOperatorFormula.getThreshold())) {
this->qualitative = true; this->qualitative = true;
} }
} }

2
src/parser/FormulaParser.cpp

@ -478,7 +478,7 @@ namespace storm {
storm::logic::OperatorInformation FormulaParserGrammar::createOperatorInformation(boost::optional<storm::OptimizationDirection> const& optimizationDirection, boost::optional<storm::logic::ComparisonType> const& comparisonType, boost::optional<double> const& threshold) const { storm::logic::OperatorInformation FormulaParserGrammar::createOperatorInformation(boost::optional<storm::OptimizationDirection> const& optimizationDirection, boost::optional<storm::logic::ComparisonType> const& comparisonType, boost::optional<double> const& threshold) const {
if (comparisonType && threshold) { if (comparisonType && threshold) {
return storm::logic::OperatorInformation(optimizationDirection, storm::logic::Bound<double>(comparisonType.get(), threshold.get()));
return storm::logic::OperatorInformation(optimizationDirection, storm::logic::Bound<RationalNumber>(comparisonType.get(), storm::utility::convertNumber<RationalNumber>(threshold.get())));
} else { } else {
return storm::logic::OperatorInformation(optimizationDirection, boost::none); return storm::logic::OperatorInformation(optimizationDirection, boost::none);
} }

4
src/permissivesched/PermissiveSchedulers.cpp

@ -26,7 +26,7 @@ namespace storm {
auto solver = storm::utility::solver::getLpSolver("Gurobi", storm::solver::LpSolverTypeSelection::Gurobi); auto solver = storm::utility::solver::getLpSolver("Gurobi", storm::solver::LpSolverTypeSelection::Gurobi);
MilpPermissiveSchedulerComputation<storm::models::sparse::StandardRewardModel<double>> comp(*solver, mdp, goalstates, sinkstates); MilpPermissiveSchedulerComputation<storm::models::sparse::StandardRewardModel<double>> comp(*solver, mdp, goalstates, sinkstates);
STORM_LOG_THROW(!storm::logic::isStrict(safeProp.getComparisonType()), storm::exceptions::NotImplementedException, "Strict bounds are not supported"); STORM_LOG_THROW(!storm::logic::isStrict(safeProp.getComparisonType()), storm::exceptions::NotImplementedException, "Strict bounds are not supported");
comp.calculatePermissiveScheduler(storm::logic::isLowerBound(safeProp.getComparisonType()), safeProp.getBound().threshold);
comp.calculatePermissiveScheduler(storm::logic::isLowerBound(safeProp.getComparisonType()), safeProp.getThresholdAs<double>());
//comp.dumpLpToFile("milpdump.lp"); //comp.dumpLpToFile("milpdump.lp");
std::cout << "Found Solution: " << (comp.foundSolution() ? "yes" : "no") << std::endl; std::cout << "Found Solution: " << (comp.foundSolution() ? "yes" : "no") << std::endl;
if(comp.foundSolution()) { if(comp.foundSolution()) {
@ -54,7 +54,7 @@ namespace storm {
auto solver = storm::utility::solver::getSmtSolver(*expressionManager); auto solver = storm::utility::solver::getSmtSolver(*expressionManager);
SmtPermissiveSchedulerComputation<storm::models::sparse::StandardRewardModel<double>> comp(*solver, mdp, goalstates, sinkstates); SmtPermissiveSchedulerComputation<storm::models::sparse::StandardRewardModel<double>> comp(*solver, mdp, goalstates, sinkstates);
STORM_LOG_THROW(!storm::logic::isStrict(safeProp.getComparisonType()), storm::exceptions::NotImplementedException, "Strict bounds are not supported"); STORM_LOG_THROW(!storm::logic::isStrict(safeProp.getComparisonType()), storm::exceptions::NotImplementedException, "Strict bounds are not supported");
comp.calculatePermissiveScheduler(storm::logic::isLowerBound(safeProp.getComparisonType()), safeProp.getBound().threshold);
comp.calculatePermissiveScheduler(storm::logic::isLowerBound(safeProp.getComparisonType()), safeProp.getThresholdAs<double>());
if(comp.foundSolution()) { if(comp.foundSolution()) {
return boost::optional<SubMDPPermissiveScheduler<RM>>(comp.getScheduler()); return boost::optional<SubMDPPermissiveScheduler<RM>>(comp.getScheduler());
} else { } else {

Loading…
Cancel
Save