Browse Source

Merge branch 'master' into SmtSolvers

Former-commit-id: 7a70be824a
tempestpy_adaptions
dehnert 10 years ago
parent
commit
0f4b19ffc9
  1. 9
      src/models/AtomicPropositionsLabeling.h
  2. 41
      src/storage/DeterministicModelBisimulationDecomposition.cpp

9
src/models/AtomicPropositionsLabeling.h

@ -209,9 +209,14 @@ public:
* @return True if the node is labeled with the atomic proposition, false otherwise. * @return True if the node is labeled with the atomic proposition, false otherwise.
*/ */
bool getStateHasAtomicProposition(std::string const& ap, const uint_fast64_t state) const { bool getStateHasAtomicProposition(std::string const& ap, const uint_fast64_t state) const {
if (ap == "true") {
return true;
} else if (ap == "false") {
return false;
}
if (!this->containsAtomicProposition(ap)) { if (!this->containsAtomicProposition(ap)) {
LOG4CPLUS_ERROR(logger, "The atomic proposition " << ap << " is invalid for the labeling of the model.");
throw storm::exceptions::InvalidArgumentException() << "The atomic proposition " << ap << " is invalid for the labeling of the model.";
LOG4CPLUS_ERROR(logger, "The atomic proposition '" << ap << "' is invalid for the labeling of the model.");
throw storm::exceptions::InvalidArgumentException() << "The atomic proposition '" << ap << "' is invalid for the labeling of the model.";
} }
auto apIndexPair = nameToLabelingMap.find(ap); auto apIndexPair = nameToLabelingMap.find(ap);
return this->singleLabelings[apIndexPair->second].get(state); return this->singleLabelings[apIndexPair->second].get(state);

41
src/storage/DeterministicModelBisimulationDecomposition.cpp

@ -262,42 +262,51 @@ namespace storm {
template<typename ValueType> template<typename ValueType>
DeterministicModelBisimulationDecomposition<ValueType>::Partition::Partition(std::size_t numberOfStates, storm::storage::BitVector const& prob0States, storm::storage::BitVector const& prob1States, std::string const& otherLabel, std::string const& prob1Label, bool keepSilentProbabilities) : numberOfBlocks(0), stateToBlockMapping(numberOfStates), statesAndValues(numberOfStates), positions(numberOfStates), keepSilentProbabilities(keepSilentProbabilities), silentProbabilities() { DeterministicModelBisimulationDecomposition<ValueType>::Partition::Partition(std::size_t numberOfStates, storm::storage::BitVector const& prob0States, storm::storage::BitVector const& prob1States, std::string const& otherLabel, std::string const& prob1Label, bool keepSilentProbabilities) : numberOfBlocks(0), stateToBlockMapping(numberOfStates), statesAndValues(numberOfStates), positions(numberOfStates), keepSilentProbabilities(keepSilentProbabilities), silentProbabilities() {
storm::storage::sparse::state_type position = 0;
Block* firstBlock = nullptr;
Block* secondBlock = nullptr;
Block* thirdBlock = nullptr;
if (!prob0States.empty()) {
typename std::list<Block>::iterator firstIt = blocks.emplace(this->blocks.end(), 0, prob0States.getNumberOfSetBits(), nullptr, nullptr, numberOfBlocks++); typename std::list<Block>::iterator firstIt = blocks.emplace(this->blocks.end(), 0, prob0States.getNumberOfSetBits(), nullptr, nullptr, numberOfBlocks++);
Block& firstBlock = *firstIt;
firstBlock.setIterator(firstIt);
firstBlock = &(*firstIt);
firstBlock->setIterator(firstIt);
storm::storage::sparse::state_type position = 0;
for (auto state : prob0States) { for (auto state : prob0States) {
statesAndValues[position] = std::make_pair(state, storm::utility::zero<ValueType>()); statesAndValues[position] = std::make_pair(state, storm::utility::zero<ValueType>());
positions[state] = position; positions[state] = position;
stateToBlockMapping[state] = &firstBlock;
stateToBlockMapping[state] = firstBlock;
++position; ++position;
} }
firstBlock.setAbsorbing(true);
firstBlock->setAbsorbing(true);
}
typename std::list<Block>::iterator secondIt = blocks.emplace(this->blocks.end(), position, position + prob1States.getNumberOfSetBits(), &firstBlock, nullptr, numberOfBlocks++, std::shared_ptr<std::string>(new std::string(prob1Label)));
Block& secondBlock = *secondIt;
secondBlock.setIterator(secondIt);
if (!prob1States.empty()) {
typename std::list<Block>::iterator secondIt = blocks.emplace(this->blocks.end(), position, position + prob1States.getNumberOfSetBits(), firstBlock, nullptr, numberOfBlocks++, std::shared_ptr<std::string>(new std::string(prob1Label)));
secondBlock = &(*secondIt);
secondBlock->setIterator(secondIt);
for (auto state : prob1States) { for (auto state : prob1States) {
statesAndValues[position] = std::make_pair(state, storm::utility::zero<ValueType>()); statesAndValues[position] = std::make_pair(state, storm::utility::zero<ValueType>());
positions[state] = position; positions[state] = position;
stateToBlockMapping[state] = &secondBlock;
stateToBlockMapping[state] = secondBlock;
++position; ++position;
} }
secondBlock.setAbsorbing(true);
typename std::list<Block>::iterator thirdIt = blocks.emplace(this->blocks.end(), position, numberOfStates, &secondBlock, nullptr, numberOfBlocks++, otherLabel == "true" ? std::shared_ptr<std::string>(nullptr) : std::shared_ptr<std::string>(new std::string(otherLabel)));
Block& thirdBlock = *thirdIt;
thirdBlock.setIterator(thirdIt);
secondBlock->setAbsorbing(true);
}
storm::storage::BitVector otherStates = ~(prob0States | prob1States); storm::storage::BitVector otherStates = ~(prob0States | prob1States);
if (!otherStates.empty()) {
typename std::list<Block>::iterator thirdIt = blocks.emplace(this->blocks.end(), position, numberOfStates, secondBlock, nullptr, numberOfBlocks++, otherLabel == "true" ? std::shared_ptr<std::string>(nullptr) : std::shared_ptr<std::string>(new std::string(otherLabel)));
thirdBlock = &(*thirdIt);
thirdBlock->setIterator(thirdIt);
for (auto state : otherStates) { for (auto state : otherStates) {
statesAndValues[position] = std::make_pair(state, storm::utility::zero<ValueType>()); statesAndValues[position] = std::make_pair(state, storm::utility::zero<ValueType>());
positions[state] = position; positions[state] = position;
stateToBlockMapping[state] = &thirdBlock;
stateToBlockMapping[state] = thirdBlock;
++position; ++position;
} }
}
// If we are requested to store silent probabilities, we need to prepare the vector. // If we are requested to store silent probabilities, we need to prepare the vector.
if (this->keepSilentProbabilities) { if (this->keepSilentProbabilities) {
@ -1198,7 +1207,7 @@ namespace storm {
template<typename ModelType> template<typename ModelType>
typename DeterministicModelBisimulationDecomposition<ValueType>::Partition DeterministicModelBisimulationDecomposition<ValueType>::getMeasureDrivenInitialPartition(ModelType const& model, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::string const& phiLabel, std::string const& psiLabel, BisimulationType bisimulationType, bool keepRewards, bool bounded) { typename DeterministicModelBisimulationDecomposition<ValueType>::Partition DeterministicModelBisimulationDecomposition<ValueType>::getMeasureDrivenInitialPartition(ModelType const& model, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::string const& phiLabel, std::string const& psiLabel, BisimulationType bisimulationType, bool keepRewards, bool bounded) {
std::pair<storm::storage::BitVector, storm::storage::BitVector> statesWithProbability01 = storm::utility::graph::performProb01(backwardTransitions, phiLabel == "true" ? storm::storage::BitVector(model.getNumberOfStates(), true) : model.getLabeledStates(phiLabel), model.getLabeledStates(psiLabel)); std::pair<storm::storage::BitVector, storm::storage::BitVector> statesWithProbability01 = storm::utility::graph::performProb01(backwardTransitions, phiLabel == "true" ? storm::storage::BitVector(model.getNumberOfStates(), true) : model.getLabeledStates(phiLabel), model.getLabeledStates(psiLabel));
Partition partition(model.getNumberOfStates(), statesWithProbability01.first, bounded ? model.getLabeledStates(psiLabel) : statesWithProbability01.second, phiLabel, psiLabel, bisimulationType == BisimulationType::WeakDtmc);
Partition partition(model.getNumberOfStates(), statesWithProbability01.first, bounded || keepRewards ? model.getLabeledStates(psiLabel) : statesWithProbability01.second, phiLabel, psiLabel, bisimulationType == BisimulationType::WeakDtmc);
// If the model has state rewards, we need to consider them, because otherwise reward properties are not // If the model has state rewards, we need to consider them, because otherwise reward properties are not
// preserved. // preserved.

Loading…
Cancel
Save