Browse Source

small fix regarding the return type of computeValue

Former-commit-id: 78b43e0f6d
tempestpy_adaptions
TimQu 9 years ago
parent
commit
77e086f446
  1. 15
      src/modelchecker/region/AbstractSparseRegionModelChecker.cpp
  2. 4
      src/modelchecker/region/ApproximationModel.cpp
  3. 3
      src/modelchecker/region/ApproximationModel.h
  4. 8
      src/modelchecker/region/SamplingModel.cpp
  5. 3
      src/modelchecker/region/SamplingModel.h

15
src/modelchecker/region/AbstractSparseRegionModelChecker.cpp

@ -9,6 +9,7 @@
#include "src/adapters/CarlAdapter.h" #include "src/adapters/CarlAdapter.h"
#include "src/modelchecker/region/RegionCheckResult.h" #include "src/modelchecker/region/RegionCheckResult.h"
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
#include "src/logic/Formulas.h" #include "src/logic/Formulas.h"
#include "src/models/sparse/StandardRewardModel.h" #include "src/models/sparse/StandardRewardModel.h"
#include "src/settings/SettingsManager.h" #include "src/settings/SettingsManager.h"
@ -24,6 +25,8 @@
#include "src/exceptions/NotImplementedException.h" #include "src/exceptions/NotImplementedException.h"
#include "src/exceptions/UnexpectedException.h" #include "src/exceptions/UnexpectedException.h"
#include "utility/ConversionHelper.h" #include "utility/ConversionHelper.h"
#include "modelchecker/results/CheckResult.h"
#include "modelchecker/results/ExplicitQuantitativeCheckResult.h"
namespace storm { namespace storm {
namespace modelchecker { namespace modelchecker {
@ -138,7 +141,7 @@ namespace storm {
initializeSamplingModel(*this->getSimpleModel(), this->getSimpleFormula()); initializeSamplingModel(*this->getSimpleModel(), this->getSimpleFormula());
std::map<VariableType, CoefficientType> emptySubstitution; std::map<VariableType, CoefficientType> emptySubstitution;
this->getSamplingModel()->instantiate(emptySubstitution); this->getSamplingModel()->instantiate(emptySubstitution);
this->constantResult = this->getSamplingModel()->computeValues()[*this->getSamplingModel()->getModel()->getInitialStates().begin()];
this->constantResult = this->getSamplingModel()->computeValues()->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()[*this->getSamplingModel()->getModel()->getInitialStates().begin()];
} }
//some more information for statistics... //some more information for statistics...
@ -317,13 +320,13 @@ namespace storm {
bool formulaSatisfied; bool formulaSatisfied;
if((this->specifiedFormulaHasUpperBound() && proveAllSat) || (!this->specifiedFormulaHasUpperBound() && !proveAllSat)){ if((this->specifiedFormulaHasUpperBound() && proveAllSat) || (!this->specifiedFormulaHasUpperBound() && !proveAllSat)){
//these are the cases in which we need to compute upper bounds //these are the cases in which we need to compute upper bounds
upperBounds = this->getApproximationModel()->computeValues(storm::solver::OptimizationDirection::Maximize);
upperBounds = this->getApproximationModel()->computeValues(storm::solver::OptimizationDirection::Maximize)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
lowerBounds = std::vector<ConstantType>(); lowerBounds = std::vector<ConstantType>();
formulaSatisfied = this->valueIsInBoundOfFormula(upperBounds[*this->getApproximationModel()->getModel()->getInitialStates().begin()]); formulaSatisfied = this->valueIsInBoundOfFormula(upperBounds[*this->getApproximationModel()->getModel()->getInitialStates().begin()]);
} }
else{ else{
//for the remaining cases we compute lower bounds //for the remaining cases we compute lower bounds
lowerBounds = this->getApproximationModel()->computeValues(storm::solver::OptimizationDirection::Minimize);
lowerBounds = this->getApproximationModel()->computeValues(storm::solver::OptimizationDirection::Minimize)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
upperBounds = std::vector<ConstantType>(); upperBounds = std::vector<ConstantType>();
formulaSatisfied = this->valueIsInBoundOfFormula(lowerBounds[*this->getApproximationModel()->getModel()->getInitialStates().begin()]); formulaSatisfied = this->valueIsInBoundOfFormula(lowerBounds[*this->getApproximationModel()->getModel()->getInitialStates().begin()]);
} }
@ -343,11 +346,11 @@ namespace storm {
proveAllSat=!proveAllSat; proveAllSat=!proveAllSat;
if(lowerBounds.empty()){ if(lowerBounds.empty()){
lowerBounds = this->getApproximationModel()->computeValues(storm::solver::OptimizationDirection::Minimize);
lowerBounds = this->getApproximationModel()->computeValues(storm::solver::OptimizationDirection::Minimize)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
formulaSatisfied=this->valueIsInBoundOfFormula(lowerBounds[*this->getApproximationModel()->getModel()->getInitialStates().begin()]); formulaSatisfied=this->valueIsInBoundOfFormula(lowerBounds[*this->getApproximationModel()->getModel()->getInitialStates().begin()]);
} }
else{ else{
upperBounds = this->getApproximationModel()->computeValues(storm::solver::OptimizationDirection::Maximize);
upperBounds = this->getApproximationModel()->computeValues(storm::solver::OptimizationDirection::Maximize)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
formulaSatisfied=this->valueIsInBoundOfFormula(upperBounds[*this->getApproximationModel()->getModel()->getInitialStates().begin()]); formulaSatisfied=this->valueIsInBoundOfFormula(upperBounds[*this->getApproximationModel()->getModel()->getInitialStates().begin()]);
} }
@ -391,7 +394,7 @@ namespace storm {
return this->constantResult.get(); return this->constantResult.get();
} }
this->getSamplingModel()->instantiate(point); this->getSamplingModel()->instantiate(point);
return this->getSamplingModel()->computeValues()[*this->getSamplingModel()->getModel()->getInitialStates().begin()];
return this->getSamplingModel()->computeValues()->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()[*this->getSamplingModel()->getModel()->getInitialStates().begin()];
} }
template<typename ParametricSparseModelType, typename ConstantType> template<typename ParametricSparseModelType, typename ConstantType>

4
src/modelchecker/region/ApproximationModel.cpp

@ -343,7 +343,7 @@ namespace storm {
} }
template<typename ParametricSparseModelType, typename ConstantType> template<typename ParametricSparseModelType, typename ConstantType>
std::vector<ConstantType> const& ApproximationModel<ParametricSparseModelType, ConstantType>::computeValues(storm::solver::OptimizationDirection const& approximationOpDir) {
std::unique_ptr<storm::modelchecker::CheckResult> ApproximationModel<ParametricSparseModelType, ConstantType>::computeValues(storm::solver::OptimizationDirection const& approximationOpDir) {
std::unique_ptr<storm::modelchecker::AbstractModelChecker> modelChecker; std::unique_ptr<storm::modelchecker::AbstractModelChecker> modelChecker;
switch(this->getModel()->getType()){ switch(this->getModel()->getType()){
case storm::models::ModelType::Mdp: case storm::models::ModelType::Mdp:
@ -384,7 +384,7 @@ namespace storm {
//perform model checking //perform model checking
resultPtr = modelChecker->computeEventuallyProbabilities(this->formula->asProbabilityOperatorFormula().getSubformula().asEventuallyFormula(), false, approximationOpDir); resultPtr = modelChecker->computeEventuallyProbabilities(this->formula->asProbabilityOperatorFormula().getSubformula().asEventuallyFormula(), false, approximationOpDir);
} }
return resultPtr->asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
return resultPtr;
} }

3
src/modelchecker/region/ApproximationModel.h

@ -13,6 +13,7 @@
#include "src/utility/region.h" #include "src/utility/region.h"
#include "src/modelchecker/region/ParameterRegion.h" #include "src/modelchecker/region/ParameterRegion.h"
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
#include "src/logic/Formulas.h" #include "src/logic/Formulas.h"
#include "src/models/sparse/Model.h" #include "src/models/sparse/Model.h"
#include "src/storage/SparseMatrix.h" #include "src/storage/SparseMatrix.h"
@ -49,7 +50,7 @@ namespace storm {
* Undefined behavior if model has not been instantiated first! * Undefined behavior if model has not been instantiated first!
* @param approximationOpDir Use MAXIMIZE to get upper bounds or MINIMIZE to get lower bounds * @param approximationOpDir Use MAXIMIZE to get upper bounds or MINIMIZE to get lower bounds
*/ */
std::vector<ConstantType> const& computeValues(storm::solver::OptimizationDirection const& approximationOpDir);
std::unique_ptr<storm::modelchecker::CheckResult> computeValues(storm::solver::OptimizationDirection const& approximationOpDir);
private: private:

8
src/modelchecker/region/SamplingModel.cpp

@ -13,7 +13,6 @@
#include "models/sparse/StandardRewardModel.h" #include "models/sparse/StandardRewardModel.h"
#include "src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h" #include "src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
#include "src/modelchecker/prctl/SparseMdpPrctlModelChecker.h" #include "src/modelchecker/prctl/SparseMdpPrctlModelChecker.h"
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
#include "src/utility/macros.h" #include "src/utility/macros.h"
#include "src/utility/region.h" #include "src/utility/region.h"
#include "src/utility/vector.h" #include "src/utility/vector.h"
@ -185,7 +184,7 @@ namespace storm {
} }
template<typename ParametricSparseModelType, typename ConstantType> template<typename ParametricSparseModelType, typename ConstantType>
std::vector<ConstantType> const& SamplingModel<ParametricSparseModelType, ConstantType>::computeValues() {
std::unique_ptr<storm::modelchecker::CheckResult> SamplingModel<ParametricSparseModelType, ConstantType>::computeValues() {
std::unique_ptr<storm::modelchecker::AbstractModelChecker> modelChecker; std::unique_ptr<storm::modelchecker::AbstractModelChecker> modelChecker;
switch(this->getModel()->getType()){ switch(this->getModel()->getType()){
case storm::models::ModelType::Dtmc: case storm::models::ModelType::Dtmc:
@ -204,9 +203,10 @@ namespace storm {
resultPtr = modelChecker->computeReachabilityRewards(this->formula->asRewardOperatorFormula().getSubformula().asReachabilityRewardFormula()); resultPtr = modelChecker->computeReachabilityRewards(this->formula->asRewardOperatorFormula().getSubformula().asReachabilityRewardFormula());
} }
else { else {
resultPtr = modelChecker->computeEventuallyProbabilities(this->formula->asProbabilityOperatorFormula().getSubformula().asEventuallyFormula(), false, opDir);
storm::logic::UntilFormula newFormula(storm::logic::Formula::getTrueFormula(), this->formula->asProbabilityOperatorFormula().getSubformula().asEventuallyFormula().getSubformula().asSharedPointer());
resultPtr = modelChecker->computeUntilProbabilities(newFormula, false, opDir);
} }
return resultPtr->asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
return resultPtr;
} }
#ifdef STORM_HAVE_CARL #ifdef STORM_HAVE_CARL

3
src/modelchecker/region/SamplingModel.h

@ -14,6 +14,7 @@
#include "src/utility/region.h" #include "src/utility/region.h"
#include "src/logic/Formulas.h" #include "src/logic/Formulas.h"
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
#include "src/models/sparse/Model.h" #include "src/models/sparse/Model.h"
#include "src/storage/SparseMatrix.h" #include "src/storage/SparseMatrix.h"
@ -47,7 +48,7 @@ namespace storm {
* Returns the reachability probabilities (or the expected rewards) for every state according to the current instantiation. * Returns the reachability probabilities (or the expected rewards) for every state according to the current instantiation.
* Undefined behavior if model has not been instantiated first! * Undefined behavior if model has not been instantiated first!
*/ */
std::vector<ConstantType> const& computeValues();
std::unique_ptr<storm::modelchecker::CheckResult> computeValues();
private: private:

Loading…
Cancel
Save