Browse Source

bug fixes for pla

tempestpy_adaptions
TimQu 8 years ago
parent
commit
b1786d9822
  1. 2
      src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp
  2. 3
      src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp
  3. 16
      src/storm/modelchecker/parametric/SparseMdpParameterLiftingModelChecker.cpp
  4. 6
      src/storm/transformer/GoalStateMerger.cpp

2
src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp

@ -19,6 +19,7 @@ namespace storm {
std::unique_ptr<CheckResult> SparseDtmcInstantiationModelChecker<SparseModelType, ConstantType>::check(storm::utility::parametric::Valuation<typename SparseModelType::ValueType> const& valuation) {
STORM_LOG_THROW(this->currentCheckTask, storm::exceptions::InvalidStateException, "Checking has been invoked but no property has been specified before.");
auto const& instantiatedModel = modelInstantiator.instantiate(valuation);
STORM_LOG_ASSERT(instantiatedModel.getTransitionMatrix().isProbabilistic(), "Instantiated matrix is not probabilistic!");
storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<ConstantType>> modelChecker(instantiatedModel);
// Check if there are some optimizations implemented for the specified property
@ -28,7 +29,6 @@ namespace storm {
return modelChecker.check(*this->currentCheckTask);
}
}
template <typename SparseModelType, typename ConstantType>
std::unique_ptr<CheckResult> SparseDtmcInstantiationModelChecker<SparseModelType, ConstantType>::checkWithHint(storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<ConstantType>>& modelchecker) {

3
src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp

@ -20,6 +20,7 @@ namespace storm {
std::unique_ptr<CheckResult> SparseMdpInstantiationModelChecker<SparseModelType, ConstantType>::check(storm::utility::parametric::Valuation<typename SparseModelType::ValueType> const& valuation) {
STORM_LOG_THROW(this->currentCheckTask, storm::exceptions::InvalidStateException, "Checking has been invoked but no property has been specified before.");
auto const& instantiatedModel = modelInstantiator.instantiate(valuation);
STORM_LOG_ASSERT(instantiatedModel.getTransitionMatrix().isProbabilistic(), "Instantiated matrix is not probabilistic!");
storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<ConstantType>> modelChecker(instantiatedModel);
// Check if there are some optimizations implemented for the specified property
@ -57,7 +58,7 @@ namespace storm {
std::unique_ptr<storm::modelchecker::CheckResult> qualitativeResult = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(), this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
storm::storage::Scheduler& scheduler = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getScheduler();
this->currentCheckTask->setHint(ExplicitModelCheckerHint<ConstantType>(std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()),
std::move(dynamic_cast<storm::storage::TotalScheduler const&>(scheduler))));
std::move(dynamic_cast<storm::storage::TotalScheduler&>(scheduler))));
return qualitativeResult;
}
}

16
src/storm/modelchecker/parametric/SparseMdpParameterLiftingModelChecker.cpp

