Browse Source

add_memory_labels for memory unfolding added

refactoring
Sebastian Junges 4 years ago
parent
commit
75ad72a574
  1. 6
      lib/stormpy/pomdp/__init__.py
  2. 6
      src/pomdp/transformations.cpp

6
lib/stormpy/pomdp/__init__.py

@ -25,7 +25,7 @@ def make_simple(model):
else: else:
return pomdp._make_simple_Double(model) return pomdp._make_simple_Double(model)
def unfold_memory(model, memory):
def unfold_memory(model, memory, add_memory_labels=False):
""" """
Unfold the memory for an FSC into the POMDP Unfold the memory for an FSC into the POMDP
@ -34,9 +34,9 @@ def unfold_memory(model, memory):
:return: A pomdp that contains states from the product of the original POMDP and the FSC Memory :return: A pomdp that contains states from the product of the original POMDP and the FSC Memory
""" """
if model.supports_parameters: if model.supports_parameters:
return pomdp._unfold_memory_Rf(model, memory)
return pomdp._unfold_memory_Rf(model, memory, add_memory_labels)
else: else:
return pomdp._unfold_memory_Double(model, memory)
return pomdp._unfold_memory_Double(model, memory, add_memory_labels)
def apply_unknown_fsc(model, mode): def apply_unknown_fsc(model, mode):
if model.supports_parameters: if model.supports_parameters:

6
src/pomdp/transformations.cpp

@ -11,8 +11,8 @@ std::shared_ptr<storm::models::sparse::Pomdp<ValueType>> make_canonic(storm::mod
} }
template<typename ValueType> template<typename ValueType>
std::shared_ptr<storm::models::sparse::Pomdp<ValueType>> unfold_memory(storm::models::sparse::Pomdp<ValueType> const& pomdp, storm::storage::PomdpMemory const& memory) {
storm::transformer::PomdpMemoryUnfolder<ValueType> unfolder(pomdp, memory);
std::shared_ptr<storm::models::sparse::Pomdp<ValueType>> unfold_memory(storm::models::sparse::Pomdp<ValueType> const& pomdp, storm::storage::PomdpMemory const& memory, bool addMemoryLabels) {
storm::transformer::PomdpMemoryUnfolder<ValueType> unfolder(pomdp, memory, addMemoryLabels);
return unfolder.transform(); return unfolder.transform();
} }
@ -42,7 +42,7 @@ void define_transformations_nt(py::module &m) {
template<typename ValueType> template<typename ValueType>
void define_transformations(py::module& m, std::string const& vtSuffix) { void define_transformations(py::module& m, std::string const& vtSuffix) {
m.def(("_make_canonic_" + vtSuffix).c_str(), &make_canonic<ValueType>, "Return a canonicly-ordered POMDP", py::arg("pomdp")); m.def(("_make_canonic_" + vtSuffix).c_str(), &make_canonic<ValueType>, "Return a canonicly-ordered POMDP", py::arg("pomdp"));
m.def(("_unfold_memory_" + vtSuffix).c_str(), &unfold_memory<ValueType>, "Unfold memory into a POMDP", py::arg("pomdp"), py::arg("memorystructure"));
m.def(("_unfold_memory_" + vtSuffix).c_str(), &unfold_memory<ValueType>, "Unfold memory into a POMDP", py::arg("pomdp"), py::arg("memorystructure"), py::arg("memorylabels") = false);
m.def(("_make_simple_"+ vtSuffix).c_str(), &make_simple<ValueType>, "Make POMDP simple", py::arg("pomdp")); m.def(("_make_simple_"+ vtSuffix).c_str(), &make_simple<ValueType>, "Make POMDP simple", py::arg("pomdp"));
m.def(("_apply_unknown_fsc_" + vtSuffix).c_str(), &apply_unknown_fsc<ValueType>, "Apply unknown FSC",py::arg("pomdp"), py::arg("application_mode")=storm::transformer::PomdpFscApplicationMode::SIMPLE_LINEAR); m.def(("_apply_unknown_fsc_" + vtSuffix).c_str(), &apply_unknown_fsc<ValueType>, "Apply unknown FSC",py::arg("pomdp"), py::arg("application_mode")=storm::transformer::PomdpFscApplicationMode::SIMPLE_LINEAR);
} }

Loading…
Cancel
Save