From c038a82e3e12052055444140b6a5fcbcdbf93fe9 Mon Sep 17 00:00:00 2001 From: hannah Date: Thu, 4 Jun 2020 19:51:04 +0200 Subject: [PATCH] cleaned --- src/storage/model.cpp | 12 ++++++------ src/storage/model_components.cpp | 12 ++---------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/storage/model.cpp b/src/storage/model.cpp index a6a2db3..5739579 100644 --- a/src/storage/model.cpp +++ b/src/storage/model.cpp @@ -198,12 +198,12 @@ void define_sparse_model(py::module& m) { ; py::class_, std::shared_ptr>>(m, "SparseDtmc", "DTMC in sparse representation", model) .def(py::init>(), py::arg("other_model")) - .def(py::init const&>(), py::arg("components")) //todo tests + .def(py::init const&>(), py::arg("components")) .def("__str__", &getModelInfoPrinter) ; py::class_, std::shared_ptr>> mdp(m, "SparseMdp", "MDP in sparse representation", model); mdp.def(py::init>(), py::arg("other_model")) - .def(py::init const&, storm::models::ModelType>(), py::arg("components"), py::arg("type")=storm::models::ModelType::Mdp) //todo tests + .def(py::init const&, storm::models::ModelType>(), py::arg("components"), py::arg("type")=storm::models::ModelType::Mdp) .def_property_readonly("nondeterministic_choice_indices", [](SparseMdp const& mdp) { return mdp.getNondeterministicChoiceIndices(); }) .def("get_nr_available_actions", [](SparseMdp const& mdp, uint64_t stateIndex) { return mdp.getNondeterministicChoiceIndices()[stateIndex+1] - mdp.getNondeterministicChoiceIndices()[stateIndex] ; }, py::arg("state")) .def("get_choice_index", [](SparseMdp const& mdp, uint64_t state, uint64_t actOff) { return mdp.getNondeterministicChoiceIndices()[state]+actOff; }, py::arg("state"), py::arg("action_offset"), "gets the choice index for the offset action from the given state.") @@ -212,7 +212,7 @@ void define_sparse_model(py::module& m) { ; py::class_, std::shared_ptr>>(m, "SparsePomdp", "POMDP in sparse representation", mdp) .def(py::init>(), py::arg("other_model")) - .def(py::init const&, bool>(), py::arg("components"), py::arg("canonic_flag")=false) //todo tests + .def(py::init const&, bool>(), py::arg("components"), py::arg("canonic_flag")=false) .def("__str__", &getModelInfoPrinter) .def("get_observation", &SparsePomdp::getObservation, py::arg("state")) .def_property_readonly("observations", &SparsePomdp::getObservations) @@ -220,14 +220,14 @@ void define_sparse_model(py::module& m) { ; py::class_, std::shared_ptr>>(m, "SparseCtmc", "CTMC in sparse representation", model) .def(py::init>(), py::arg("other_model")) - .def(py::init const&>(), py::arg("components")) //todo tests + .def(py::init const&>(), py::arg("components")) .def_property_readonly("exit_rates", [](SparseCtmc const& ctmc) { return ctmc.getExitRateVector(); }) //todo new: tests .def("__str__", &getModelInfoPrinter) ; py::class_, std::shared_ptr>>(m, "SparseMA", "MA in sparse representation", model) .def(py::init>(), py::arg("other_model")) - .def(py::init const&>(), py::arg("components")) // todo tests - .def_property_readonly("exit_rates", [](SparseMarkovAutomaton const& ma) { return ma.getExitRates(); }) //todo new: tests + .def(py::init const&>(), py::arg("components")) + .def_property_readonly("exit_rates", [](SparseMarkovAutomaton const& ma) { return ma.getExitRates(); }) .def_property_readonly("markovian_states", [](SparseMarkovAutomaton const& ma) { return ma.getMarkovianStates(); }) //todo new: tests .def_property_readonly("nondeterministic_choice_indices", [](SparseMarkovAutomaton const& ma) { return ma.getNondeterministicChoiceIndices(); }) .def("apply_scheduler", [](SparseMarkovAutomaton const& ma, storm::storage::Scheduler const& scheduler, bool dropUnreachableStates) { return ma.applyScheduler(scheduler, dropUnreachableStates); } , "apply scheduler", "scheduler"_a, "drop_unreachable_states"_a = true) diff --git a/src/storage/model_components.cpp b/src/storage/model_components.cpp index 9769e17..9a03a73 100644 --- a/src/storage/model_components.cpp +++ b/src/storage/model_components.cpp @@ -15,17 +15,11 @@ template using SparseRewardModel = storm::models::sparse::St template using SparseModelComponents = storm::storage::sparse::ModelComponents; -// others: todo -// ; -// -// -// > // Parametric models, Valuetype: todo void define_sparse_model_components(py::module& m) { - // shared_ptr? todo py::class_, std::shared_ptr>>(m, "SparseModelComponents", "ModelComponents description..") //todo .def(py::init const&, StateLabeling const&, std::unordered_map> const&, @@ -34,11 +28,9 @@ void define_sparse_model_components(py::module& m) { py::arg("reward_models") = std::unordered_map>(), py::arg("rate_transitions") = false, py::arg("markovian_states") = boost::none, py::arg("player1_matrix") = boost::none) - - // General components (for all model types) - .def_readwrite("transition_matrix", &SparseModelComponents::transitionMatrix) - .def_readwrite("state_labeling", &SparseModelComponents::stateLabeling) + .def_readwrite("transition_matrix", &SparseModelComponents::transitionMatrix, "The transition matrix") + .def_readwrite("state_labeling", &SparseModelComponents::stateLabeling, "The state labeling") .def_readwrite("reward_models", &SparseModelComponents::rewardModels, "Reward models associated with the model") .def_readwrite("choice_labeling", &SparseModelComponents::choiceLabeling, "A vector that stores a labeling for each choice") .def_readwrite("state_valuations", &SparseModelComponents::stateValuations, "A vector that stores for each state to which variable valuation it belongs")