Browse Source

Conditional probabilities work for brp model from the paper by Baier et al.

Former-commit-id: 02858bf34d
tempestpy_adaptions
dehnert 10 years ago
parent
commit
e51c3b9f44
  1. 4
      examples/pdtmc/brp/brp_128-2.pm
  2. 4
      examples/pdtmc/brp/brp_128-3.pm
  3. 4
      examples/pdtmc/brp/brp_128-4.pm
  4. 4
      examples/pdtmc/brp/brp_128-5.pm
  5. 4
      examples/pdtmc/brp/brp_16_2.pm
  6. 4
      examples/pdtmc/brp/brp_256-2.pm
  7. 4
      examples/pdtmc/brp/brp_256-3.pm
  8. 4
      examples/pdtmc/brp/brp_256-4.pm
  9. 4
      examples/pdtmc/brp/brp_256-5.pm
  10. 4
      examples/pdtmc/brp/brp_32-4.pm
  11. 4
      examples/pdtmc/brp/brp_64-4.pm
  12. 4
      examples/pdtmc/brp/brp_64-5.pm
  13. 125
      src/modelchecker/reachability/SparseSccModelChecker.cpp
  14. 2
      src/modelchecker/reachability/SparseSccModelChecker.h
  15. 199
      src/stormParametric.cpp

4
examples/pdtmc/brp/brp_128-2.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s = 5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_128-3.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s = 5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_128-4.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s = 5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_128-5.pm

@ -135,4 +135,6 @@ module channelL
endmodule
label "target" = s = 5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_16_2.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s=5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_256-2.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s = 5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_256-3.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s = 5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_256-4.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s = 5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_256-5.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s = 5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_32-4.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s=5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_64-4.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s=5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

4
examples/pdtmc/brp/brp_64-5.pm

@ -134,4 +134,6 @@ module channelL
endmodule
label "target" = s=5;
label "target" = s=5;
label "finished_with_success" = srep=3&rrep=3;
label "two_fragments_transmitted" = s=1&i=2+1;

125
src/modelchecker/reachability/SparseSccModelChecker.cpp

