Browse Source

some constructors

refactoring
hannah 5 years ago
committed by Matthias Volk
parent
commit
f64d5e8c4e
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 7
      src/storage/labeling.cpp
  2. 4
      src/storage/model.cpp
  3. 2
      src/storage/valuation.cpp

7
src/storage/labeling.cpp

@ -21,6 +21,7 @@ void define_labeling(py::module& m) {
// StateLabeling // StateLabeling
py::class_<storm::models::sparse::StateLabeling, std::shared_ptr<storm::models::sparse::StateLabeling>>(m, "StateLabeling", "Labeling for states", labeling) py::class_<storm::models::sparse::StateLabeling, std::shared_ptr<storm::models::sparse::StateLabeling>>(m, "StateLabeling", "Labeling for states", labeling)
.def(py::init<uint_fast64_t>(), "state_count"_a) // todo tests
.def("get_labels_of_state", &storm::models::sparse::StateLabeling::getLabelsOfState, "Get labels of given state", py::arg("state")) .def("get_labels_of_state", &storm::models::sparse::StateLabeling::getLabelsOfState, "Get labels of given state", py::arg("state"))
.def("add_label_to_state", &storm::models::sparse::StateLabeling::addLabelToState, "Add label to state", py::arg("label"), py::arg("state")) .def("add_label_to_state", &storm::models::sparse::StateLabeling::addLabelToState, "Add label to state", py::arg("label"), py::arg("state"))
.def("has_state_label", &storm::models::sparse::StateLabeling::getStateHasLabel, "Check if the given state has the given label", py::arg("label"), py::arg("state")) .def("has_state_label", &storm::models::sparse::StateLabeling::getStateHasLabel, "Check if the given state has the given label", py::arg("label"), py::arg("state"))
@ -32,6 +33,8 @@ void define_labeling(py::module& m) {
; ;
py::class_<storm::models::sparse::ChoiceLabeling>(m, "ChoiceLabeling", "Labeling for choices", labeling).
def("get_labels_of_choice", &storm::models::sparse::ChoiceLabeling::getLabelsOfChoice, py::arg("choice"), "get labels of a choice");
py::class_<storm::models::sparse::ChoiceLabeling>(m, "ChoiceLabeling", "Labeling for choices", labeling)
.def(py::init<uint_fast64_t>(), "choice_count"_a) // todo tests
.def("get_labels_of_choice", &storm::models::sparse::ChoiceLabeling::getLabelsOfChoice, py::arg("choice"), "get labels of a choice")
;
} }

4
src/storage/model.cpp

@ -237,6 +237,9 @@ void define_sparse_model(py::module& m) {
; ;
py::class_<SparseRewardModel<double>>(m, "SparseRewardModel", "Reward structure for sparse models") py::class_<SparseRewardModel<double>>(m, "SparseRewardModel", "Reward structure for sparse models")
.def(py::init<boost::optional<std::vector<double>> const&, boost::optional<std::vector<double>> const&,
boost::optional<storm::storage::SparseMatrix<double>> const&>(), py::arg("optional_state_reward_vector") = boost::none,
py::arg("optional_state_action_reward_vector") = boost::none, py::arg("optional_transition_reward_matrix") = boost::none) // todo tests
.def_property_readonly("has_state_rewards", &SparseRewardModel<double>::hasStateRewards) .def_property_readonly("has_state_rewards", &SparseRewardModel<double>::hasStateRewards)
.def_property_readonly("has_state_action_rewards", &SparseRewardModel<double>::hasStateActionRewards) .def_property_readonly("has_state_action_rewards", &SparseRewardModel<double>::hasStateActionRewards)
.def_property_readonly("has_transition_rewards", &SparseRewardModel<double>::hasTransitionRewards) .def_property_readonly("has_transition_rewards", &SparseRewardModel<double>::hasTransitionRewards)
@ -299,7 +302,6 @@ void define_sparse_model(py::module& m) {
; ;
py::class_<SparseRewardModel<RationalFunction>>(m, "SparseParametricRewardModel", "Reward structure for parametric sparse models") py::class_<SparseRewardModel<RationalFunction>>(m, "SparseParametricRewardModel", "Reward structure for parametric sparse models")
//todo init?
.def_property_readonly("has_state_rewards", &SparseRewardModel<RationalFunction>::hasStateRewards) .def_property_readonly("has_state_rewards", &SparseRewardModel<RationalFunction>::hasStateRewards)
.def_property_readonly("has_state_action_rewards", &SparseRewardModel<RationalFunction>::hasStateActionRewards) .def_property_readonly("has_state_action_rewards", &SparseRewardModel<RationalFunction>::hasStateActionRewards)
.def_property_readonly("has_transition_rewards", &SparseRewardModel<RationalFunction>::hasTransitionRewards) .def_property_readonly("has_transition_rewards", &SparseRewardModel<RationalFunction>::hasTransitionRewards)

2
src/storage/valuation.cpp

@ -4,6 +4,7 @@
#include "storm/storage/sparse/StateValuations.h" #include "storm/storage/sparse/StateValuations.h"
#include "storm/storage/expressions/SimpleValuation.h" #include "storm/storage/expressions/SimpleValuation.h"
#include "storm/storage/expressions/Variable.h" #include "storm/storage/expressions/Variable.h"
#include "storm/storage/expressions/ExpressionManager.h"
// Thin wrappers // Thin wrappers
std::string toJson(storm::storage::sparse::StateValuations const& valuations, storm::storage::sparse::state_type const& stateIndex, boost::optional<std::set<storm::expressions::Variable>> const& selectedVariables) { std::string toJson(storm::storage::sparse::StateValuations const& valuations, storm::storage::sparse::state_type const& stateIndex, boost::optional<std::set<storm::expressions::Variable>> const& selectedVariables) {
@ -20,6 +21,7 @@ void define_statevaluation(py::module& m) {
.def("get_rational_value", &storm::storage::sparse::StateValuations::getRationalValue, py::arg("state"), py::arg("variable")) .def("get_rational_value", &storm::storage::sparse::StateValuations::getRationalValue, py::arg("state"), py::arg("variable"))
.def("get_string", &storm::storage::sparse::StateValuations::toString, py::arg("state"), py::arg("pretty")=true, py::arg("selected_variables")=boost::none) .def("get_string", &storm::storage::sparse::StateValuations::toString, py::arg("state"), py::arg("pretty")=true, py::arg("selected_variables")=boost::none)
.def("get_json", &toJson, py::arg("state"), py::arg("selected_variables")=boost::none) .def("get_json", &toJson, py::arg("state"), py::arg("selected_variables")=boost::none)
.def("get_nr_of_states", &storm::storage::sparse::StateValuations::getNumberOfStates);
; ;
} }
Loading…
Cancel
Save