Browse Source

small fix for building MAs

Also fixed a test for explicit MA parsing, where the transitions of a probabilistic choice did not sum up to one


Former-commit-id: c2f920a4d6
tempestpy_adaptions
TimQu 9 years ago
parent
commit
12287e5090
  1. 6
      src/builder/ExplicitModelBuilder.cpp
  2. 11
      src/models/sparse/MarkovAutomaton.cpp
  3. 6
      src/models/sparse/MarkovAutomaton.h
  4. 3
      src/storage/BitVector.cpp

6
src/builder/ExplicitModelBuilder.cpp

@ -178,7 +178,7 @@ namespace storm {
// Create markovian states bit vector, if required
if (generator->getModelType() == storm::generator::ModelType::MA) {
// The BitVector will be resized when the correct size is known
markovianChoices = storm::storage::BitVector(64, false);
markovianChoices = storm::storage::BitVector();
}
// Create a callback for the next-state generator to enable it to request the index of states.
@ -230,7 +230,7 @@ namespace storm {
}
if (generator->getModelType() == storm::generator::ModelType::MA) {
markovianChoices->enlargeLiberally(currentRow, false);
markovianChoices->enlargeLiberally(currentRow+1, false);
markovianChoices->set(currentRow);
}
@ -279,7 +279,7 @@ namespace storm {
// If we keep track of the Markovian choices, store whether the current one is Markovian.
if( markovianChoices && choice.isMarkovian() ) {
markovianChoices->enlargeLiberally(currentRow, false);
markovianChoices->enlargeLiberally(currentRow+1, false);
markovianChoices->set(currentRow);
}

11
src/models/sparse/MarkovAutomaton.cpp

@ -267,7 +267,7 @@ namespace storm {
++row;
}
for(; row < this->getTransitionMatrix().getRowGroupIndices()[state+1]; ++row) {
STORM_LOG_THROW(storm::utility::isOne(this->getTransitionMatrix().getRowSum(row)), storm::exceptions::InvalidArgumentException, "Transitions of rateMatrix do not sum up to one for some non-Markovian choice.");
STORM_LOG_THROW(storm::utility::isOne(this->getTransitionMatrix().getRowSum(row)), storm::exceptions::InvalidArgumentException, "Transitions of rateMatrix do not sum up to one for some non-Markovian choice. Sum is " << this->getTransitionMatrix().getRowSum(row) << ". State is " << state << ". Choice is " << row << ".");
}
}
}
@ -355,6 +355,15 @@ namespace storm {
}
template<typename ValueType, typename RewardModelType>
void MarkovAutomaton<ValueType, RewardModelType>::printModelInformationToStream(std::ostream& out) const {
this->printModelInformationHeaderToStream(out);
out << "Choices: \t" << this->getNumberOfChoices() << std::endl;
out << "Markovian St.: \t" << this->getMarkovianStates().getNumberOfSetBits() << std::endl;
this->printModelInformationFooterToStream(out);
}
template class MarkovAutomaton<double>;
// template class MarkovAutomaton<float>;
template class MarkovAutomaton<storm::RationalNumber>;

6
src/models/sparse/MarkovAutomaton.h

@ -188,9 +188,11 @@ namespace storm {
std::shared_ptr<storm::models::sparse::Ctmc<ValueType, RewardModelType>> convertToCTMC();
virtual void writeDotToStream(std::ostream& outStream, bool includeLabeling = true, storm::storage::BitVector const* subsystem = nullptr, std::vector<ValueType> const* firstValue = nullptr, std::vector<ValueType> const* secondValue = nullptr, std::vector<uint_fast64_t> const* stateColoring = nullptr, std::vector<std::string> const* colors = nullptr, std::vector<uint_fast64_t>* scheduler = nullptr, bool finalizeOutput = true) const;
virtual void writeDotToStream(std::ostream& outStream, bool includeLabeling = true, storm::storage::BitVector const* subsystem = nullptr, std::vector<ValueType> const* firstValue = nullptr, std::vector<ValueType> const* secondValue = nullptr, std::vector<uint_fast64_t> const* stateColoring = nullptr, std::vector<std::string> const* colors = nullptr, std::vector<uint_fast64_t>* scheduler = nullptr, bool finalizeOutput = true) const override;
std::size_t getSizeInBytes() const;
std::size_t getSizeInBytes() const override;
virtual void printModelInformationToStream(std::ostream& out) const override;
private:
/*!

3
src/storage/BitVector.cpp

@ -255,7 +255,8 @@ namespace storm {
void BitVector::enlargeLiberally(uint_fast64_t minimumLength, bool init) {
if(minimumLength > this->size()) {
uint_fast64_t newLength = this->bucketCount() << 6;
uint_fast64_t newLength = this->bucketCount();
newLength = std::max(newLength, 1ull) << 6;
while(newLength < minimumLength) {
newLength = newLength << 1;
}

Loading…
Cancel
Save