@ -265,8 +265,8 @@ namespace storm {
// Determine the set of initial states of the sub-DTMC.
storm::storage::BitVector newInitialStates = dtmc.getInitialStates() % maybeStates;
// Create a vector for the probabilities to go to a state with probability 1 in one step.
std::vector<ValueType> oneStepProbabilities = dtmc.getTransitionMatrix().getConstrainedRowSumVector(maybeStates, statesWithProbability1);
// Create a dummy vector for the one-step probabilities.
std::vector<ValueType> oneStepProbabilities(maybeStates.getNumberOfSetBits(), storm::utility::zero<ValueType>());
// We then build the submatrix that only has the transitions of the maybe states.
storm::storage::SparseMatrix<ValueType> submatrix = dtmc.getTransitionMatrix().getSubmatrix(false, maybeStates, maybeStates);
@ -303,70 +303,59 @@ namespace storm {
}
STORM_PRINT_AND_LOG("Eliminated " << states.size() << " states." << std::endl);
flexibleMatrix.print();
// FIXME: Eliminate backward transitions to initial state.
// At this point, the initial state has one of the following three scenarios:
// (a) only phi successors
// (b) only psi successors
// (c) phi and psi successors
//
// Case (a): ???
// Case (b): then we can add the probability of all transitions emanating from the initial state (=: p)
// and then use the regular scheme to compute the probability to reach a phi state (=: q) and then
// compute the result to be q/p.
// Case (c):
// Find first occurring representatives.
bool foundPhiRepresentative = false;
storm::storage::sparse::state_type phiRepresentative;
bool foundPsiRepresentative = false;
storm::storage::sparse::state_type psiRepresentative;
for (auto initialState : newInitialStates) {
for (auto const& trans : flexibleMatrix.getRow(initialState)) {
if (!foundPhiRepresentative && phiStates.get(trans.getColumn())) {
foundPhiRepresentative = true;
phiRepresentative = trans.getColumn();
STORM_LOG_DEBUG("Found phi representative " << phiRepresentative);
} else if (!foundPsiRepresentative && psiStates.get(trans.getColumn())) {
foundPsiRepresentative = true;
psiRepresentative = trans.getColumn();
STORM_LOG_DEBUG("Found psi representative " << phiRepresentative);
eliminateState(flexibleMatrix, oneStepProbabilities, *newInitialStates.begin(), flexibleBackwardTransitions, missingStateRewards, false);
// Now eliminate all chains of phi or psi states.
for (auto phiState : phiStates) {
// Only eliminate the state if it has a successor that is not itself.
auto const& currentRow = flexibleMatrix.getRow(phiState);
if (currentRow.size() == 1) {
auto const& firstEntry = currentRow.front();
if (firstEntry.getColumn() == phiState) {
break;
}
if (foundPhiRepresentative && foundPsiRepresentative) {
}
eliminateState(flexibleMatrix, oneStepProbabilities, phiState, flexibleBackwardTransitions, missingStateRewards, false, true, phiStates);
}
for (auto psiState : psiStates) {
// Only eliminate the state if it has a successor that is not itself.
auto const& currentRow = flexibleMatrix.getRow(psiState);
if (currentRow.size() == 1) {
auto const& firstEntry = currentRow.front();
if (firstEntry.getColumn() == psiState) {
break;
}
}
eliminateState(flexibleMatrix, oneStepProbabilities, psiState, flexibleBackwardTransitions, missingStateRewards, false, true, psiStates);
}
STORM_LOG_THROW(foundPhiRepresentative, storm::exceptions::InvalidStateException, "Found no phi representative.");
STORM_LOG_THROW(foundPsiRepresentative, storm::exceptions::InvalidStateException, "Found no psi representative.");
// Redirect all transitions to the phi states to their representative and do the same for the psi states.
for (auto state : maybeStates) {
std::map<storm::storage::sparse::state_type, ValueType> newSuccessors;
for (auto const& trans : submatrix.getRow(state)) {
if (phiStates.get(trans.getColumn())) {
newSuccessors[phiRepresentative] += trans.getValue();
} else if (psiStates.get(trans.getColumn())) {
newSuccessors[psiRepresentative] += trans.getValue();
} else {
newSuccessors[trans.getColumn()] += trans.getValue();
ValueType numerator = storm::utility::zero<ValueType>();
ValueType denominator = storm::utility::zero<ValueType>();
for (auto const& trans1 : flexibleMatrix.getRow(*newInitialStates.begin())) {
auto initialStateSuccessor = trans1.getColumn();
if (phiStates.get(initialStateSuccessor)) {
ValueType additiveTerm = storm::utility::zero<ValueType>();
for (auto const& trans2 : flexibleMatrix.getRow(initialStateSuccessor)) {
STORM_LOG_ASSERT(psiStates.get(trans2.getColumn()), "Expected psi state.");
additiveTerm += trans2.getValue();
}
additiveTerm *= trans1.getValue();
numerator += additiveTerm;
denominator += additiveTerm;
} else {
STORM_LOG_ASSERT(psiStates.get(initialStateSuccessor), "Expected psi state.");
denominator += trans1.getValue();
ValueType additiveTerm = storm::utility::zero<ValueType>();
for (auto const& trans2 : flexibleMatrix.getRow(initialStateSuccessor)) {
STORM_LOG_ASSERT(phiStates.get(trans2.getColumn()), "Expected phi state.");
additiveTerm += trans2.getValue();
}
numerator += trans1.getValue() * additiveTerm;
}
std::vector<storm::storage::MatrixEntry<storm::storage::sparse::state_type, ValueType>> newTransitions;
for (auto const& stateValuePair : newSuccessors) {
newTransitions.emplace_back(stateValuePair);
}
flexibleMatrix.getRow(state) = newTransitions;
}
flexibleMatrix.print();
return storm::utility::zero<ValueType>();
return numerator / denominator;
}
template<typename ValueType>
@ -533,7 +522,7 @@ namespace storm {
}
template<typename ValueType>
void SparseSccModelChecker<ValueType>::eliminateState(FlexibleSparseMatrix<ValueType>& matrix, std::vector<ValueType>& oneStepProbabilities, uint_fast64_t state, FlexibleSparseMatrix<ValueType>& backwardTransitions, boost::optional<std::vector<ValueType>>& stateRewards) {
void SparseSccModelChecker<ValueType>::eliminateState(FlexibleSparseMatrix<ValueType>& matrix, std::vector<ValueType>& oneStepProbabilities, uint_fast64_t state, FlexibleSparseMatrix<ValueType>& backwardTransitions, boost::optional<std::vector<ValueType>>& stateRewards, bool removeForwardTransitions, bool constrained, storm::storage::BitVector const& predecessorConstraint) {
auto eliminationStart = std::chrono::high_resolution_clock::now();
++counter;
@ -591,6 +580,11 @@ namespace storm {
continue;
}
// Skip the state if the elimination is constrained, but the predecessor is not in the constraint.
if (constrained && !predecessorConstraint.get(predecessor)) {
continue;
}
// First, find the probability with which the predecessor can move to the current state, because
// the other probabilities need to be scaled with this factor.
typename FlexibleSparseMatrix<ValueType>::row_type& predecessorForwardTransitions = matrix.getRow(predecessor);
@ -713,11 +707,18 @@ namespace storm {
}
STORM_LOG_DEBUG("Fixed predecessor lists of successor states.");
// Clear the eliminated row to reduce memory consumption.
currentStateSuccessors.clear();
currentStateSuccessors.shrink_to_fit();
currentStatePredecessors.clear();
currentStatePredecessors.shrink_to_fit();
if (removeForwardTransitions) {
// Clear the eliminated row to reduce memory consumption.
currentStateSuccessors.clear();
currentStateSuccessors.shrink_to_fit();
}
if (!constrained) {
// FIXME: is this safe? If the elimination is constrained, we might have to repair the predecessor
// relation.
currentStatePredecessors.clear();
currentStatePredecessors.shrink_to_fit();
}
auto eliminationEnd = std::chrono::high_resolution_clock::now();
auto eliminationTime = eliminationEnd - eliminationStart;

2
src/modelchecker/reachability/SparseSccModelChecker.h

@ -49,7 +49,7 @@ namespace storm {
static FlexibleSparseMatrix<ValueType> getFlexibleSparseMatrix(storm::storage::SparseMatrix<ValueType> const& matrix, bool setAllValuesToOne = false);
static void eliminateState(FlexibleSparseMatrix<ValueType>& matrix, std::vector<ValueType>& oneStepProbabilities, uint_fast64_t state, FlexibleSparseMatrix<ValueType>& backwardTransitions, boost::optional<std::vector<ValueType>>& stateRewards);
static void eliminateState(FlexibleSparseMatrix<ValueType>& matrix, std::vector<ValueType>& oneStepProbabilities, uint_fast64_t state, FlexibleSparseMatrix<ValueType>& backwardTransitions, boost::optional<std::vector<ValueType>>& stateRewards, bool removeForwardTransitions = true, bool constrained = false, storm::storage::BitVector const& predecessorConstraint = storm::storage::BitVector());
static std::vector<std::size_t> getStatePriorities(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<ValueType> const& oneStepProbabilities);
};

199
src/stormParametric.cpp

@ -123,6 +123,100 @@
// return std::make_tuple(modelchecker.computeReachabilityProbability(submatrix, oneStepProbabilities, submatrix.transpose(), newInitialStates, phiStates, psiStates, distances),submatrix, oneStepProbabilities, newInitialStates, threshold, strict);
//}
template<typename ValueType>
void printApproximateResult(ValueType const& value) {
// Intentionally left empty.
}
template<>
void printApproximateResult(storm::RationalFunction const& value) {
if (value.isConstant()) {
STORM_PRINT_AND_LOG(" (approximately " << std::setprecision(30) << carl::toDouble(value.constantPart()) << ")" << std::endl);
}
}
template<typename ValueType>
void check() {
// From this point on we are ready to carry out the actual computations.
// Program Translation Time Measurement, Start
std::chrono::high_resolution_clock::time_point programTranslationStart = std::chrono::high_resolution_clock::now();
// First, we build the model using the given symbolic model description and constant definitions.
std::string const& programFile = storm::settings::generalSettings().getSymbolicModelFilename();
std::string const& constants = storm::settings::generalSettings().getConstantDefinitionString();
storm::prism::Program program = storm::parser::PrismParser::parse(programFile);
std::shared_ptr<storm::models::AbstractModel<ValueType>> model = storm::builder::ExplicitPrismModelBuilder<ValueType>::translateProgram(program, true, false, storm::settings::generalSettings().isSymbolicRewardModelNameSet() ? storm::settings::generalSettings().getSymbolicRewardModelName() : "", constants);
model->printModelInformationToStream(std::cout);
// Program Translation Time Measurement, End
std::chrono::high_resolution_clock::time_point programTranslationEnd = std::chrono::high_resolution_clock::now();
std::cout << "Parsing and translating the model took " << std::chrono::duration_cast<std::chrono::milliseconds>(programTranslationEnd - programTranslationStart).count() << "ms." << std::endl << std::endl;
std::shared_ptr<storm::models::Dtmc<ValueType>> dtmc = model->template as<storm::models::Dtmc<ValueType>>();
STORM_LOG_THROW(storm::settings::generalSettings().isPctlPropertySet(), storm::exceptions::InvalidSettingsException, "Unable to perform model checking without a property.");
std::shared_ptr<storm::properties::prctl::PrctlFilter<double>> filterFormula = storm::parser::PrctlParser::parsePrctlFormula(storm::settings::generalSettings().getPctlProperty());
std::cout << "Checking formula " << *filterFormula << std::endl;
bool checkRewards = false;
std::shared_ptr<storm::properties::prctl::Ap<double>> phiStateFormulaApFormula = nullptr;
std::shared_ptr<storm::properties::prctl::Ap<double>> psiStateFormulaApFormula = nullptr;
// The first thing we need to do is to make sure the formula is of the correct form.
std::shared_ptr<storm::properties::prctl::Until<double>> untilFormula = std::dynamic_pointer_cast<storm::properties::prctl::Until<double>>(filterFormula->getChild());
std::shared_ptr<storm::properties::prctl::AbstractStateFormula<double>> phiStateFormula;
std::shared_ptr<storm::properties::prctl::AbstractStateFormula<double>> psiStateFormula;
if (untilFormula) {
phiStateFormula = untilFormula->getLeft();
psiStateFormula = untilFormula->getRight();
} else {
std::shared_ptr<storm::properties::prctl::Eventually<double>> eventuallyFormula = std::dynamic_pointer_cast<storm::properties::prctl::Eventually<double>>(filterFormula->getChild());
if (eventuallyFormula) {
phiStateFormula = std::shared_ptr<storm::properties::prctl::Ap<double>>(new storm::properties::prctl::Ap<double>("true"));
psiStateFormula = eventuallyFormula->getChild();
} else {
std::shared_ptr<storm::properties::prctl::ReachabilityReward<double>> reachabilityRewardFormula = std::dynamic_pointer_cast<storm::properties::prctl::ReachabilityReward<double>>(filterFormula->getChild());
STORM_LOG_THROW(reachabilityRewardFormula, storm::exceptions::InvalidPropertyException, "Illegal formula " << *filterFormula << " for parametric model checking. Note that only unbounded reachability properties (probabilities/rewards) are admitted.");
phiStateFormula = std::shared_ptr<storm::properties::prctl::Ap<double>>(new storm::properties::prctl::Ap<double>("true"));
psiStateFormula = reachabilityRewardFormula->getChild();
checkRewards = true;
}
}
// Now we need to make sure the formulas defining the phi and psi states are just labels.
phiStateFormulaApFormula = std::dynamic_pointer_cast<storm::properties::prctl::Ap<double>>(phiStateFormula);
psiStateFormulaApFormula = std::dynamic_pointer_cast<storm::properties::prctl::Ap<double>>(psiStateFormula);
STORM_LOG_THROW(phiStateFormulaApFormula, storm::exceptions::InvalidPropertyException, "Illegal formula " << *phiStateFormula << " for parametric model checking. Note that only atomic propositions are admitted in that position.");
STORM_LOG_THROW(psiStateFormulaApFormula, storm::exceptions::InvalidPropertyException, "Illegal formula " << *psiStateFormula << " for parametric model checking. Note that only atomic propositions are admitted in that position.");
// Perform bisimulation minimization if requested.
if (storm::settings::generalSettings().isBisimulationSet()) {
storm::storage::DeterministicModelBisimulationDecomposition<ValueType> bisimulationDecomposition(*dtmc, phiStateFormulaApFormula->getAp(), psiStateFormulaApFormula->getAp(), checkRewards, storm::settings::bisimulationSettings().isWeakBisimulationSet(), false, true);
dtmc = bisimulationDecomposition.getQuotient()->template as<storm::models::Dtmc<ValueType>>();
dtmc->printModelInformationToStream(std::cout);
}
assert(dtmc);
// storm::modelchecker::reachability::CollectConstraints<ValueType> constraintCollector;
// constraintCollector(*dtmc);
storm::modelchecker::reachability::SparseSccModelChecker<ValueType> modelchecker;
ValueType valueFunction = modelchecker.computeConditionalProbability(*dtmc, phiStateFormulaApFormula, psiStateFormulaApFormula);
// storm::RationalFunction valueFunction = checkRewards ? modelchecker.computeReachabilityReward(*dtmc, phiStateFormulaApFormula, psiStateFormulaApFormula) : modelchecker.computeReachabilityProbability(*dtmc, phiStateFormulaApFormula, psiStateFormulaApFormula);
STORM_PRINT_AND_LOG(std::endl << "Result: " << valueFunction << std::endl);
if (std::is_same<ValueType, storm::RationalFunction>::value) {
printApproximateResult(valueFunction);
}
}
/*!
* Main entry point of the executable storm.
*/
@ -135,84 +229,8 @@ int main(const int argc, const char** argv) {
return -1;
}
// From this point on we are ready to carry out the actual computations.
// Program Translation Time Measurement, Start
std::chrono::high_resolution_clock::time_point programTranslationStart = std::chrono::high_resolution_clock::now();
// First, we build the model using the given symbolic model description and constant definitions.
std::string const& programFile = storm::settings::generalSettings().getSymbolicModelFilename();
std::string const& constants = storm::settings::generalSettings().getConstantDefinitionString();
storm::prism::Program program = storm::parser::PrismParser::parse(programFile);
std::shared_ptr<storm::models::AbstractModel<storm::RationalFunction>> model = storm::builder::ExplicitPrismModelBuilder<storm::RationalFunction>::translateProgram(program, true, false, storm::settings::generalSettings().isSymbolicRewardModelNameSet() ? storm::settings::generalSettings().getSymbolicRewardModelName() : "", constants);
model->printModelInformationToStream(std::cout);
// Program Translation Time Measurement, End
std::chrono::high_resolution_clock::time_point programTranslationEnd = std::chrono::high_resolution_clock::now();
std::cout << "Parsing and translating the model took " << std::chrono::duration_cast<std::chrono::milliseconds>(programTranslationEnd - programTranslationStart).count() << "ms." << std::endl << std::endl;
std::shared_ptr<storm::models::Dtmc<storm::RationalFunction>> dtmc = model->as<storm::models::Dtmc<storm::RationalFunction>>();
STORM_LOG_THROW(storm::settings::generalSettings().isPctlPropertySet(), storm::exceptions::InvalidSettingsException, "Unable to perform model checking without a property.");
std::shared_ptr<storm::properties::prctl::PrctlFilter<double>> filterFormula = storm::parser::PrctlParser::parsePrctlFormula(storm::settings::generalSettings().getPctlProperty());
std::cout << "Checking formula " << *filterFormula << std::endl;
bool checkRewards = false;
std::shared_ptr<storm::properties::prctl::Ap<double>> phiStateFormulaApFormula = nullptr;
std::shared_ptr<storm::properties::prctl::Ap<double>> psiStateFormulaApFormula = nullptr;
// The first thing we need to do is to make sure the formula is of the correct form.
std::shared_ptr<storm::properties::prctl::Until<double>> untilFormula = std::dynamic_pointer_cast<storm::properties::prctl::Until<double>>(filterFormula->getChild());
std::shared_ptr<storm::properties::prctl::AbstractStateFormula<double>> phiStateFormula;
std::shared_ptr<storm::properties::prctl::AbstractStateFormula<double>> psiStateFormula;
if (untilFormula) {
phiStateFormula = untilFormula->getLeft();
psiStateFormula = untilFormula->getRight();
} else {
std::shared_ptr<storm::properties::prctl::Eventually<double>> eventuallyFormula = std::dynamic_pointer_cast<storm::properties::prctl::Eventually<double>>(filterFormula->getChild());
if (eventuallyFormula) {
phiStateFormula = std::shared_ptr<storm::properties::prctl::Ap<double>>(new storm::properties::prctl::Ap<double>("true"));
psiStateFormula = eventuallyFormula->getChild();
} else {
std::shared_ptr<storm::properties::prctl::ReachabilityReward<double>> reachabilityRewardFormula = std::dynamic_pointer_cast<storm::properties::prctl::ReachabilityReward<double>>(filterFormula->getChild());
STORM_LOG_THROW(reachabilityRewardFormula, storm::exceptions::InvalidPropertyException, "Illegal formula " << *filterFormula << " for parametric model checking. Note that only unbounded reachability properties (probabilities/rewards) are admitted.");
phiStateFormula = std::shared_ptr<storm::properties::prctl::Ap<double>>(new storm::properties::prctl::Ap<double>("true"));
psiStateFormula = reachabilityRewardFormula->getChild();
checkRewards = true;
}
}
// Now we need to make sure the formulas defining the phi and psi states are just labels.
phiStateFormulaApFormula = std::dynamic_pointer_cast<storm::properties::prctl::Ap<double>>(phiStateFormula);
psiStateFormulaApFormula = std::dynamic_pointer_cast<storm::properties::prctl::Ap<double>>(psiStateFormula);
STORM_LOG_THROW(phiStateFormulaApFormula, storm::exceptions::InvalidPropertyException, "Illegal formula " << *phiStateFormula << " for parametric model checking. Note that only atomic propositions are admitted in that position.");
STORM_LOG_THROW(psiStateFormulaApFormula, storm::exceptions::InvalidPropertyException, "Illegal formula " << *psiStateFormula << " for parametric model checking. Note that only atomic propositions are admitted in that position.");
// Perform bisimulation minimization if requested.
if (storm::settings::generalSettings().isBisimulationSet()) {
storm::storage::DeterministicModelBisimulationDecomposition<storm::RationalFunction> bisimulationDecomposition(*dtmc, phiStateFormulaApFormula->getAp(), psiStateFormulaApFormula->getAp(), checkRewards, storm::settings::bisimulationSettings().isWeakBisimulationSet(), false, true);
dtmc = bisimulationDecomposition.getQuotient()->as<storm::models::Dtmc<storm::RationalFunction>>();
dtmc->printModelInformationToStream(std::cout);
}
assert(dtmc);
storm::modelchecker::reachability::CollectConstraints<storm::RationalFunction> constraintCollector;
constraintCollector(*dtmc);
storm::modelchecker::reachability::SparseSccModelChecker<storm::RationalFunction> modelchecker;
check<storm::RationalFunction>();
storm::RationalFunction valueFunction = modelchecker.computeConditionalProbability(*dtmc, phiStateFormulaApFormula, psiStateFormulaApFormula);
// storm::RationalFunction valueFunction = checkRewards ? modelchecker.computeReachabilityReward(*dtmc, phiStateFormulaApFormula, psiStateFormulaApFormula) : modelchecker.computeReachabilityProbability(*dtmc, phiStateFormulaApFormula, psiStateFormulaApFormula);
// STORM_PRINT_AND_LOG(std::endl << "Result: (" << carl::computePolynomial(valueFunction.nominator()) << ") / (" << carl::computePolynomial(valueFunction.denominator()) << ")" << std::endl);
// STORM_PRINT_AND_LOG(std::endl << "Result: (" << valueFunction.nominator() << ") / (" << valueFunction.denominator() << ")" << std::endl);
STORM_PRINT_AND_LOG(std::endl << "Result: " << valueFunction << std::endl);
// // Perform bisimulation minimization if requested.
// if (storm::settings::generalSettings().isBisimulationSet()) {
// storm::storage::DeterministicModelStrongBisimulationDecomposition<storm::RationalFunction> bisimulationDecomposition(*dtmc, true);
@ -228,22 +246,23 @@ int main(const int argc, const char** argv) {
// STORM_PRINT_AND_LOG(std::endl << "difference: " << diff << std::endl);
// Get variables from parameter definitions in prism program.
std::set<storm::Variable> parameters;
for(auto constant : program.getConstants())
{
if(!constant.isDefined())
{
carl::Variable p = carl::VariablePool::getInstance().findVariableWithName(constant.getName());
assert(p != storm::Variable::NO_VARIABLE);
parameters.insert(p);
}
}
// std::set<storm::Variable> parameters;
// for(auto constant : program.getConstants())
// {
// if(!constant.isDefined())
// {
// std::cout << "got undef constant " << constant.getName() << std::endl;
// carl::Variable p = carl::VariablePool::getInstance().findVariableWithName(constant.getName());
// assert(p != storm::Variable::NO_VARIABLE);
// parameters.insert(p);
// }
// }
// STORM_LOG_ASSERT(parameters == valueFunction.gatherVariables(), "Parameters in result and program definition do not coincide.");
if(storm::settings::parametricSettings().exportResultToFile()) {
storm::utility::exportParametricMcResult(valueFunction, constraintCollector);
}
// if(storm::settings::parametricSettings().exportResultToFile()) {
// storm::utility::exportParametricMcResult(valueFunction, constraintCollector);
// }
// if (storm::settings::parametricSettings().exportToSmt2File() && std::get<1>(result) && std::get<2>(result) && std::get<3>(result) && std::get<4>(result) && std::get<5>(result)) {
// storm::modelchecker::reachability::DirectEncoding dec;

Loading…
Cancel
Save