@ -101,7 +101,7 @@ namespace storm {
// if there are maybestates, create the parameterLifter
if (!maybeStates.empty()) {
// Create the vector of one-step probabilities to go to target states.
std::vector<typename SparseModelType::ValueType> b = this->parametricModel.getTransitionMatrix().getConstrainedRowSumVector(storm::storage::BitVector(this->parametricModel.getTransitionMatrix().getRowCount(), true), psiStates);
std::vector<typename SparseModelType::ValueType> b = this->parametricModel.getTransitionMatrix().getConstrainedRowSumVector(storm::storage::BitVector(this->parametricModel.getTransitionMatrix().getRowCount(), true), statesWithProbability01.second);
parameterLifter = std::make_unique<storm::transformer::ParameterLifter<typename SparseModelType::ValueType, ConstantType>>(this->parametricModel.getTransitionMatrix(), b, this->parametricModel.getTransitionMatrix().getRowIndicesOfRowGroups(maybeStates), maybeStates);
computePlayer1Matrix();
@ -204,10 +204,10 @@ namespace storm {
// Set up the solver
auto solver = solverFactory->create(player1Matrix, parameterLifter->getMatrix());
solver->setTrackScheduler(true);
if(lowerResultBound) solver->setLowerBound(lowerResultBound.get());
if(upperResultBound) solver->setUpperBound(upperResultBound.get());
if(applyPreviousResultAsHint) {
solver->setTrackScheduler(true);
x.resize(maybeStates.getNumberOfSetBits(), storm::utility::zero<ConstantType>());
if(storm::solver::minimize(dirForParameters) && minSched && player1Sched) solver->setSchedulerHint(std::move(player1Sched.get()), std::move(minSched.get()));
if(storm::solver::maximize(dirForParameters) && maxSched && player1Sched) solver->setSchedulerHint(std::move(player1Sched.get()), std::move(maxSched.get()));
@ -221,12 +221,14 @@ namespace storm {
solver->repeatedMultiply(this->currentCheckTask->getOptimizationDirection(), dirForParameters, x, &parameterLifter->getVector(), *stepBound);
} else {
solver->solveGame(this->currentCheckTask->getOptimizationDirection(), dirForParameters, x, parameterLifter->getVector());
if(storm::solver::minimize(dirForParameters)) {
minSched = solver->getPlayer2Scheduler();
} else {
maxSched = solver->getPlayer2Scheduler();
if(applyPreviousResultAsHint) {
if(storm::solver::minimize(dirForParameters)) {
minSched = solver->getPlayer2Scheduler();
} else {
maxSched = solver->getPlayer2Scheduler();
}
player1Sched = solver->getPlayer1Scheduler();
}
player1Sched = solver->getPlayer1Scheduler();
}
// Get the result for the complete model (including maybestates)

6
src/storm/transformer/GoalStateMerger.cpp

@ -77,9 +77,9 @@ namespace storm {
bool sinkStateRequired = !originalModel.getInitialStates().isDisjointFrom(sinkStates);
for( auto state : maybeStates) {
resNumActions += origMatrix.getRowGroupSize(state);
bool hasTransitionToTarget(false), hasTransitionToSink(false);
auto const& endOfRowGroup = origMatrix.getRowGroupIndices()[state+1];
for (uint_fast64_t row = origMatrix.getRowGroupIndices()[state]; row < endOfRowGroup; ++row) {
bool hasTransitionToTarget(false), hasTransitionToSink(false);
for (auto const& entry : origMatrix.getRow(row)) {
if(maybeStates.get(entry.getColumn())) {
++resNumTransitions;
@ -120,8 +120,6 @@ namespace storm {
}
template <typename SparseModelType>
storm::storage::SparseMatrix<typename SparseModelType::ValueType> GoalStateMerger<SparseModelType>::buildTransitionMatrix(storm::storage::BitVector const& maybeStates, storm::storage::BitVector const& targetStates, storm::storage::BitVector const& sinkStates, boost::optional<uint_fast64_t> const& newTargetState, boost::optional<uint_fast64_t>const& newSinkState, storm::storage::SparseMatrixBuilder<typename SparseModelType::ValueType>& builder) {
@ -138,9 +136,9 @@ namespace storm {
uint_fast64_t currRow = 0;
for (auto state : maybeStates) {
builder.newRowGroup(currRow);
boost::optional<typename SparseModelType::ValueType> targetProbability, sinkProbability;
auto const& endOfRowGroup = origMatrix.getRowGroupIndices()[state+1];
for (uint_fast64_t row = origMatrix.getRowGroupIndices()[state]; row < endOfRowGroup; ++row) {
boost::optional<typename SparseModelType::ValueType> targetProbability, sinkProbability;
for (auto const& entry : origMatrix.getRow(row)) {
if(maybeStates.get(entry.getColumn())) {
builder.addNextValue(currRow, oldToNewIndexMap[entry.getColumn()], entry.getValue());

Loading…
Cancel
Save