Browse Source

better dot output for pomdp models

tempestpy_adaptions
Sebastian Junges 5 years ago
parent
commit
fe2dcfc975
  1. 11
      src/storm/models/sparse/Model.cpp
  2. 11
      src/storm/models/sparse/Model.h
  3. 8
      src/storm/models/sparse/Pomdp.cpp
  4. 7
      src/storm/models/sparse/Pomdp.h

11
src/storm/models/sparse/Model.cpp

@ -363,7 +363,9 @@ namespace storm {
storm::utility::outputFixedWidth(outStream, this->getLabelsOfState(state), maxWidthLabel); storm::utility::outputFixedWidth(outStream, this->getLabelsOfState(state), maxWidthLabel);
outStream << "}"; outStream << "}";
} }
outStream << this->additionalDotStateInfo(state);
// If we are to include some values for the state as well, we do so now. // If we are to include some values for the state as well, we do so now.
if (firstValue != nullptr || secondValue != nullptr) { if (firstValue != nullptr || secondValue != nullptr) {
outStream << " ["; outStream << " [";
@ -397,7 +399,12 @@ namespace storm {
outStream << "}" << std::endl; outStream << "}" << std::endl;
} }
} }
template<typename ValueType, typename RewardModelType>
std::string Model<ValueType, RewardModelType>::additionalDotStateInfo(uint64_t state) const {
return "";
}
template<typename ValueType, typename RewardModelType> template<typename ValueType, typename RewardModelType>
std::set<std::string> Model<ValueType, RewardModelType>::getLabelsOfState(storm::storage::sparse::state_type state) const { std::set<std::string> Model<ValueType, RewardModelType>::getLabelsOfState(storm::storage::sparse::state_type state) const {
return this->stateLabeling.getLabelsOfState(state); return this->stateLabeling.getLabelsOfState(state);

11
src/storm/models/sparse/Model.h

@ -333,8 +333,8 @@ namespace storm {
* @param finalizeOutput A flag that sets whether or not the dot stream is closed with a curly brace. * @param finalizeOutput A flag that sets whether or not the dot stream is closed with a curly brace.
* @return A string containing the exported model in dot-format. * @return A string containing the exported model in dot-format.
*/ */
virtual void writeDotToStream(std::ostream& outStream, size_t maxWidthLabel = 30, 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, size_t maxWidthLabel = 30, bool includeLabeling = true, storm::storage::BitVector const* subsystem = nullptr, std::vector<ValueType> const* firstValue = nullptr, std::vector<ValueType> const* secondValue = nullptr, std::vector<uint64_t> const* stateColoring = nullptr, std::vector<std::string> const* colors = nullptr, std::vector<uint_fast64_t>* scheduler = nullptr, bool finalizeOutput = true) const;
/*! /*!
* Retrieves the set of labels attached to the given state. * Retrieves the set of labels attached to the given state.
* *
@ -394,6 +394,13 @@ namespace storm {
* @param out The stream the information is to be printed to. * @param out The stream the information is to be printed to.
*/ */
void printRewardModelsInformationToStream(std::ostream& out) const; void printRewardModelsInformationToStream(std::ostream& out) const;
/*!
* Return a string that is additonally added to the state information in the dot stream.
* @param state
* @return
*/
virtual std::string additionalDotStateInfo(uint64_t state) const;
private: private:

8
src/storm/models/sparse/Pomdp.cpp

@ -59,6 +59,12 @@ namespace storm {
return observations; return observations;
} }
template<typename ValueType, typename RewardModelType>
std::string Pomdp<ValueType, RewardModelType>::additionalDotStateInfo(uint64_t state) const {
return "<" + std::to_string(getObservation(state)) + ">";
}
template<typename ValueType, typename RewardModelType> template<typename ValueType, typename RewardModelType>
std::vector<uint64_t> std::vector<uint64_t>
Pomdp<ValueType, RewardModelType>::getStatesWithObservation(uint32_t observation) const { Pomdp<ValueType, RewardModelType>::getStatesWithObservation(uint32_t observation) const {
@ -71,6 +77,8 @@ namespace storm {
return result; return result;
} }
template class Pomdp<double>; template class Pomdp<double>;
template class Pomdp<storm::RationalNumber>; template class Pomdp<storm::RationalNumber>;
template class Pomdp<double, storm::models::sparse::StandardRewardModel<storm::Interval>>; template class Pomdp<double, storm::models::sparse::StandardRewardModel<storm::Interval>>;

7
src/storm/models/sparse/Pomdp.h

@ -64,6 +64,13 @@ namespace storm {
std::vector<uint64_t> getStatesWithObservation(uint32_t observation) const; std::vector<uint64_t> getStatesWithObservation(uint32_t observation) const;
protected: protected:
/*!
* Return a string that is additonally added to the state information in the dot stream.
* @param state
* @return
*/
virtual std::string additionalDotStateInfo(uint64_t state) const override;
// TODO: consider a bitvector based presentation (depending on our needs). // TODO: consider a bitvector based presentation (depending on our needs).
std::vector<uint32_t> observations; std::vector<uint32_t> observations;

Loading…
Cancel
Save