From 49afda739d9fe83b1641f1360f49837942eb145a Mon Sep 17 00:00:00 2001 From: Linus Heck Date: Thu, 20 Aug 2026 11:58:39 +0200 Subject: [PATCH] Run conversion to smart_holder aka classh --- src/common.h | 3 - src/core/analysis.cpp | 3 +- src/core/bisimulation.cpp | 2 +- src/core/core.cpp | 21 +++-- src/core/counterexample.cpp | 10 +-- src/core/environment.cpp | 22 +++--- src/core/input.cpp | 4 +- src/core/modelchecking.cpp | 7 +- src/core/multiobjective.cpp | 3 +- src/core/result.cpp | 44 ++++------- src/core/simulator.cpp | 4 +- src/core/transformation.cpp | 8 +- src/dft/analysis.cpp | 6 +- src/dft/dft.cpp | 4 +- src/dft/dft_elements.cpp | 7 +- src/dft/dft_state.cpp | 8 +- src/dft/module.cpp | 2 +- src/dft/simulator.cpp | 6 +- src/dft/transformations.cpp | 2 +- src/gspn/gspn.cpp | 16 ++-- src/gspn/gspn_io.cpp | 4 +- src/logic/formulae.cpp | 77 +++++++------------ src/mod_info.cpp | 2 +- src/pars/model_instantiator.cpp | 6 +- src/pars/pars.cpp | 6 +- src/pars/pla.cpp | 13 ++-- src/pomdp/generator.cpp | 8 +- src/pomdp/memory.cpp | 4 +- src/pomdp/qualitative_analysis.cpp | 10 +-- src/pomdp/quantitative_analysis.cpp | 8 +- src/pomdp/tracker.cpp | 8 +- src/pomdp/transformations.cpp | 4 +- src/pycarl/core/monomial.cpp | 2 +- src/pycarl/core/variable.cpp | 2 +- src/pycarl/typed_core/factorization.cpp | 5 +- .../typed_core/factorizedpolynomial.cpp | 2 +- .../typed_core/factorizedrationalfunction.cpp | 2 +- src/pycarl/typed_core/integer.cpp | 4 +- src/pycarl/typed_core/interval.h | 2 +- src/pycarl/typed_core/polynomial.cpp | 2 +- src/pycarl/typed_core/rational.cpp | 4 +- src/pycarl/typed_core/rationalfunction.cpp | 2 +- src/pycarl/typed_core/term.cpp | 2 +- src/pycarl/typed_formula/constraint.cpp | 6 +- src/pycarl/typed_formula/formula.cpp | 2 +- src/storage/bitvector.cpp | 2 +- src/storage/choiceorigins.cpp | 9 +-- src/storage/dd.cpp | 20 ++--- src/storage/dd.h | 4 +- src/storage/decomposition.cpp | 5 +- src/storage/distribution.cpp | 2 +- src/storage/expressions.cpp | 13 ++-- src/storage/geometry.cpp | 2 +- src/storage/jani.cpp | 44 +++++------ src/storage/labeling.cpp | 6 +- src/storage/matrix.cpp | 8 +- src/storage/memorystructure.cpp | 12 +-- src/storage/model.cpp | 54 +++++-------- src/storage/model_components.cpp | 3 +- src/storage/prism.cpp | 26 +++---- src/storage/scheduler.cpp | 4 +- src/storage/state.cpp | 8 +- src/storage/umb.cpp | 6 +- src/storage/valuation.cpp | 12 +-- src/utility/chrono.cpp | 2 +- src/utility/json.cpp | 2 +- src/utility/shortestPaths.cpp | 4 +- src/utility/smtsolver.cpp | 12 ++- 68 files changed, 279 insertions(+), 350 deletions(-) diff --git a/src/common.h b/src/common.h index 576b955b89..dfad7d9b26 100644 --- a/src/common.h +++ b/src/common.h @@ -11,7 +11,4 @@ namespace py = pybind11; using namespace pybind11::literals; -PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr) -PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr) - #include "src/boost.h" diff --git a/src/core/analysis.cpp b/src/core/analysis.cpp index 501d07312b..c942f229ad 100644 --- a/src/core/analysis.cpp +++ b/src/core/analysis.cpp @@ -5,8 +5,7 @@ // Define python bindings void define_graph_constraints(py::module& m) { // ConstraintCollector - py::class_, std::shared_ptr>>( - m, "ConstraintCollector", "Collector for constraints on parametric Markov chains") + py::classh>(m, "ConstraintCollector", "Collector for constraints on parametric Markov chains") .def(py::init const&>(), py::arg("model")) .def_property_readonly("wellformed_constraints", &storm::analysis::ConstraintCollector::getWellformedConstraints, "Get the constraints ensuring a wellformed model") diff --git a/src/core/bisimulation.cpp b/src/core/bisimulation.cpp index 5755f5410e..5ce9be5e7b 100644 --- a/src/core/bisimulation.cpp +++ b/src/core/bisimulation.cpp @@ -37,7 +37,7 @@ void define_bisimulation(py::module& m) { .value("DD", storm::dd::bisimulation::QuotientFormat::Dd) .finalize(); - py::class_(m, "BisimulationOptionsDd", "Options for Dd bisimulation") + py::classh(m, "BisimulationOptionsDd", "Options for Dd bisimulation") .def(py::init<>(), "Create") .def_readwrite("reuse_mode", &storm::dd::bisimulation::BisimulationOptions::reuseMode, "Reuse mode") .def_readwrite("refinement_mode", &storm::dd::bisimulation::BisimulationOptions::refinementMode, "Refinement mode") diff --git a/src/core/core.cpp b/src/core/core.cpp index 003578c9aa..1583302cd0 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -144,7 +144,7 @@ void define_build_sparse_model_defs(py::module& m) { ("Build the " + desc + "model from DRN" + (std::is_same_v ? " (parametric)" : "")).c_str(), py::arg("file"), py::arg("options") = storm::parser::DirectEncodingParserOptions()); - py::class_::Options>(m, ("Explicit" + classType + "ModelBuilderOptions").c_str(), + py::classh::Options>(m, ("Explicit" + classType + "ModelBuilderOptions").c_str(), "Options for the explicit model builder") .def(py::init<>(), "Create") .def_readwrite("exploration_order", &storm::builder::ExplicitModelBuilder::Options::explorationOrder, @@ -164,7 +164,7 @@ void define_build_sparse_model_defs(py::module& m) { m.def("make_sparse_model_builder", &storm::api::makeExplicitModelBuilder, "Construct a builder instance", py::arg("model_description"), py::arg("options"), py::arg("action_mask") = nullptr, py::arg("exploration_options") = typename storm::builder::ExplicitModelBuilder::Options()); - py::class_>(m, "ExplicitModelBuilder", "Model builder for sparse models") + py::classh>(m, "ExplicitModelBuilder", "Model builder for sparse models") .def("build", &storm::builder::ExplicitModelBuilder::build, "Build the model", py::call_guard()) .def("export_lookup", &storm::builder::ExplicitModelBuilder::exportExplicitStateLookup, "Export a lookup model"); } else if constexpr (std::is_same_v) { @@ -174,7 +174,7 @@ void define_build_sparse_model_defs(py::module& m) { m.def("make_sparse_model_builder_parametric", &storm::api::makeExplicitModelBuilder, "Construct a builder instance", py::arg("model_description"), py::arg("options"), py::arg("action_mask") = nullptr, py::arg("exploration_options") = typename storm::builder::ExplicitModelBuilder::Options()); - py::class_>(m, "ExplicitParametricModelBuilder", "Model builder for sparse models") + py::classh>(m, "ExplicitParametricModelBuilder", "Model builder for sparse models") .def("build", &storm::builder::ExplicitModelBuilder::build, "Build the model", py::call_guard()) .def("export_lookup", &storm::builder::ExplicitModelBuilder::exportExplicitStateLookup, "Export a lookup model"); } else if constexpr (std::is_same_v) { @@ -185,7 +185,7 @@ void define_build_sparse_model_defs(py::module& m) { } void define_build(py::module& m) { - py::class_(m, "DirectEncodingParserOptions", "Options for the .drn parser") + py::classh(m, "DirectEncodingParserOptions", "Options for the .drn parser") .def(py::init<>(), "initialise") .def_readwrite("build_choice_labels", &storm::parser::DirectEncodingParserOptions::buildChoiceLabeling, "Build with choice labels"); @@ -194,7 +194,7 @@ void define_build(py::module& m) { .value("BFS", storm::builder::ExplorationOrder::Bfs) .finalize(); - py::class_(m, "ExplicitModelParserOptions", "Options for the explicit model parser") + py::classh(m, "ExplicitModelParserOptions", "Options for the explicit model parser") .def(py::init<>(), "Create") .def_readwrite("fix_deadlocks", &storm::parser::ExplicitModelParserOptions::fixDeadlocks, "If set, deadlocks states will be fixed by adding a self-loop with probability 1.") @@ -207,7 +207,7 @@ void define_build(py::module& m) { define_build_sparse_model_defs(m); define_build_sparse_model_defs(m); - py::class_>(m, "ExplicitStateLookup", "Lookup model for states") + py::classh>(m, "ExplicitStateLookup", "Lookup model for states") .def( "lookup", [](storm::builder::ExplicitStateLookup const& lookup, @@ -223,7 +223,7 @@ void define_build(py::module& m) { ; - py::class_(m, "BuilderOptions", "Options for building process") + py::classh(m, "BuilderOptions", "Options for building process") .def(py::init> const&>(), "Initialise with formulae to preserve", py::arg("formulae")) .def(py::init(), "Initialise without formulae", py::arg("build_all_reward_models") = true, py::arg("build_all_labels") = true) .def_property_readonly("preserved_label_names", &storm::builder::BuilderOptions::getLabelNames, "Labels preserved") @@ -242,9 +242,8 @@ void define_build(py::module& m) { .def("set_build_all_reward_models", &storm::builder::BuilderOptions::setBuildAllRewardModels, "Build with all reward models", py::arg("new_value") = true); - py::class_, std::shared_ptr>> actionmask(m, "ActionMaskDouble"); - py::class_, std::shared_ptr>> actfuncmask( - m, "StateValuationFunctionActionMaskDouble", actionmask); + py::classh> actionmask(m, "ActionMaskDouble"); + py::classh> actfuncmask(m, "StateValuationFunctionActionMaskDouble", actionmask); actfuncmask.def(py::init>(), py::arg("f")); } @@ -296,7 +295,7 @@ void define_export_drn(py::module& m) { } void define_export(py::module& m) { - py::class_(m, "DirectEncodingExporterOptions") + py::classh(m, "DirectEncodingExporterOptions") .def(py::init<>()) .def_readwrite("allow_placeholders", &storm::io::DirectEncodingExporterOptions::allowPlaceholders) .def_readwrite("outputPrecision", &storm::io::DirectEncodingExporterOptions::outputPrecision); diff --git a/src/core/counterexample.cpp b/src/core/counterexample.cpp index fb81350ff9..50d79a6b9b 100644 --- a/src/core/counterexample.cpp +++ b/src/core/counterexample.cpp @@ -9,7 +9,7 @@ using namespace storm::counterexamples; void define_counterexamples(py::module& m) { using FlatSet = boost::container::flat_set, boost::container::new_allocator>; - py::class_(m, "FlatSet", "Container to pass to program") + py::classh(m, "FlatSet", "Container to pass to program") .def(py::init<>()) .def(py::init(), "other"_a) .def("insert", [](FlatSet& flatset, uint64_t value) { flatset.insert(value); }) @@ -37,7 +37,7 @@ void define_counterexamples(py::module& m) { using CexGeneratorStats = SMTMinimalLabelSetGenerator::GeneratorStats; - py::class_(m, "SMTCounterExampleGeneratorStats", "Stats for highlevel counterexample generation") + py::classh(m, "SMTCounterExampleGeneratorStats", "Stats for highlevel counterexample generation") .def(py::init<>()) .def_readonly("analysis_time", &CexGeneratorStats::analysisTime) .def_readonly("setup_time", &CexGeneratorStats::setupTime) @@ -47,7 +47,7 @@ void define_counterexamples(py::module& m) { .def_readonly("iterations", &CexGeneratorStats::iterations); using CexGeneratorOptions = SMTMinimalLabelSetGenerator::Options; - py::class_(m, "SMTCounterExampleGeneratorOptions", "Options for highlevel counterexample generation") + py::classh(m, "SMTCounterExampleGeneratorOptions", "Options for highlevel counterexample generation") .def(py::init<>()) .def_readwrite("check_threshold_feasible", &CexGeneratorOptions::checkThresholdFeasible) .def_readwrite("encode_reachability", &CexGeneratorOptions::encodeReachability) @@ -57,7 +57,7 @@ void define_counterexamples(py::module& m) { .def_readwrite("maximum_counterexamples", &CexGeneratorOptions::maximumCounterexamples) .def_readwrite("continue_after_first_counterexample", &CexGeneratorOptions::continueAfterFirstCounterexampleUntil) .def_readwrite("maximum_iterations_after_counterexample", &CexGeneratorOptions::maximumExtraIterations); - py::class_>(m, "SMTCounterExampleGenerator", "Highlevel Counterexample Generator with SMT as backend") + py::classh>(m, "SMTCounterExampleGenerator", "Highlevel Counterexample Generator with SMT as backend") .def_static("precompute", &SMTMinimalLabelSetGenerator::precompute, "Precompute input for counterexample generation", py::arg("env"), py::arg("symbolic_model"), py::arg("model"), py::arg("formula")) .def_static("build", &SMTMinimalLabelSetGenerator::computeCounterexampleLabelSet, "Compute counterexample", py::arg("env"), py::arg("stats"), @@ -66,7 +66,7 @@ void define_counterexamples(py::module& m) { ; using CexInput = SMTMinimalLabelSetGenerator::CexInput; - py::class_(m, "SMTCounterExampleInput", "Precomputed input for counterexample generation") + py::classh(m, "SMTCounterExampleInput", "Precomputed input for counterexample generation") .def("add_reward_and_threshold", &CexInput::addRewardThresholdCombination, "add another reward structure and threshold", py::arg("reward_name"), py::arg("threshold")); } diff --git a/src/core/environment.cpp b/src/core/environment.cpp index 0609068d1a..ed5e586c7f 100644 --- a/src/core/environment.cpp +++ b/src/core/environment.cpp @@ -111,7 +111,7 @@ void define_environment(py::module& m) { .value("counter", storm::storage::SchedulerClass::MemoryPattern::Counter) .finalize(); - py::class_(m, "SchedulerClass", "Scheduler class restriction") + py::classh(m, "SchedulerClass", "Scheduler class restriction") .def(py::init<>()) .def_property("deterministic", &storm::storage::SchedulerClass::isDeterministic, [](storm::storage::SchedulerClass& sc, bool v) { sc.setIsDeterministic(v); }) @@ -133,7 +133,7 @@ void define_environment(py::module& m) { .def("set_memory_pattern", [](storm::storage::SchedulerClass& sc, storm::storage::SchedulerClass::MemoryPattern p) { sc.setMemoryPattern(p); }) .def("set_positional", &storm::storage::SchedulerClass::setPositional); - py::class_(m, "Environment", "Environment") + py::classh(m, "Environment", "Environment") .def(py::init<>(), "Construct default environment") .def_property_readonly( "solver_environment", [](storm::Environment& env) -> auto& { return env.solver(); }, "solver part of environment") @@ -141,7 +141,7 @@ void define_environment(py::module& m) { "model_checker_environment", [](storm::Environment& env) -> auto& { return env.modelchecker(); }, "model checker part of environment") .def_property_readonly("dd_environment", [](storm::Environment& env) -> auto& { return env.dd(); }, "dd part of environment"); - py::class_(m, "ConditionalModelCheckerEnvironment", "Environment for conditional model checking") + py::classh(m, "ConditionalModelCheckerEnvironment", "Environment for conditional model checking") .def_property("algorithm", &storm::ConditionalModelCheckerEnvironment::getAlgorithm, &storm::ConditionalModelCheckerEnvironment::setAlgorithm, "algorithm for conditional model checking") .def_property( @@ -151,7 +151,7 @@ void define_environment(py::module& m) { .def_property("relative", &storm::ConditionalModelCheckerEnvironment::isRelativePrecision, &storm::ConditionalModelCheckerEnvironment::setRelativePrecision, "whether the precision is relative"); - py::class_(m, "ModelCheckerEnvironment", "Environment for the model checker") + py::classh(m, "ModelCheckerEnvironment", "Environment for the model checker") .def_property("steady_state_distribution_algorithm", &storm::ModelCheckerEnvironment::getSteadyStateDistributionAlgorithm, &storm::ModelCheckerEnvironment::setSteadyStateDistributionAlgorithm, "steady state distribution algorithm used") .def_property( @@ -175,7 +175,7 @@ void define_environment(py::module& m) { "multi", [](storm::ModelCheckerEnvironment& env) -> storm::MultiObjectiveModelCheckerEnvironment& { return env.multi(); }, py::return_value_policy::reference, "Access multi-objective sub-environment"); - py::class_(m, "MultiObjectiveModelCheckerEnvironment", "Environment for multi-objective model checking") + py::classh(m, "MultiObjectiveModelCheckerEnvironment", "Environment for multi-objective model checking") .def_property( "method", [](storm::MultiObjectiveModelCheckerEnvironment const& env) { return env.getMethod(); }, &storm::MultiObjectiveModelCheckerEnvironment::setMethod, "multi-objective model checking method") @@ -262,7 +262,7 @@ void define_environment(py::module& m) { .def_property("print_results", &storm::MultiObjectiveModelCheckerEnvironment::isPrintResultsSet, &storm::MultiObjectiveModelCheckerEnvironment::setPrintResults); - py::class_(m, "SolverEnvironment", "Environment for solvers") + py::classh(m, "SolverEnvironment", "Environment for solvers") .def("set_force_sound", &storm::SolverEnvironment::setForceSoundness, "force soundness", py::arg("new_value") = true) .def("set_force_exact", &storm::SolverEnvironment::setForceExact, "force exact solving", py::arg("new_value") = true) .def("set_linear_equation_solver_type", &storm::SolverEnvironment::setLinearEquationSolverType, "set solver type to use", py::arg("new_value"), @@ -270,27 +270,27 @@ void define_environment(py::module& m) { .def_property_readonly("minmax_solver_environment", [](storm::SolverEnvironment& senv) -> auto& { return senv.minMax(); }) .def_property_readonly("native_solver_environment", [](storm::SolverEnvironment& senv) -> auto& { return senv.native(); }); - py::class_(m, "NativeSolverEnvironment", "Environment for Native solvers") + py::classh(m, "NativeSolverEnvironment", "Environment for Native solvers") .def_property("method", &storm::NativeSolverEnvironment::getMethod, [](storm::NativeSolverEnvironment& nsenv, storm::solver::NativeLinearEquationSolverMethod const& m) { nsenv.setMethod(m); }) .def_property("maximum_iterations", &storm::NativeSolverEnvironment::getMaximalNumberOfIterations, [](storm::NativeSolverEnvironment& nsenv, uint64_t iters) { nsenv.setMaximalNumberOfIterations(iters); }) .def_property("precision", &storm::NativeSolverEnvironment::getPrecision, &storm::NativeSolverEnvironment::setPrecision); - py::class_(m, "MinMaxSolverEnvironment", "Environment for Min-Max-Solvers") + py::classh(m, "MinMaxSolverEnvironment", "Environment for Min-Max-Solvers") .def_property("method", &storm::MinMaxSolverEnvironment::getMethod, [](storm::MinMaxSolverEnvironment& mmenv, storm::solver::MinMaxMethod const& m) { mmenv.setMethod(m, false); }) .def_property("precision", &storm::MinMaxSolverEnvironment::getPrecision, &storm::MinMaxSolverEnvironment::setPrecision); - py::class_(m, "DdEnvironment", "Environment for DD libraries") + py::classh(m, "DdEnvironment", "Environment for DD libraries") .def_property_readonly("sylvan", [](storm::DdEnvironment& senv) -> auto& { return senv.sylvan(); }) .def_property_readonly("cudd", [](storm::DdEnvironment& senv) -> auto& { return senv.cudd(); }); - py::class_(m, "SylvanDdManagerEnvironment", "Environment for Sylvan Dd manager") + py::classh(m, "SylvanDdManagerEnvironment", "Environment for Sylvan Dd manager") .def_property("maximal_memory", &storm::SylvanDdManagerEnvironment::getMaximalMemory, &storm::SylvanDdManagerEnvironment::setMaximalMemory) .def_property("number_threads", &storm::SylvanDdManagerEnvironment::getNumberOfThreads, &storm::SylvanDdManagerEnvironment::setNumberOfThreads); - py::class_(m, "CuddDdManagerEnvironment", "Environment for CUDD Dd manager") + py::classh(m, "CuddDdManagerEnvironment", "Environment for CUDD Dd manager") .def_property("maximal_memory", &storm::CuddDdManagerEnvironment::getMaximalMemory, &storm::CuddDdManagerEnvironment::setMaximalMemory) .def_property("constant_precision", &storm::CuddDdManagerEnvironment::getConstantPrecision, &storm::CuddDdManagerEnvironment::setConstantPrecision) .def_property("reordering_enabled", &storm::CuddDdManagerEnvironment::isReorderingEnabled, &storm::CuddDdManagerEnvironment::setReorderingEnabled) diff --git a/src/core/input.cpp b/src/core/input.cpp index 96a4c69f9d..a1a18a7fb3 100644 --- a/src/core/input.cpp +++ b/src/core/input.cpp @@ -6,7 +6,7 @@ #include "src/helpers.h" void define_property(py::module& m) { - py::class_(m, "Property", "Property") + py::classh(m, "Property", "Property") .def(py::init const&, std::set const&, std::string const&>(), "Construct property from formula", py::arg("name"), py::arg("formula"), py::arg("undefined_constants") = std::set(), @@ -73,7 +73,7 @@ void define_input(py::module& m) { .finalize(); // SymbolicModelDescription - py::class_(m, "SymbolicModelDescription", "Symbolic description of model") + py::classh(m, "SymbolicModelDescription", "Symbolic description of model") .def(py::init(), "Construct from Prism program", py::arg("prism_program")) .def(py::init(), "Construct from Jani model", py::arg("jani_model")) .def_property_readonly("is_prism_program", &storm::storage::SymbolicModelDescription::isPrismProgram, "Flag if program is in Prism format") diff --git a/src/core/modelchecking.cpp b/src/core/modelchecking.cpp index e1fff96abd..46760db09a 100644 --- a/src/core/modelchecking.cpp +++ b/src/core/modelchecking.cpp @@ -145,7 +145,7 @@ storm::storage::BitVector getReachableStates(storm::models::sparse::Model void define_check_task(py::module& m, std::string const& name) { // CheckTask - py::class_, std::shared_ptr>>(m, name.c_str(), "Task for model checking") + py::classh>(m, name.c_str(), "Task for model checking") .def(py::init(), py::arg("formula"), py::arg("only_initial_states") = false) .def("set_produce_schedulers", &CheckTask::setProduceSchedulers, "Set whether schedulers should be produced (if possible)", py::arg("produce_schedulers") = true) @@ -207,9 +207,8 @@ void define_modelchecking_mdefs(py::module& m) { } void define_modelchecking(py::module& m) { - py::class_> mchint( - m, "ModelCheckerHint", "Information that may accelerate the model checking process"); - py::class_>(m, "ExplicitModelCheckerHintDouble", + py::classh mchint(m, "ModelCheckerHint", "Information that may accelerate the model checking process"); + py::classh>(m, "ExplicitModelCheckerHintDouble", "Information that may accelerate an explicit state model checker", mchint) .def(py::init<>()) .def("set_scheduler_hint", diff --git a/src/core/multiobjective.cpp b/src/core/multiobjective.cpp index d8d6ff6897..606a75e9fc 100644 --- a/src/core/multiobjective.cpp +++ b/src/core/multiobjective.cpp @@ -27,8 +27,7 @@ void define_multiobjective(py::module& m, std::string const& vtSuffix) { py::arg("model"), py::arg("formula"), py::arg("compute_scheduler") = false); using PcaaWeightVectorChecker = storm::modelchecker::multiobjective::PcaaWeightVectorChecker>; - py::class_> weightedObjectiveMdpModelChecker( - m, ("WeightedObjectiveMdpModelChecker" + vtSuffix).c_str()); + py::classh weightedObjectiveMdpModelChecker(m, ("WeightedObjectiveMdpModelChecker" + vtSuffix).c_str()); weightedObjectiveMdpModelChecker.def("check", &PcaaWeightVectorChecker::check, py::arg("env"), py::arg("weight_vector")) .def("get_achievable_point", &PcaaWeightVectorChecker::getAchievablePoint) .def("get_optimal_weighted_sum", &PcaaWeightVectorChecker::getOptimalWeightedSum, diff --git a/src/core/result.cpp b/src/core/result.cpp index 8422c6f498..e69eb153a6 100644 --- a/src/core/result.cpp +++ b/src/core/result.cpp @@ -27,8 +27,7 @@ std::shared_ptr createFilterSymboli } template -void define_result_as_explicit(py::class_>& checkResult, - std::string const& vtSuffix) { +void define_result_as_explicit(py::classh& checkResult, std::string const& vtSuffix) { checkResult.def(("as_explicit" + vtSuffix + "_qualitative").c_str(), [](storm::modelchecker::CheckResult const& result) { return result.template asExplicitQualitativeCheckResult(); }, "Convert into explicit qualitative result"); @@ -40,8 +39,7 @@ void define_result_as_explicit(py::class_> checkResult(m, "_CheckResult", - "Base class for all modelchecking results"); + py::classh checkResult(m, "_CheckResult", "Base class for all modelchecking results"); checkResult.def_property_readonly("_symbolic", &storm::modelchecker::CheckResult::isSymbolic, "Flag if result is symbolic") .def_property_readonly("_hybrid", &storm::modelchecker::CheckResult::isHybrid, "Flag if result is hybrid") .def_property_readonly("_quantitative", &storm::modelchecker::CheckResult::isQuantitative, "Flag if result is quantitative") @@ -70,11 +68,10 @@ void define_result(py::module& m) { }); // QualitativeCheckResult - py::class_> qualitativeCheckResult( - m, "_QualitativeCheckResult", "Abstract class for qualitative model checking results", checkResult); + py::classh qualitativeCheckResult(m, "_QualitativeCheckResult", + "Abstract class for qualitative model checking results", checkResult); - py::class_, - std::shared_ptr>>( + py::classh>( m, "SymbolicQualitativeCheckResult", "Symbolic qualitative model checking result", qualitativeCheckResult) .def("get_truth_values", &storm::modelchecker::SymbolicQualitativeCheckResult::getTruthValuesVector, "Get Dd representing the truth values"); @@ -82,9 +79,8 @@ void define_result(py::module& m) { template void define_typed_result(py::module& m, std::string const& vtSuffix) { - py::class_, std::shared_ptr>, - storm::modelchecker::QualitativeCheckResult>(m, ("Explicit" + vtSuffix + "QualitativeCheckResult").c_str(), - "Explicit qualitative model checking result") + py::classh, storm::modelchecker::QualitativeCheckResult>( + m, ("Explicit" + vtSuffix + "QualitativeCheckResult").c_str(), "Explicit qualitative model checking result") .def( "at", [](storm::modelchecker::ExplicitQualitativeCheckResult const& result, storm::storage::sparse::state_type state) { @@ -96,15 +92,13 @@ void define_typed_result(py::module& m, std::string const& vtSuffix) { .def_property_readonly( "scheduler", [](storm::modelchecker::ExplicitQualitativeCheckResult const& res) { return res.getScheduler(); }, "Get scheduler"); - py::class_, std::shared_ptr>, - storm::modelchecker::CheckResult> - quantitativeCheckResult(m, ("_" + vtSuffix + "QuantitativeCheckResult").c_str(), "Abstract class for quantitative model checking results"); + py::classh, storm::modelchecker::CheckResult> quantitativeCheckResult( + m, ("_" + vtSuffix + "QuantitativeCheckResult").c_str(), "Abstract class for quantitative model checking results"); quantitativeCheckResult.def_property_readonly("min", &storm::modelchecker::QuantitativeCheckResult::getMin, "Minimal value") .def_property_readonly("max", &storm::modelchecker::QuantitativeCheckResult::getMax, "Maximal value"); - py::class_, - std::shared_ptr>>( - m, ("Explicit" + vtSuffix + "QuantitativeCheckResult").c_str(), "Explicit quantitative model checking result", quantitativeCheckResult) + py::classh>(m, ("Explicit" + vtSuffix + "QuantitativeCheckResult").c_str(), + "Explicit quantitative model checking result", quantitativeCheckResult) .def(py::init>(), py::arg("values")) .def( "at", @@ -118,8 +112,7 @@ void define_typed_result(py::module& m, std::string const& vtSuffix) { .def_property_readonly( "scheduler", [](storm::modelchecker::ExplicitQuantitativeCheckResult const& res) { return res.getScheduler(); }, "get scheduler"); - py::class_, - std::shared_ptr>>( + py::classh>( m, ("Symbolic" + vtSuffix + "QuantitativeCheckResult").c_str(), "Symbolic quantitative model checking result", quantitativeCheckResult) .def("clone", [](storm::modelchecker::SymbolicQuantitativeCheckResult const& dd) { @@ -127,22 +120,19 @@ void define_typed_result(py::module& m, std::string const& vtSuffix) { }) .def("get_values", &storm::modelchecker::SymbolicQuantitativeCheckResult::getValueVector); - py::class_, - std::shared_ptr>>( + py::classh>( m, ("Hybrid" + vtSuffix + "QuantitativeCheckResult").c_str(), "Hybrid quantitative model checking result", quantitativeCheckResult) .def("get_values", &storm::modelchecker::HybridQuantitativeCheckResult::getExplicitValueVector, "Get model checking result values for all states"); if constexpr (std::is_same_v || std::is_same_v) { - py::class_, std::shared_ptr>, - storm::modelchecker::CheckResult> - pccheckresult(m, (vtSuffix + "ParetoCurveCheckResult").c_str(), "Result for multiobjective model checking"); + py::classh, storm::modelchecker::CheckResult> pccheckresult( + m, (vtSuffix + "ParetoCurveCheckResult").c_str(), "Result for multiobjective model checking"); pccheckresult.def("get_underapproximation", &storm::modelchecker::ParetoCurveCheckResult::getUnderApproximation) .def("get_overapproximation", &storm::modelchecker::ParetoCurveCheckResult::getOverApproximation); - py::class_, - std::shared_ptr>> - epccheckresult(m, ("Explicit" + vtSuffix + "ParetoCurveCheckResult").c_str(), "Result for explicit multiobjective model checking", pccheckresult); + py::classh> epccheckresult( + m, ("Explicit" + vtSuffix + "ParetoCurveCheckResult").c_str(), "Result for explicit multiobjective model checking", pccheckresult); m.def(("create_filter_symbolic" + vtSuffix).c_str(), &createFilterSymbolic, "Creates a filter for the given states and a symbolic model", py::arg("model"), py::arg("states")); diff --git a/src/core/simulator.cpp b/src/core/simulator.cpp index f2bdb6323c..3af41e9717 100644 --- a/src/core/simulator.cpp +++ b/src/core/simulator.cpp @@ -9,7 +9,7 @@ using PLSim = storm::simulator::DiscreteTimePrismProgramSimulator; template void define_sparse_model_simulator(py::module& m, std::string const& vtSuffix) { - py::class_> dtsmsd(m, ("_DiscreteTimeSparseModelSimulator" + vtSuffix).c_str(), + py::classh> dtsmsd(m, ("_DiscreteTimeSparseModelSimulator" + vtSuffix).c_str(), "Simulator for sparse discrete-time models in memory (for ValueType)"); dtsmsd.def(py::init const&>()); dtsmsd.def("set_seed", &storm::simulator::DiscreteTimeSparseModelSimulator::setSeed, py::arg("seed")); @@ -22,7 +22,7 @@ void define_sparse_model_simulator(py::module& m, std::string const& vtSuffix) { template void define_prism_program_simulator(py::module& m, std::string const& vtSuffix) { - py::class_> dtpps(m, ("_DiscreteTimePrismProgramSimulator" + vtSuffix).c_str(), + py::classh> dtpps(m, ("_DiscreteTimePrismProgramSimulator" + vtSuffix).c_str(), "Simulator for prism programs"); dtpps.def(py::init(), py::arg("program"), py::arg("options")); dtpps.def("set_seed", &storm::simulator::DiscreteTimePrismProgramSimulator::setSeed, py::arg("seed")); diff --git a/src/core/transformation.cpp b/src/core/transformation.cpp index 8d64d91020..e71d62aa6e 100644 --- a/src/core/transformation.cpp +++ b/src/core/transformation.cpp @@ -55,7 +55,7 @@ void define_transformation(py::module& m) { define_transformation_mdef(m); define_transformation_mdef(m); - py::class_(m, "SubsystemBuilderOptions", "Options for constructing the subsystem") + py::classh(m, "SubsystemBuilderOptions", "Options for constructing the subsystem") .def(py::init<>()) .def_readwrite("check_transitions_outside", &storm::transformer::SubsystemBuilderOptions::checkTransitionsOutside) .def_readwrite("build_state_mapping", &storm::transformer::SubsystemBuilderOptions::buildStateMapping) @@ -74,7 +74,7 @@ void define_transformation(py::module& m) { template void define_transformation_typed(py::module& m, std::string const& vtSuffix) { - py::class_>(m, ("SubsystemBuilderReturnType" + vtSuffix).c_str(), + py::classh>(m, ("SubsystemBuilderReturnType" + vtSuffix).c_str(), "Result of the construction of a subsystem") .def_readonly("model", &storm::transformer::SubsystemBuilderReturnType::model, "the submodel") .def_readonly("new_to_old_state_mapping", &storm::transformer::SubsystemBuilderReturnType::newToOldStateIndexMapping, @@ -87,7 +87,7 @@ void define_transformation_typed(py::module& m, std::string const& vtSuffix) { "If set, deadlock states have been introduced and have been assigned this label"); m.def(("_construct_subsystem_" + vtSuffix).c_str(), &constructSubsystem, "build a subsystem of a sparse model"); - py::class_::EndComponentEliminatorReturnType>( + py::classh::EndComponentEliminatorReturnType>( m, ("EndComponentEliminatorReturnType" + vtSuffix).c_str(), "Container for result of endcomponent elimination") .def_readonly("matrix", &storm::transformer::EndComponentEliminator::EndComponentEliminatorReturnType::matrix, "The resulting matrix") .def_readonly("new_to_old_row_mapping", &storm::transformer::EndComponentEliminator::EndComponentEliminatorReturnType::newToOldRowMapping, @@ -103,7 +103,7 @@ void define_transformation_typed(py::module& m, std::string const& vtSuffix) { template void define_transformation_typed_only_numbers(py::module& m, std::string const& vtSuffix) { - py::class_>(m, ("AddUncertainty" + vtSuffix).c_str(), + py::classh>(m, ("AddUncertainty" + vtSuffix).c_str(), "Transform model into interval model with specified uncertainty") .def(py::init> const&>(), py::arg("model")) .def("transform", &storm::transformer::AddUncertainty::transform, "Transform the model", py::arg("additive_uncertainty"), diff --git a/src/dft/analysis.cpp b/src/dft/analysis.cpp index 7599e7cbfe..623f7d4c59 100644 --- a/src/dft/analysis.cpp +++ b/src/dft/analysis.cpp @@ -42,8 +42,7 @@ void define_analysis(py::module& m) { .finalize(); // RelevantEvents - py::class_>(m, "RelevantEvents", - "Relevant events which should be observed") + py::classh(m, "RelevantEvents", "Relevant events which should be observed") .def(py::init<>(), "Create empty list of relevant events") .def("is_relevant", &storm::dft::utility::RelevantEvents::isRelevant, "Check whether the given name is a relevant event", py::arg("name")); @@ -53,8 +52,7 @@ void define_analysis(py::module& m) { template void define_analysis_typed(py::module& m, std::string const& vt_suffix) { - py::class_, std::shared_ptr>>(m, ("ExplicitDFTModelBuilder" + vt_suffix).c_str(), - "Builder to generate explicit model from DFT") + py::classh>(m, ("ExplicitDFTModelBuilder" + vt_suffix).c_str(), "Builder to generate explicit model from DFT") .def(py::init const&, storm::dft::storage::DftSymmetries const&>(), "Constructor", py::arg("dft"), py::arg("symmetries") = storm::dft::storage::DftSymmetries()) .def("build", &ExplicitDFTModelBuilder::buildModel, "Build state space of model", py::arg("iteration"), diff --git a/src/dft/dft.cpp b/src/dft/dft.cpp index eb61ae5ff3..75dac6a772 100644 --- a/src/dft/dft.cpp +++ b/src/dft/dft.cpp @@ -36,7 +36,7 @@ void define_dft(py::module& m) { template void define_dft_typed(py::module& m, std::string const& vt_suffix) { // DFT class - py::class_, std::shared_ptr>>(m, ("DFT" + vt_suffix).c_str(), "Dynamic Fault Tree") + py::classh>(m, ("DFT" + vt_suffix).c_str(), "Dynamic Fault Tree") .def("nr_elements", &DFT::nrElements, "Total number of elements") .def("nr_be", &DFT::nrBasicElements, "Number of basic elements") .def("nr_dynamic", &DFT::nrDynamicElements, "Number of dynamic elements") @@ -64,7 +64,7 @@ void define_dft_typed(py::module& m, std::string const& vt_suffix) { } void define_symmetries(py::module& m) { - py::class_>(m, "DftSymmetries", "Symmetries in DFT") + py::classh(m, "DftSymmetries", "Symmetries in DFT") .def(py::init<>(), "Constructor for empty symmetry") .def("__len__", &storm::dft::storage::DftSymmetries::nrSymmetries) .def( diff --git a/src/dft/dft_elements.cpp b/src/dft/dft_elements.cpp index 6e62b91608..70cdb12c6c 100644 --- a/src/dft/dft_elements.cpp +++ b/src/dft/dft_elements.cpp @@ -34,16 +34,15 @@ void define_dft_elements(py::module& m) { template void define_dft_elements_typed(py::module& m, std::string const& vt_suffix) { // DFT elements - py::class_, std::shared_ptr>> element(m, ("DFTElement" + vt_suffix).c_str(), "DFT element"); + py::classh> element(m, ("DFTElement" + vt_suffix).c_str(), "DFT element"); element.def_property_readonly("id", &DFTElement::id, "Id") .def_property_readonly("name", &DFTElement::name, "Name") .def_property_readonly("type", &DFTElement::type, "Type") .def("__str__", &DFTElement::toString); - py::class_, std::shared_ptr>>(m, ("DFTBE" + vt_suffix).c_str(), "Basic Event", element) - .def("__str__", &BE::toString); + py::classh>(m, ("DFTBE" + vt_suffix).c_str(), "Basic Event", element).def("__str__", &BE::toString); - py::class_, std::shared_ptr>>(m, ("DFTDependency" + vt_suffix).c_str(), "Dependency", element) + py::classh>(m, ("DFTDependency" + vt_suffix).c_str(), "Dependency", element) .def_property_readonly("trigger", &Dependency::triggerEvent, "Trigger event") .def_property_readonly("dependent_events", &Dependency::dependentEvents, "Dependent events") .def("__str__", &Dependency::toString); diff --git a/src/dft/dft_state.cpp b/src/dft/dft_state.cpp index 0cece1f799..34367bed4c 100644 --- a/src/dft/dft_state.cpp +++ b/src/dft/dft_state.cpp @@ -14,7 +14,7 @@ typedef storm::dft::storage::FailableElements::const_iterator FailableIter; template void define_dft_state(py::module& m, std::string const& vt_suffix) { // DFT state - py::class_, std::shared_ptr>>(m, ("DFTState" + vt_suffix).c_str(), "DFT state") + py::classh>(m, ("DFTState" + vt_suffix).c_str(), "DFT state") .def("operational", &DFTState::isOperational, "Is element operational", py::arg("id")) .def( "failed", [](DFTState const& state, size_t id) { return state.hasFailed(id); }, "Is element failed", py::arg("id")) @@ -52,15 +52,15 @@ void define_failable_elements(py::module& m) { FailableIter it; }; - py::class_>(m, "FailableElements", "Failable elements in DFT state") + py::classh(m, "FailableElements", "Failable elements in DFT state") .def("__iter__", [](py::object s) { return FailableIterator(s.cast(), s); }, py::keep_alive<0, 1>()); - py::class_(m, "FailableIterator") + py::classh(m, "FailableIterator") .def( "__iter__", [](FailableIterator& it) -> FailableIterator& { return it; }, py::keep_alive<0, 1>()) .def("__next__", &FailableIterator::next, py::keep_alive<0, 1>()); - py::class_>(m, "FailableElement", "Failable element") + py::classh(m, "FailableElement", "Failable element") .def("is_due_dependency", &FailableIter::isFailureDueToDependency, "Is failure due to dependency") .def("as_be_double", &FailableIter::asBE, py::arg("dft"), "Get BE which fails") .def("as_be_ratfunc", &FailableIter::asBE, py::arg("dft"), "Get BE which fails") diff --git a/src/dft/module.cpp b/src/dft/module.cpp index f4cb0ce8a6..c224c7f37b 100644 --- a/src/dft/module.cpp +++ b/src/dft/module.cpp @@ -7,7 +7,7 @@ using DftIndependentModule = storm::dft::storage::DftIndependentModule; void define_module(py::module& m) { - py::class_>(m, "DftIndependentModule", "Independent module in DFT") + py::classh(m, "DftIndependentModule", "Independent module in DFT") .def("static", &DftIndependentModule::isStatic, "Whether the module contains only static elements (except in submodules)") .def("fully_static", &DftIndependentModule::isFullyStatic, "Whether the module contains only static elements (also in submodules)") .def("single_be", &DftIndependentModule::isSingleBE, "Whether the module consists of a single BE (trivial module)") diff --git a/src/dft/simulator.cpp b/src/dft/simulator.cpp index 50c98ae0c2..f19976cfea 100644 --- a/src/dft/simulator.cpp +++ b/src/dft/simulator.cpp @@ -24,9 +24,9 @@ void define_simulator(py::module& m) { .value("INVALID", storm::dft::simulator::SimulationTraceResult::INVALID) .value("CONTINUE", storm::dft::simulator::SimulationTraceResult::CONTINUE) .finalize(); - py::class_>(m, "DFTStateInfo", "State Generation Info for DFT"); + py::classh(m, "DFTStateInfo", "State Generation Info for DFT"); - py::class_>(m, "RandomGenerator", "Random number generator") + py::classh(m, "RandomGenerator", "Random number generator") .def_static( "create", [](unsigned int seed) -> RandomGenerator { return RandomGenerator(seed); }, py::arg("seed"), "Initialize random number generator"); } @@ -34,7 +34,7 @@ void define_simulator(py::module& m) { template void define_simulator_typed(py::module& m, std::string const& vt_suffix) { // Simulator for DFTs - py::class_, std::shared_ptr>>(m, ("DFTSimulator" + vt_suffix).c_str(), "Simulator for DFT traces") + py::classh>(m, ("DFTSimulator" + vt_suffix).c_str(), "Simulator for DFT traces") .def(py::init const&, DFTStateInfo const&, RandomGenerator&>(), py::keep_alive<1, 2>(), py::keep_alive<1, 3>(), py::keep_alive<1, 4>(), py::arg("dft"), py::arg("state_generation_info"), py::arg("generator"), "Create Simulator") .def("reset", &Simulator::resetToInitial, "Reset to initial state") diff --git a/src/dft/transformations.cpp b/src/dft/transformations.cpp index eaef552983..59fce7b4d4 100644 --- a/src/dft/transformations.cpp +++ b/src/dft/transformations.cpp @@ -8,7 +8,7 @@ using DFTInstantiator = storm::dft::transformations::DftInstantiator; void define_transformations(py::module& m) { - py::class_>(m, "DFTInstantiator", "Instantiator for parametric DFT") + py::classh(m, "DFTInstantiator", "Instantiator for parametric DFT") .def(py::init const&>(), "Initialize with parametric DFT", py::arg("dft")) .def("instantiate", &DFTInstantiator::instantiate, "Instantiate parametric DFT and obtain concrete DFT", py::arg("valuation")); } diff --git a/src/gspn/gspn.cpp b/src/gspn/gspn.cpp index d25349f899..28ee8fa166 100644 --- a/src/gspn/gspn.cpp +++ b/src/gspn/gspn.cpp @@ -30,7 +30,7 @@ void gspnToFile(GSPN const& gspn, std::string const& filepath, bool toPnpro) { void define_gspn(py::module& m) { // GSPN_Builder class - py::class_>(m, "GSPNBuilder", "Generalized Stochastic Petri Net Builder") + py::classh(m, "GSPNBuilder", "Generalized Stochastic Petri Net Builder") .def(py::init(), "Constructor") .def("set_name", &GSPNBuilder::setGspnName, "Set name of GSPN", "name"_a) @@ -106,7 +106,7 @@ void define_gspn(py::module& m) { "constants_substitution"_a = std::map()); // GSPN class - py::class_>(m, "GSPN", "Generalized Stochastic Petri Net") + py::classh(m, "GSPN", "Generalized Stochastic Petri Net") // Constructor .def(py::init const&, std::vector const&, std::vector const&, std::vector const&, std::shared_ptr const&, @@ -174,7 +174,7 @@ void define_gspn(py::module& m) { .def_static("transition_id_to_immediate_transition_id", &GSPN::transitionIdToImmediateTransitionId); // LayoutInfo class - py::class_(m, "LayoutInfo") + py::classh(m, "LayoutInfo") .def(py::init<>()) .def(py::init(), "x"_a, "y"_a, "rotation"_a = 0.0) .def_readwrite("x", &LayoutInfo::x) @@ -182,7 +182,7 @@ void define_gspn(py::module& m) { .def_readwrite("rotation", &LayoutInfo::rotation); // Place class - py::class_>(m, "Place", "Place in a GSPN") + py::classh(m, "Place", "Place in a GSPN") .def(py::init(), "id"_a) .def("get_name", &Place::getName, "Get name of this place") .def("set_name", &Place::setName, "name"_a, "Set name of this place") @@ -194,7 +194,7 @@ void define_gspn(py::module& m) { .def("has_restricted_capacity", &Place::hasRestrictedCapacity, "Is capacity of this place restricted"); // Transition class - py::class_>(m, "Transition", "Transition in a GSPN") + py::classh(m, "Transition", "Transition in a GSPN") .def(py::init<>()) .def("get_id", &Transition::getID, "Get id of this transition") .def("set_name", &Transition::setName, "name"_a, "Set name of this transition") @@ -232,7 +232,7 @@ void define_gspn(py::module& m) { ; // TimedTransition class - py::class_>(m, "TimedTransition", "TimedTransition in a GSPN") + py::classh(m, "TimedTransition", "TimedTransition in a GSPN") .def(py::init<>()) .def("get_rate", &TimedTransition::getRate, "Get rate of this transition") .def("set_rate", &TimedTransition::setRate, "rate"_a, "Set rate of this transition") @@ -245,14 +245,14 @@ void define_gspn(py::module& m) { .def("get_number_of_servers", &TimedTransition::getNumberOfServers, "Get number of servers"); // ImmediateTransition class - py::class_>(m, "ImmediateTransition", "ImmediateTransition in a GSPN") + py::classh(m, "ImmediateTransition", "ImmediateTransition in a GSPN") .def(py::init<>()) .def("get_weight", &ImmediateTransition::getWeight, "Get weight of this transition") .def("set_weight", &ImmediateTransition::setWeight, "weight"_a, "Set weight of this transition") .def("no_weight_attached", &ImmediateTransition::noWeightAttached, "True iff no weight is attached"); // TransitionPartition class - py::class_(m, "TransitionPartition") + py::classh(m, "TransitionPartition") .def(py::init<>()) .def_readwrite("priority", &TransitionPartition::priority) .def_readwrite("transitions", &TransitionPartition::transitions) diff --git a/src/gspn/gspn_io.cpp b/src/gspn/gspn_io.cpp index 1fd56a581f..539da00a2a 100644 --- a/src/gspn/gspn_io.cpp +++ b/src/gspn/gspn_io.cpp @@ -11,7 +11,7 @@ using GSPNJaniBuilder = storm::builder::JaniGSPNBuilder; void define_gspn_io(py::module& m) { // GspnParser class - py::class_>(m, "GSPNParser") + py::classh(m, "GSPNParser") .def(py::init<>()) .def( "parse", @@ -21,7 +21,7 @@ void define_gspn_io(py::module& m) { "filename"_a, "constant_definitions"_a = ""); // GspnToJani builder - py::class_>(m, "GSPNToJaniBuilder") + py::classh(m, "GSPNToJaniBuilder") .def(py::init(), py::arg("gspn")) .def("build", &GSPNJaniBuilder::build, py::arg("automaton_name") = "gspn_automaton", "Build Jani model from GSPN") .def("create_deadlock_properties", &GSPNJaniBuilder::getDeadlockProperties, py::arg("jani_model"), "Create standard properties for deadlocks"); diff --git a/src/logic/formulae.cpp b/src/logic/formulae.cpp index b621136564..b6ad53b79b 100644 --- a/src/logic/formulae.cpp +++ b/src/logic/formulae.cpp @@ -19,7 +19,7 @@ void define_formulae(py::module& m) { .value("OR", storm::logic::BinaryBooleanOperatorType::Or) .finalize(); - py::class_> formula(m, "Formula", "Generic Storm Formula"); + py::classh formula(m, "Formula", "Generic Storm Formula"); formula.def("__str__", &storm::logic::Formula::toString) .def("clone", [](storm::logic::Formula const& f) { @@ -45,21 +45,16 @@ void define_formulae(py::module& m) { .def_property_readonly("is_multi_objective_formula", &storm::logic::Formula::isMultiObjectiveFormula); // Path Formulae - py::class_> pathFormula( - m, "PathFormula", "Formula about the probability of a set of paths in an automaton", formula); - py::class_> unaryPathFormula(m, "UnaryPathFormula", - "Path formula with one operand", pathFormula); + py::classh pathFormula(m, "PathFormula", "Formula about the probability of a set of paths in an automaton", formula); + py::classh unaryPathFormula(m, "UnaryPathFormula", "Path formula with one operand", pathFormula); unaryPathFormula.def_property_readonly("subformula", &storm::logic::UnaryPathFormula::getSubformula, "the subformula"); - py::class_>(m, "EventuallyFormula", "Formula for eventually", - unaryPathFormula) + py::classh(m, "EventuallyFormula", "Formula for eventually", unaryPathFormula) .def_property_readonly("subformula", &storm::logic::EventuallyFormula::getSubformula, "the subformula"); - py::class_>(m, "GloballyFormula", "Formula for globally", unaryPathFormula); - py::class_> binaryPathFormula( - m, "BinaryPathFormula", "Path formula with two operands", pathFormula); + py::classh(m, "GloballyFormula", "Formula for globally", unaryPathFormula); + py::classh binaryPathFormula(m, "BinaryPathFormula", "Path formula with two operands", pathFormula); binaryPathFormula.def_property_readonly("left_subformula", &storm::logic::BinaryPathFormula::getLeftSubformula); binaryPathFormula.def_property_readonly("right_subformula", &storm::logic::BinaryPathFormula::getRightSubformula); - py::class_>( - m, "BoundedUntilFormula", "Until Formula with either a step or a time bound.", binaryPathFormula) + py::classh(m, "BoundedUntilFormula", "Until Formula with either a step or a time bound.", binaryPathFormula) .def_property_readonly("is_multidimensional", &storm::logic::BoundedUntilFormula::isMultiDimensional, "Is the bound multi-dimensional") .def_property_readonly("has_lower_bound", [](storm::logic::BoundedUntilFormula const& form) { return form.hasLowerBound(); }) .def_property_readonly("upper_bound_expression", [](storm::logic::BoundedUntilFormula const& form) { return form.getUpperBound(); }) @@ -69,44 +64,32 @@ void define_formulae(py::module& m) { .def_property_readonly( "right_subformula", [](storm::logic::BoundedUntilFormula const& form) -> storm::logic::Formula const& { return form.getRightSubformula(); }, py::return_value_policy::reference_internal); - py::class_>( - m, "ConditionalFormula", "Formula with the right hand side being a condition.", formula) + py::classh(m, "ConditionalFormula", "Formula with the right hand side being a condition.", formula) .def_property_readonly("main_subformula", &storm::logic::ConditionalFormula::getSubformula, "the subformula") .def_property_readonly("conditional_subformula", &storm::logic::ConditionalFormula::getConditionFormula, "the conditional subformula"); - py::class_>(m, "UntilFormula", "Path Formula for unbounded until", - binaryPathFormula); + py::classh(m, "UntilFormula", "Path Formula for unbounded until", binaryPathFormula); // Reward Path Formulae // py::class_(m, "RewardPathFormula", "Formula about the rewards of a set // of paths in an automaton", py::base()); - py::class_>(m, "CumulativeRewardFormula", - "Summed rewards over a the paths", pathFormula); - py::class_>(m, "InstantaneousRewardFormula", - "Instantaneous reward", pathFormula); - py::class_>(m, "LongRunAverageRewardFormula", - "Long run average reward", pathFormula); + py::classh(m, "CumulativeRewardFormula", "Summed rewards over a the paths", pathFormula); + py::classh(m, "InstantaneousRewardFormula", "Instantaneous reward", pathFormula); + py::classh(m, "LongRunAverageRewardFormula", "Long run average reward", pathFormula); // py::class_>(m, "ReachabilityRewardFormula", // "Reachability reward", py::base()); // State Formulae - py::class_> stateFormula(m, "StateFormula", "Formula about a state of an automaton", - formula); - py::class_>(m, "AtomicExpressionFormula", - "Formula with an atomic expression", stateFormula) + py::classh stateFormula(m, "StateFormula", "Formula about a state of an automaton", formula); + py::classh(m, "AtomicExpressionFormula", "Formula with an atomic expression", stateFormula) .def("get_expression", &storm::logic::AtomicExpressionFormula::getExpression); - py::class_>(m, "AtomicLabelFormula", "Formula with an atomic label", - stateFormula) + py::classh(m, "AtomicLabelFormula", "Formula with an atomic label", stateFormula) .def_property_readonly("label", &storm::logic::AtomicLabelFormula::getLabel, "label in the formula"); - py::class_>(m, "BooleanLiteralFormula", - "Formula with a boolean literal", stateFormula) + py::classh(m, "BooleanLiteralFormula", "Formula with a boolean literal", stateFormula) .def(py::init(), "truth value"_a); - py::class_> unaryStateFormula( - m, "UnaryStateFormula", "State formula with one operand", stateFormula); + py::classh unaryStateFormula(m, "UnaryStateFormula", "State formula with one operand", stateFormula); unaryStateFormula.def_property_readonly("subformula", &storm::logic::UnaryStateFormula::getSubformula, "the subformula"); - py::class_>( - m, "UnaryBooleanStateFormula", "Unary boolean state formula", unaryStateFormula); - py::class_> operatorFormula(m, "OperatorFormula", "Operator formula", - unaryStateFormula); + py::classh(m, "UnaryBooleanStateFormula", "Unary boolean state formula", unaryStateFormula); + py::classh operatorFormula(m, "OperatorFormula", "Operator formula", unaryStateFormula); operatorFormula.def_property_readonly("has_bound", &storm::logic::OperatorFormula::hasBound, "Flag if formula is bounded") .def_property("comparison_type", &storm::logic::OperatorFormula::getComparisonType, &storm::logic::OperatorFormula::setComparisonType, "Comparison type of bound") @@ -140,27 +123,21 @@ void define_formulae(py::module& m) { .def("remove_optimality_type", &storm::logic::OperatorFormula::removeOptimalityType, "remove the optimality type") ; - py::class_>(m, "TimeOperator", "The time operator", operatorFormula); - py::class_>( - m, "LongRunAvarageOperator", "Long run average operator", operatorFormula); - py::class_>(m, "ProbabilityOperator", - "Probability operator", operatorFormula) + py::classh(m, "TimeOperator", "The time operator", operatorFormula); + py::classh(m, "LongRunAvarageOperator", "Long run average operator", operatorFormula); + py::classh(m, "ProbabilityOperator", "Probability operator", operatorFormula) .def(py::init>(), "construct probability operator formula", py::arg("subformula")); - py::class_>(m, "RewardOperator", "Reward operator", - operatorFormula) + py::classh(m, "RewardOperator", "Reward operator", operatorFormula) .def("has_reward_name", &storm::logic::RewardOperatorFormula::hasRewardModelName) .def_property_readonly("reward_name", &storm::logic::RewardOperatorFormula::getRewardModelName); - py::class_> binaryStateFormula( - m, "BinaryStateFormula", "State formula with two operands", stateFormula); - py::class_>( - m, "BooleanBinaryStateFormula", "Boolean binary state formula", binaryStateFormula); + py::classh binaryStateFormula(m, "BinaryStateFormula", "State formula with two operands", stateFormula); + py::classh(m, "BooleanBinaryStateFormula", "Boolean binary state formula", binaryStateFormula); - py::class_>(m, "MultiObjectiveFormula", "Multi objective formula", - formula) + py::classh(m, "MultiObjectiveFormula", "Multi objective formula", formula) .def_property_readonly("subformulas", &storm::logic::MultiObjectiveFormula::getSubformulas, "Get vector of subformulas") .def_property_readonly("nr_subformulas", &storm::logic::MultiObjectiveFormula::getNumberOfSubformulas, "Get number of subformulas"); - py::class_>(m, "GameFormula", "Game formula", unaryStateFormula) + py::classh(m, "GameFormula", "Game formula", unaryStateFormula) .def_property_readonly("is_game_formula", &storm::logic::GameFormula::isGameFormula, "is it a game formula"); } diff --git a/src/mod_info.cpp b/src/mod_info.cpp index 412d0d8a58..1223397469 100644 --- a/src/mod_info.cpp +++ b/src/mod_info.cpp @@ -10,7 +10,7 @@ PYBIND11_MODULE(_info, m) { options.disable_function_signatures(); #endif - py::class_(m, "Version", "Version information for Storm") + py::classh(m, "Version", "Version information for Storm") // static properties are still called with self as argument (which we ignore), see // https://pybind11.readthedocs.io/en/stable/advanced/classes.html#static-properties .def_property_readonly_static( diff --git a/src/pars/model_instantiator.cpp b/src/pars/model_instantiator.cpp index fc946c9024..39e3ae1384 100644 --- a/src/pars/model_instantiator.cpp +++ b/src/pars/model_instantiator.cpp @@ -34,7 +34,7 @@ using namespace storm::modelchecker; // Helper: define typed ModelInstantiator class template void define_typed_instantiator(py::module& m, const char* pyName, const char* pyDesc) { - py::class_>(m, pyName, pyDesc) + py::classh>(m, pyName, pyDesc) .def(py::init(), "parametric model"_a) .def("instantiate", &storm::utility::ModelInstantiator::instantiate, "Instantiate model with given parameter values"); @@ -80,10 +80,10 @@ template void define_typed_checker(py::module& m, const char* baseName, const char* baseDesc, const char* derivedName, const char* derivedDesc) { using CheckerType = typename instantiation_checker::type; using BaseChecker = SparseInstantiationModelChecker; - auto base = py::class_>(m, baseName, baseDesc); + auto base = py::classh(m, baseName, baseDesc); base.def("specify_formula", &BaseChecker::specifyFormula, "check_task"_a); - py::class_>(m, derivedName, derivedDesc, base) + py::classh(m, derivedName, derivedDesc, base) .def(py::init(), "parametric model"_a) .def( "check", diff --git a/src/pars/pars.cpp b/src/pars/pars.cpp index f93ad96948..81ce4f919f 100644 --- a/src/pars/pars.cpp +++ b/src/pars/pars.cpp @@ -20,8 +20,7 @@ void define_pars(py::module& m) { }, "Initialize Storm-pars"); - py::class_>(m, "_SparseParametricDtmcSimplifier", - "Model simplifier for parametric DTMCs") + py::classh(m, "_SparseParametricDtmcSimplifier", "Model simplifier for parametric DTMCs") .def(py::init(), py::arg("dtmc")) .def( "simplify", [](SparseParametricDtmcSimplifier& simplifier, storm::logic::Formula const& formula) -> bool { return simplifier.simplify(formula); }, @@ -32,8 +31,7 @@ void define_pars(py::module& m) { "simplified_formula", [](SparseParametricDtmcSimplifier const& simplifier) { return simplifier.getSimplifiedFormula(); }, "Return simplified formula"); - py::class_>(m, "_SparseParametricMdpSimplifier", - "Model simplifier for parametric MDPs") + py::classh(m, "_SparseParametricMdpSimplifier", "Model simplifier for parametric MDPs") .def(py::init(), py::arg("mdp")) .def( "simplify", [](SparseParametricMdpSimplifier& simplifier, storm::logic::Formula const& formula) -> bool { return simplifier.simplify(formula); }, diff --git a/src/pars/pla.cpp b/src/pars/pla.cpp index b4f6893d5b..b8742032d0 100644 --- a/src/pars/pla.cpp +++ b/src/pars/pla.cpp @@ -120,7 +120,7 @@ void define_pla(py::module& m) { py::name("friendly_name"), py::is_method(m.attr("RegionResultHypothesis"))); // Region - py::class_>(m, "ParameterRegion", "Parameter region") + py::classh(m, "ParameterRegion", "Parameter region") .def(py::init([](std::map> valuation) { Region::Valuation lowerValuation; Region::Valuation upperValuation; @@ -141,8 +141,7 @@ void define_pla(py::module& m) { .def("__str__", &streamToString); // RegionModelChecker - py::class_> regionModelChecker(m, "RegionModelChecker", - "Region model checker via paramater lifting"); + py::classh regionModelChecker(m, "RegionModelChecker", "Region model checker via paramater lifting"); regionModelChecker .def("check_region", &checkRegion, "Check region", py::arg("environment"), py::arg("region"), py::arg("hypothesis") = storm::modelchecker::RegionResultHypothesis::Unknown, py::arg("sampleVertices") = false) @@ -152,7 +151,7 @@ void define_pla(py::module& m) { py::arg("splitting_estimate") = std::nullopt, py::arg("allow_model_simplification") = true, py::arg("graph_preserving") = true); // RegionRefinementChecker - py::class_>(m, "RegionRefinementChecker", "Region refinement checker") + py::classh(m, "RegionRefinementChecker", "Region refinement checker") .def("specify", &specifyRefinementChecker, "specify arguments", py::arg("environment"), py::arg("model"), py::arg("formula"), py::arg("allow_model_simplification") = true, py::arg("graph_preserving") = true) .def( @@ -165,12 +164,10 @@ void define_pla(py::module& m) { "Compute extremum value and point with precision", py::arg("environment"), py::arg("region"), py::arg("extremum_direction"), py::arg("precision"), py::arg("precision_absolute") = false); - py::class_>(m, "DtmcParameterLiftingModelChecker", - "Region model checker for DTMCs", regionModelChecker) + py::classh(m, "DtmcParameterLiftingModelChecker", "Region model checker for DTMCs", regionModelChecker) .def(py::init<>()) .def("get_bound_all_states", &getBound_dtmc, "Get bound", py::arg("environment"), py::arg("region"), py::arg("maximise") = true); - py::class_>(m, "MdpParameterLiftingModelChecker", - "Region model checker for MPDs", regionModelChecker) + py::classh(m, "MdpParameterLiftingModelChecker", "Region model checker for MPDs", regionModelChecker) .def(py::init<>()) .def("get_bound_all_states", &getBound_mdp, "Get bound", py::arg("environment"), py::arg("region"), py::arg("maximise") = true); diff --git a/src/pomdp/generator.cpp b/src/pomdp/generator.cpp index 900ef27bbb..05d351dcfd 100644 --- a/src/pomdp/generator.cpp +++ b/src/pomdp/generator.cpp @@ -19,8 +19,8 @@ using GenerateMonitorVerifierOptions = typename storm::generator::GenerateMonito template void define_verimon_generator(py::module &m, std::string const &vtSuffix) { - py::class_, std::shared_ptr>> mv( - m, ("MonitorVerifier" + vtSuffix).c_str(), "Container for monitor verifier POMDP with associated objects"); + py::classh> mv(m, ("MonitorVerifier" + vtSuffix).c_str(), + "Container for monitor verifier POMDP with associated objects"); mv.def(py::init &, const std::map, uint32_t> &, const std::map &>(), py::arg("product"), py::arg("observation_map"), py::arg("default_action_map")); mv.def("get_product", &storm::generator::MonitorVerifier::getProduct, py::return_value_policy::reference_internal); @@ -28,7 +28,7 @@ void define_verimon_generator(py::module &m, std::string const &vtSuffix) { mv.def_property_readonly("default_action_map", &storm::generator::MonitorVerifier::getObservationDefaultAction, py::return_value_policy::reference_internal); - py::class_> gmv(m, ("GenerateMonitorVerifier" + vtSuffix).c_str(), + py::classh> gmv(m, ("GenerateMonitorVerifier" + vtSuffix).c_str(), "Generator of POMDP used in verifying monitors against markov chains"); gmv.def(py::init const &, SparseMdp const &, std::shared_ptr &, GenerateMonitorVerifierOptions const &>(), @@ -36,7 +36,7 @@ void define_verimon_generator(py::module &m, std::string const &vtSuffix) { gmv.def("create_product", &storm::generator::GenerateMonitorVerifier::createProduct, "Create the verification POMDP"); gmv.def("set_risk", &storm::generator::GenerateMonitorVerifier::setRisk, py::arg("risk")); - py::class_> gmvopts(m, ("GenerateMonitorVerifier" + vtSuffix + "Options").c_str(), + py::classh> gmvopts(m, ("GenerateMonitorVerifier" + vtSuffix + "Options").c_str(), "Options for corresponding generator"); gmvopts.def(py::init<>()); gmvopts.def_readwrite("accepting_label", &GenerateMonitorVerifierOptions::acceptingLabel); diff --git a/src/pomdp/memory.cpp b/src/pomdp/memory.cpp index f5fb9166a3..ed558a247c 100644 --- a/src/pomdp/memory.cpp +++ b/src/pomdp/memory.cpp @@ -5,7 +5,7 @@ #include "src/helpers.h" void define_memory(py::module& m) { - py::class_ memory(m, "PomdpMemory", "Memory for POMDP policies"); + py::classh memory(m, "PomdpMemory", "Memory for POMDP policies"); memory.def_property_readonly("nr_states", &storm::storage::PomdpMemory::getNumberOfStates, "How many states does the memory structure have"); // Trivial, FixedCounter, SelectiveCounter, FixedRing, SelectiveRing, SettableBits, Full @@ -19,7 +19,7 @@ void define_memory(py::module& m) { .value("full", storm::storage::PomdpMemoryPattern::Full) .finalize(); - py::class_ memorybuilder(m, "PomdpMemoryBuilder", "MemoryBuilder for POMDP policies"); + py::classh memorybuilder(m, "PomdpMemoryBuilder", "MemoryBuilder for POMDP policies"); memorybuilder.def(py::init<>()); memorybuilder.def("build", &storm::storage::PomdpMemoryBuilder::build, py::arg("pattern"), py::arg("nr_states")); } \ No newline at end of file diff --git a/src/pomdp/qualitative_analysis.cpp b/src/pomdp/qualitative_analysis.cpp index 0ecfb6332f..77042f70fa 100644 --- a/src/pomdp/qualitative_analysis.cpp +++ b/src/pomdp/qualitative_analysis.cpp @@ -41,14 +41,14 @@ void define_qualitative_policy_search(py::module& m, std::string const& vtSuffix py::arg("formula"), py::arg("options")); m.def(("prepare_pomdp_for_qualitative_search_" + vtSuffix).c_str(), &preparePOMDPForQualitativeSearch, "Preprocess POMDP", py::arg("pomdp"), py::arg("formula")); - py::class_, std::shared_ptr>> mssq( - m, ("IterativeQualitativeSearchSolver" + vtSuffix).c_str(), "Solver for POMDPs that solves qualitative queries"); + py::classh> mssq(m, ("IterativeQualitativeSearchSolver" + vtSuffix).c_str(), + "Solver for POMDPs that solves qualitative queries"); mssq.def("compute_winning_region", &storm::pomdp::IterativePolicySearch::computeWinningRegion, py::arg("lookahead")); mssq.def("compute_winning_policy_for_initial_states", &storm::pomdp::IterativePolicySearch::analyzeForInitialStates, py::arg("lookahead")); mssq.def_property_readonly("last_winning_region", &storm::pomdp::IterativePolicySearch::getLastWinningRegion, "get the last computed winning region"); - py::class_> wrqi(m, ("BeliefSupportWinningRegionQueryInterface" + vtSuffix).c_str()); + py::classh> wrqi(m, ("BeliefSupportWinningRegionQueryInterface" + vtSuffix).c_str()); wrqi.def(py::init const&, storm::pomdp::WinningRegion const&>(), py::arg("pomdp"), py::arg("BeliefSupportWinningRegion")); wrqi.def("query_current_belief", &storm::pomdp::WinningRegionQueryInterface::isInWinningRegion, py::arg("current_belief")); wrqi.def("query_action", &storm::pomdp::WinningRegionQueryInterface::staysInWinningRegion, py::arg("current_belief"), py::arg("action")); @@ -57,10 +57,10 @@ void define_qualitative_policy_search(py::module& m, std::string const& vtSuffix template void define_qualitative_policy_search(py::module& m, std::string const& vtSuffix); void define_qualitative_policy_search_nt(py::module& m) { - py::class_ mssqopts(m, "IterativeQualitativeSearchOptions", "Options for the IterativeQualitativeSearch"); + py::classh mssqopts(m, "IterativeQualitativeSearchOptions", "Options for the IterativeQualitativeSearch"); mssqopts.def(py::init<>()); - py::class_ winningRegion(m, "BeliefSupportWinningRegion"); + py::classh winningRegion(m, "BeliefSupportWinningRegion"); winningRegion.def_static("load_from_file", &storm::pomdp::WinningRegion::loadFromFile, py::arg("filepath")); winningRegion.def("store_to_file", &storm::pomdp::WinningRegion::storeToFile, py::arg("filepath"), py::arg("preamble"), py::arg("append") = false); } diff --git a/src/pomdp/quantitative_analysis.cpp b/src/pomdp/quantitative_analysis.cpp index 7b1cc1243c..cef8cdbbb2 100644 --- a/src/pomdp/quantitative_analysis.cpp +++ b/src/pomdp/quantitative_analysis.cpp @@ -20,7 +20,7 @@ using additionalCutoffValueType = std::vector void define_belief_exploration(py::module& m, std::string const& vtSuffix) { - py::class_> belmc(m, ("BeliefExplorationModelChecker" + vtSuffix).c_str()); + py::classh> belmc(m, ("BeliefExplorationModelChecker" + vtSuffix).c_str()); belmc.def(py::init>, Options>(), py::arg("model"), py::arg("options")); belmc.def( @@ -52,10 +52,10 @@ void define_belief_exploration(py::module& m, std::string const& vtSuffix) { belmc.def("has_converged", &BeliefExplorationPomdpModelChecker::hasConverged); belmc.def("set_fsc_values", &BeliefExplorationPomdpModelChecker::setFMSchedValueList, py::arg("value_list")); - py::class_, ValueType>> belmdpexpl(m, ("BeliefMdpExplorer" + vtSuffix).c_str()); + py::classh, ValueType>> belmdpexpl(m, ("BeliefMdpExplorer" + vtSuffix).c_str()); belmdpexpl.def("set_fsc_values", &storm::builder::BeliefMdpExplorer, ValueType>::setFMSchedValueList, py::arg("value_list")); - py::class_> belexploptions(m, ("BeliefExplorationModelCheckerOptions" + vtSuffix).c_str()); + py::classh> belexploptions(m, ("BeliefExplorationModelCheckerOptions" + vtSuffix).c_str()); belexploptions.def(py::init(), py::arg("discretize"), py::arg("unfold")); belexploptions.def_readwrite("use_state_elimination_cutoff", &Options::useStateEliminationCutoff); belexploptions.def_readwrite("size_threshold_init", &Options::sizeThresholdInit); @@ -72,7 +72,7 @@ void define_belief_exploration(py::module& m, std::string const& vtSuffix) { belexploptions.def_readwrite("interactive_unfolding", &Options::interactiveUnfolding); belexploptions.def_readwrite("cut_zero_gap", &Options::cutZeroGap); - py::class_::Result> belexplres(m, ("BeliefExplorationPomdpModelCheckerResult" + vtSuffix).c_str()); + py::classh::Result> belexplres(m, ("BeliefExplorationPomdpModelCheckerResult" + vtSuffix).c_str()); belexplres.def_readonly("induced_mc_from_scheduler", &BeliefExplorationPomdpModelChecker::Result::schedulerAsMarkovChain); belexplres.def_readonly("cutoff_schedulers", &BeliefExplorationPomdpModelChecker::Result::cutoffSchedulers); belexplres.def_readonly("lower_bound", &BeliefExplorationPomdpModelChecker::Result::lowerBound); diff --git a/src/pomdp/tracker.cpp b/src/pomdp/tracker.cpp index 2a4c6d3329..eeb1018a74 100644 --- a/src/pomdp/tracker.cpp +++ b/src/pomdp/tracker.cpp @@ -16,25 +16,25 @@ using NDPomdpTrackerSparse = storm::generator::NondeterministicBeliefTracker void define_tracker(py::module& m, std::string const& vtSuffix) { - py::class_> tracker(m, ("BeliefSupportTracker" + vtSuffix).c_str(), "Tracker for BeliefSupports"); + py::classh> tracker(m, ("BeliefSupportTracker" + vtSuffix).c_str(), "Tracker for BeliefSupports"); tracker.def(py::init const&>(), py::arg("pomdp")); tracker.def("get_current_belief_support", &SparsePomdpTracker::getCurrentBeliefSupport, "What is the support given the trace so far"); tracker.def("track", &SparsePomdpTracker::track, py::arg("action"), py::arg("observation")); - py::class_> sbel(m, ("SparseBeliefState" + vtSuffix).c_str(), "Belief state in sparse format"); + py::classh> sbel(m, ("SparseBeliefState" + vtSuffix).c_str(), "Belief state in sparse format"); sbel.def("get", &storm::generator::SparseBeliefState::get, py::arg("state")); sbel.def_property_readonly("risk", &storm::generator::SparseBeliefState::getRisk); sbel.def("__str__", &storm::generator::SparseBeliefState::toString); sbel.def_property_readonly("is_valid", &storm::generator::SparseBeliefState::isValid); - py::class_::Options> opts(m, ("NondeterministicBeliefTracker" + vtSuffix + "SparseOptions").c_str(), + py::classh::Options> opts(m, ("NondeterministicBeliefTracker" + vtSuffix + "SparseOptions").c_str(), "Options for the corresponding tracker"); opts.def(py::init<>()); opts.def_readwrite("track_timeout", &NDPomdpTrackerSparse::Options::trackTimeOut); opts.def_readwrite("reduction_timeout", &NDPomdpTrackerSparse::Options::timeOut); opts.def_readwrite("reduction_wiggle", &NDPomdpTrackerSparse::Options::wiggle); - py::class_> ndetbelieftracker(m, ("NondeterministicBeliefTracker" + vtSuffix + "Sparse").c_str(), + py::classh> ndetbelieftracker(m, ("NondeterministicBeliefTracker" + vtSuffix + "Sparse").c_str(), "Tracker for belief states and uncontrollable actions"); ndetbelieftracker.def(py::init const&, typename NDPomdpTrackerSparse::Options>(), py::arg("pomdp"), py::arg("options")); ndetbelieftracker.def("reset", &NDPomdpTrackerSparse::reset); diff --git a/src/pomdp/transformations.cpp b/src/pomdp/transformations.cpp index c17bbe5a16..c621d07dad 100644 --- a/src/pomdp/transformations.cpp +++ b/src/pomdp/transformations.cpp @@ -55,7 +55,7 @@ void define_transformations_nt(py::module &m) { .value("simple_log", storm::transformer::PomdpFscApplicationMode::SIMPLE_LOG) .value("full", storm::transformer::PomdpFscApplicationMode::FULL) .finalize(); - py::class_ options(m, "ObservationTraceUnfolderOptions", "Options for unfolding observation traces"); + py::classh options(m, "ObservationTraceUnfolderOptions", "Options for unfolding observation traces"); options.def(py::init<>()); options.def_readwrite("restart_semantics", &storm::pomdp::ObservationTraceUnfolderOptions::useRestartSemantics, "Use restart semantics instead of a sink state"); @@ -73,7 +73,7 @@ void define_transformations(py::module &m, std::string const &vtSuffix) { template void define_transformations_int(py::module &m, std::string const &vtSuffix) { - py::class_> unfolder(m, ("ObservationTraceUnfolder" + vtSuffix).c_str(), + py::classh> unfolder(m, ("ObservationTraceUnfolder" + vtSuffix).c_str(), "Unfolds observation traces in models"); unfolder.def(py::init, std::vector const &, std::shared_ptr, storm::pomdp::ObservationTraceUnfolderOptions const &>(), diff --git a/src/pycarl/core/monomial.cpp b/src/pycarl/core/monomial.cpp index 90602ceabf..7cc9eb30cd 100644 --- a/src/pycarl/core/monomial.cpp +++ b/src/pycarl/core/monomial.cpp @@ -4,7 +4,7 @@ #include "src/pycarl/types.h" void define_monomial(py::module& m) { - py::class_>(m, "Monomial") + py::classh(m, "Monomial") .def("__pow__", [](const Monomial::Arg& var, carl::uint exp) { return var->pow(exp); }) .def("__mul__", static_cast(&carl::operator*)) diff --git a/src/pycarl/core/variable.cpp b/src/pycarl/core/variable.cpp index f0d8097075..3f93c74a84 100644 --- a/src/pycarl/core/variable.cpp +++ b/src/pycarl/core/variable.cpp @@ -27,7 +27,7 @@ void define_variabletype(py::module& m) { } void define_variable(py::module& m) { - py::class_(m, "Variable") + py::classh(m, "Variable") .def(py::init(), py::arg("other")) .def(py::init([](std::string name, carl::VariableType type) { return freshVariable(name, type); }), py::arg("name"), py::arg("type") = carl::VariableType::VT_REAL) diff --git a/src/pycarl/typed_core/factorization.cpp b/src/pycarl/typed_core/factorization.cpp index 16f29b061a..7a6530cf93 100644 --- a/src/pycarl/typed_core/factorization.cpp +++ b/src/pycarl/typed_core/factorization.cpp @@ -4,15 +4,14 @@ #include "src/pycarl/types.h" void define_factorizationcache(py::module& m) { - py::class_, std::shared_ptr>>(m, "_FactorizationCache", - "Cache storing all factorized polynomials") + py::classh>(m, "_FactorizationCache", "Cache storing all factorized polynomials") .def(py::init(), "Constructor") .def(py::pickle([](const carl::Cache& val) -> std::tuple { throw NoPickling(); }, [](const std::tuple& data) -> std::shared_ptr> { throw NoPickling(); })); } void define_factorization(py::module& m) { - py::class_>(m, "Factorization", "Factorization") + py::classh(m, "Factorization", "Factorization") .def("__str__", &streamToString) .def(py::self == py::self) diff --git a/src/pycarl/typed_core/factorizedpolynomial.cpp b/src/pycarl/typed_core/factorizedpolynomial.cpp index 1a33074c2d..7277411acb 100644 --- a/src/pycarl/typed_core/factorizedpolynomial.cpp +++ b/src/pycarl/typed_core/factorizedpolynomial.cpp @@ -4,7 +4,7 @@ #include "src/pycarl/types.h" void define_factorizedpolynomial(py::module& m) { - py::class_(m, "FactorizedPolynomial", "Represent a polynomial with its factorization") + py::classh(m, "FactorizedPolynomial", "Represent a polynomial with its factorization") .def(py::init(), py::arg("number"), "Constructor") .def(py::init>&>(), py::arg("polynomial"), py::arg("cache"), "Constructor") diff --git a/src/pycarl/typed_core/factorizedrationalfunction.cpp b/src/pycarl/typed_core/factorizedrationalfunction.cpp index bcf125790d..a735e74fe5 100644 --- a/src/pycarl/typed_core/factorizedrationalfunction.cpp +++ b/src/pycarl/typed_core/factorizedrationalfunction.cpp @@ -4,7 +4,7 @@ #include "src/pycarl/types.h" void define_factorizedrationalfunction(py::module& m) { - py::class_(m, "FactorizedRationalFunction", + py::classh(m, "FactorizedRationalFunction", "Represent a rational function, that is the fraction of two factorized polynomials ") .def(py::init()) .def(py::init()) diff --git a/src/pycarl/typed_core/integer.cpp b/src/pycarl/typed_core/integer.cpp index fc47e76551..8e6006f068 100644 --- a/src/pycarl/typed_core/integer.cpp +++ b/src/pycarl/typed_core/integer.cpp @@ -9,7 +9,7 @@ void define_cln_integer(py::module& m) { #ifdef PYCARL_USE_CLN - py::class_(m, "Integer", "Class wrapping cln-integers") + py::classh(m, "Integer", "Class wrapping cln-integers") .def(py::init()) .def(py::init([](std::string const& val) { cln::cl_I tmp; @@ -83,7 +83,7 @@ void define_cln_integer(py::module& m) { void define_gmp_integer(py::module& m) { #ifndef PYCARL_USE_CLN - py::class_(m, "Integer", "Class wrapping gmp-integers") + py::classh(m, "Integer", "Class wrapping gmp-integers") .def(py::init()) .def(py::init([](std::string const& val) { mpz_class tmp; diff --git a/src/pycarl/typed_core/interval.h b/src/pycarl/typed_core/interval.h index e77edad5dc..b74ab67462 100644 --- a/src/pycarl/typed_core/interval.h +++ b/src/pycarl/typed_core/interval.h @@ -8,7 +8,7 @@ template void define_interval(py::module& m) { using Interval = carl::Interval; - py::class_(m, "Interval") + py::classh(m, "Interval") .def(py::init()) .def(py::init()) .def(py::init()) diff --git a/src/pycarl/typed_core/polynomial.cpp b/src/pycarl/typed_core/polynomial.cpp index ca3f19e346..a78b90d362 100644 --- a/src/pycarl/typed_core/polynomial.cpp +++ b/src/pycarl/typed_core/polynomial.cpp @@ -4,7 +4,7 @@ #include "src/pycarl/types.h" void define_polynomial(py::module& m) { - py::class_(m, "Polynomial", "Represent a multivariate polynomial") + py::classh(m, "Polynomial", "Represent a multivariate polynomial") .def(py::init()) .def(py::init()) .def(py::init()) diff --git a/src/pycarl/typed_core/rational.cpp b/src/pycarl/typed_core/rational.cpp index a9a9563e2d..f3603eb624 100644 --- a/src/pycarl/typed_core/rational.cpp +++ b/src/pycarl/typed_core/rational.cpp @@ -72,7 +72,7 @@ static cln::cl_I pyint_to_cl_I(py::int_ val) { void define_cln_rational(py::module& m) { #ifdef PYCARL_USE_CLN - py::class_(m, "Rational", "Class wrapping cln-rational numbers") + py::classh(m, "Rational", "Class wrapping cln-rational numbers") .def(py::init([](double val) { return carl::rationalize(val); })) .def(py::init([](carl::sint val) { return carl::rationalize(val); })) .def(py::init([](const cln::cl_I& numerator, const cln::cl_I& denominator) { return cln::cl_RA(numerator) / cln::cl_RA(denominator); })) @@ -189,7 +189,7 @@ void define_cln_rational(py::module& m) { void define_gmp_rational(py::module& m) { #ifndef PYCARL_USE_CLN - py::class_(m, "Rational", "Class wrapping gmp-rational numbers") + py::classh(m, "Rational", "Class wrapping gmp-rational numbers") .def(py::init([](double val) { return carl::rationalize(val); })) .def(py::init([](carl::sint val) { return carl::rationalize(val); })) .def(py::init()) diff --git a/src/pycarl/typed_core/rationalfunction.cpp b/src/pycarl/typed_core/rationalfunction.cpp index b9475336cf..110231f921 100644 --- a/src/pycarl/typed_core/rationalfunction.cpp +++ b/src/pycarl/typed_core/rationalfunction.cpp @@ -4,7 +4,7 @@ #include "src/pycarl/types.h" void define_rationalfunction(py::module& m) { - py::class_(m, "RationalFunction", "Represent a rational function, that is the fraction of two multivariate polynomials ") + py::classh(m, "RationalFunction", "Represent a rational function, that is the fraction of two multivariate polynomials ") .def(py::init()) .def(py::init()) .def(py::init()) diff --git a/src/pycarl/typed_core/term.cpp b/src/pycarl/typed_core/term.cpp index caab76abf3..a2912a60d7 100644 --- a/src/pycarl/typed_core/term.cpp +++ b/src/pycarl/typed_core/term.cpp @@ -4,7 +4,7 @@ #include "src/pycarl/types.h" void define_term(py::module& m) { - py::class_(m, "Term") + py::classh(m, "Term") .def(py::init()) .def(py::init()) .def(py::init()) diff --git a/src/pycarl/typed_formula/constraint.cpp b/src/pycarl/typed_formula/constraint.cpp index a380b44c09..2425aaa4b4 100644 --- a/src/pycarl/typed_formula/constraint.cpp +++ b/src/pycarl/typed_formula/constraint.cpp @@ -4,7 +4,7 @@ // void define_constraint(py::module& m) { - py::class_(m, "Constraint") + py::classh(m, "Constraint") .def(py::init()) .def(py::init(), py::arg("var"), py::arg("rel"), py::arg("bound")) .def(py::init()) @@ -29,7 +29,7 @@ void define_constraint(py::module& m) { } // void define_simple_constraint(py::module& m) { - py::class_(m, "SimpleConstraint") + py::classh(m, "SimpleConstraint") .def(py::init()) .def(py::init()) .def("__str__", &streamToString) @@ -39,7 +39,7 @@ void define_simple_constraint(py::module& m) { .def(py::pickle([](const SimpleConstraint& val) -> std::tuple { throw NoPickling(); }, [](const std::tuple& data) -> SimpleConstraint { throw NoPickling(); })); - py::class_(m, "SimpleConstraintRatFunc") + py::classh(m, "SimpleConstraintRatFunc") .def(py::init()) .def(py::init()) .def("__str__", &streamToString) diff --git a/src/pycarl/typed_formula/formula.cpp b/src/pycarl/typed_formula/formula.cpp index 1f1b44358e..70ca341049 100644 --- a/src/pycarl/typed_formula/formula.cpp +++ b/src/pycarl/typed_formula/formula.cpp @@ -3,7 +3,7 @@ #include "src/pycarl/typed_formula/common.h" void define_formula(py::module& m) { - py::class_(m, "Formula") + py::classh(m, "Formula") .def(py::init(), "Create Formula given Boolean variable") .def(py::init()) .def(py::init()) diff --git a/src/storage/bitvector.cpp b/src/storage/bitvector.cpp index cc9656eb10..46a32a65c2 100644 --- a/src/storage/bitvector.cpp +++ b/src/storage/bitvector.cpp @@ -7,7 +7,7 @@ void define_bitvector(py::module& m) { using BitVector = storm::storage::BitVector; - py::class_(m, "BitVector") + py::classh(m, "BitVector") .def(py::init<>()) .def(py::init(), "other"_a) .def(py::init(), "length"_a) diff --git a/src/storage/choiceorigins.cpp b/src/storage/choiceorigins.cpp index 78a3d1d5f9..a4e2fd38af 100644 --- a/src/storage/choiceorigins.cpp +++ b/src/storage/choiceorigins.cpp @@ -10,8 +10,7 @@ using JaniChoiceOrigins = storm::storage::sparse::JaniChoiceOrigins; using PrismChoiceOrigins = storm::storage::sparse::PrismChoiceOrigins; void define_origins(py::module& m) { - py::class_> co(m, "ChoiceOrigins", - "This class represents the origin of choices of a model in terms of the input model spec."); + py::classh co(m, "ChoiceOrigins", "This class represents the origin of choices of a model in terms of the input model spec."); co.def("is_prism_choice_origins", &ChoiceOrigins::isPrismChoiceOrigins) .def("is_jani_choice_origins", &ChoiceOrigins::isJaniChoiceOrigins) .def("as_prism_choice_origins", [](ChoiceOrigins& co) -> PrismChoiceOrigins& { return co.asPrismChoiceOrigins(); }) @@ -20,8 +19,7 @@ void define_origins(py::module& m) { .def("get_choice_info", &ChoiceOrigins::getChoiceInfo, "identifier"_a, "human readable string") .def("get_number_of_identifiers", &ChoiceOrigins::getNumberOfIdentifiers, "the number of considered identifier"); - py::class_>(m, "JaniChoiceOrigins", - "This class represents for each choice the origin in the jani spec.", co) + py::classh(m, "JaniChoiceOrigins", "This class represents for each choice the origin in the jani spec.", co) .def(py::init const&, std::vector const&, std::vector const&>(), "jani_model"_a, "index_to_identifier_mapping"_a, "identifier_to_edge_index__set_mapping"_a) @@ -30,8 +28,7 @@ void define_origins(py::module& m) { "get_edge_index_set", [](JaniChoiceOrigins const& co, uint64_t choice) -> auto& { return co.getEdgeIndexSet(choice); }, "returns the set of edges that induced the choice", py::arg("choice_index")); - py::class_>( - m, "PrismChoiceOrigins", "This class represents for each choice the set of prism commands that induced the choice.", co) + py::classh(m, "PrismChoiceOrigins", "This class represents for each choice the set of prism commands that induced the choice.", co) .def(py::init const&, std::vector const&, std::vector const&>(), "prism_program"_a, "index_to_identifier_mapping"_a, "identifier_to_command_set_mapping"_a) diff --git a/src/storage/dd.cpp b/src/storage/dd.cpp index 201cc4e54a..ac15cd9e2e 100644 --- a/src/storage/dd.cpp +++ b/src/storage/dd.cpp @@ -9,38 +9,38 @@ #include "src/helpers.h" template -py::class_> define_dd(py::module& m, std::string const& libstring) { - py::class_> ddMetaVariable(m, (std::string("DdMetaVariable_") + libstring).c_str()); +py::classh> define_dd(py::module& m, std::string const& libstring) { + py::classh> ddMetaVariable(m, (std::string("DdMetaVariable_") + libstring).c_str()); ddMetaVariable.def("compute_indices", &storm::dd::DdMetaVariable::getIndices, py::arg("sorted") = true); ddMetaVariable.def_property_readonly("name", &storm::dd::DdMetaVariable::getName); ddMetaVariable.def_property_readonly("lowest_value", &storm::dd::DdMetaVariable::getLow); ddMetaVariable.def_property_readonly("type", &storm::dd::DdMetaVariable::getType); ddMetaVariable.def("__str__", &storm::dd::DdMetaVariable::getName); - py::class_, std::shared_ptr>> ddManager(m, (std::string("DdManager_") + libstring).c_str()); + py::classh> ddManager(m, (std::string("DdManager_") + libstring).c_str()); ddManager.def( "get_meta_variable", [](storm::dd::DdManager const& manager, storm::expressions::Variable const& var) { return manager.getMetaVariable(var); }, py::arg("expression_variable")); - py::class_> dd(m, (std::string("Dd_") + libstring).c_str(), "Dd"); + py::classh> dd(m, (std::string("Dd_") + libstring).c_str(), "Dd"); dd.def_property_readonly("node_count", &storm::dd::Dd::getNodeCount, "get node count"); dd.def_property_readonly("dd_manager", &storm::dd::Dd::getDdManager, "get the manager"); dd.def_property_readonly("meta_variables", [](storm::dd::Dd const& dd) { return dd.getContainedMetaVariables(); }, "the contained meta variables"); - py::class_> bdd(m, (std::string("Bdd_") + libstring).c_str(), "Bdd", dd); + py::classh> bdd(m, (std::string("Bdd_") + libstring).c_str(), "Bdd", dd); bdd.def("to_expression", &storm::dd::Bdd::toExpression, py::arg("expression_manager")); return dd; } template -void define_dd_typed(py::module& m, std::string const& libstring, std::string const& valueSuffix, py::class_> const& dd) { - py::class_> add(m, (std::string("Add_") + libstring + valueSuffix).c_str(), "Add", dd); +void define_dd_typed(py::module& m, std::string const& libstring, std::string const& valueSuffix, py::classh> const& dd) { + py::classh> add(m, (std::string("Add_") + libstring + valueSuffix).c_str(), "Add", dd); add.def( "__iter__", [](const storm::dd::Add& s) { return py::make_iterator(s.begin(), s.end()); }, py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */); - py::class_> addIterator(m, (std::string("AddIterator_") + libstring + valueSuffix).c_str(), "AddIterator"); + py::classh> addIterator(m, (std::string("AddIterator_") + libstring + valueSuffix).c_str(), "AddIterator"); addIterator.def("get", [](const storm::dd::AddIterator& it) { return *it; }); } @@ -52,6 +52,6 @@ void define_dd_nt(py::module& m) { .finalize(); } -template py::class_> define_dd(py::module& m, std::string const& libstring); +template py::classh> define_dd(py::module& m, std::string const& libstring); template void define_dd_typed(py::module&, std::string const&, std::string const&, - py::class_> const&); \ No newline at end of file + py::classh> const&); \ No newline at end of file diff --git a/src/storage/dd.h b/src/storage/dd.h index f66021eb30..ea01176403 100644 --- a/src/storage/dd.h +++ b/src/storage/dd.h @@ -6,8 +6,8 @@ #include "src/common.h" template -py::class_> define_dd(py::module& m, std::string const& libname); +py::classh> define_dd(py::module& m, std::string const& libname); template -void define_dd_typed(py::module& m, std::string const& libstring, std::string const& valueSuffix, py::class_> const& dd); +void define_dd_typed(py::module& m, std::string const& libstring, std::string const& valueSuffix, py::classh> const& dd); void define_dd_nt(py::module& m); diff --git a/src/storage/decomposition.cpp b/src/storage/decomposition.cpp index 67a13b55da..30af6e5d79 100644 --- a/src/storage/decomposition.cpp +++ b/src/storage/decomposition.cpp @@ -9,7 +9,7 @@ template using MECDecomposition = storm::storage::MaximalEndComponentDecomposition; void define_maximal_end_components(py::module& m) { - py::class_>(m, "MaximalEndComponent", "Maximal end component") + py::classh(m, "MaximalEndComponent", "Maximal end component") .def_property_readonly("size", &MEC::size, "Number of states in MEC") .def( @@ -19,8 +19,7 @@ void define_maximal_end_components(py::module& m) { template void define_maximal_end_component_decomposition(py::module& m, std::string const& vt_suffix) { - py::class_, std::shared_ptr>>(m, ("MaximalEndComponentDecomposition" + vt_suffix).c_str(), - "Decomposition of maximal end components") + py::classh>(m, ("MaximalEndComponentDecomposition" + vt_suffix).c_str(), "Decomposition of maximal end components") .def(py::init const&>(), py::arg("model"), "Create MECs from model") .def_property_readonly("size", &MECDecomposition::size, "Number of MECs in the decomposition") .def( diff --git a/src/storage/distribution.cpp b/src/storage/distribution.cpp index d5e6b588d4..14a3f69937 100644 --- a/src/storage/distribution.cpp +++ b/src/storage/distribution.cpp @@ -11,7 +11,7 @@ void define_distribution(py::module& m, std::string vt_suffix) { using Distrib = storm::storage::Distribution; std::string distributionClassName = std::string("Distribution") + vt_suffix; - py::class_ distribution(m, distributionClassName.c_str(), "Finite Support Distribution"); + py::classh distribution(m, distributionClassName.c_str(), "Finite Support Distribution"); distribution.def("__str__", &streamToString); } diff --git a/src/storage/expressions.cpp b/src/storage/expressions.cpp index 079ee755c7..86e7f12581 100644 --- a/src/storage/expressions.cpp +++ b/src/storage/expressions.cpp @@ -18,8 +18,7 @@ void define_expressions(py::module& m) { using Valuation = storm::expressions::Valuation; // ExpressionManager - py::class_>(m, "ExpressionManager", - "Manages variables for expressions") + py::classh(m, "ExpressionManager", "Manages variables for expressions") .def(py::init(), "Constructor") .def("create_boolean", &storm::expressions::ExpressionManager::boolean, py::arg("boolean"), "Create expression from boolean") .def("create_integer", &storm::expressions::ExpressionManager::integer, py::arg("integer"), "Create expression from integer number") @@ -40,7 +39,7 @@ void define_expressions(py::module& m) { .def("__eq__", &storm::expressions::ExpressionManager::operator==); // Variable - py::class_>(m, "Variable", "Represents a variable") + py::classh(m, "Variable", "Represents a variable") .def_property_readonly("name", &storm::expressions::Variable::getName, "Variable name") .def_property_readonly("manager", &storm::expressions::Variable::getManager, "Variable manager") .def_property_readonly("index", &storm::expressions::Variable::getIndex, "Variable index") @@ -82,7 +81,7 @@ void define_expressions(py::module& m) { .finalize(); // Expression - py::class_> expression(m, "Expression", "Holds an expression"); + py::classh expression(m, "Expression", "Holds an expression"); expression.def(py::init(), "other_expression"_a) .def("contains_variables", &storm::expressions::Expression::containsVariables, "Check if the expression contains variables.") .def("contains_variable", &storm::expressions::Expression::containsVariable, "Check if the expression contains any of the given variables.", @@ -133,7 +132,7 @@ void define_expressions(py::module& m) { .def_static("Conjunction", [](std::vector const& expr) { return storm::expressions::conjunction(expr); }) .def_static("Disjunction", [](std::vector const& expr) { return storm::expressions::disjunction(expr); }); - py::class_(m, "ExpressionParser", "Parser for storm-expressions") + py::classh(m, "ExpressionParser", "Parser for storm-expressions") .def(py::init(), "Expression Manager to use", py::arg("expression_manager")) .def( "set_identifier_mapping", @@ -143,14 +142,14 @@ void define_expressions(py::module& m) { "sets identifiers") .def("parse", &storm::parser::ExpressionParser::parseFromString, py::arg("string"), py::arg("ignore_error") = false, "parse"); - py::class_(m, "ExpressionType", "The type of an expression") + py::classh(m, "ExpressionType", "The type of an expression") .def_property_readonly("is_boolean", &storm::expressions::Type::isBooleanType) .def_property_readonly("is_integer", &storm::expressions::Type::isIntegerType) .def_property_readonly("is_rational", &storm::expressions::Type::isRationalType) .def_property_readonly("is_string", &storm::expressions::Type::isStringType) .def("__str__", &storm::expressions::Type::getStringRepresentation); - py::class_(m, "DiceStringVisitor", "Translate expressions to dice") + py::classh(m, "DiceStringVisitor", "Translate expressions to dice") .def(py::init(), py::arg("nr_bits")) .def("to_string", [](storm::expressions::ToDiceStringVisitor& visitor, storm::expressions::Expression const& expr) { return visitor.toString(expr); }); } diff --git a/src/storage/geometry.cpp b/src/storage/geometry.cpp index 4b5d40f787..538ac55805 100644 --- a/src/storage/geometry.cpp +++ b/src/storage/geometry.cpp @@ -7,7 +7,7 @@ template void define_geometry(py::module& m, std::string vt_suffix) { typedef storm::storage::geometry::Polytope Polytope; - py::class_> polytope(m, ("Polytope" + vt_suffix).c_str()); + py::classh polytope(m, ("Polytope" + vt_suffix).c_str()); polytope.def_property_readonly("vertices", &Polytope::getVertices); polytope.def("create_downward_closure", &Polytope::downwardClosure); polytope.def("get_vertices_clockwise", &Polytope::getVerticesInClockwiseOrder); diff --git a/src/storage/jani.cpp b/src/storage/jani.cpp index 3e55e62c81..4a8c28a3d5 100644 --- a/src/storage/jani.cpp +++ b/src/storage/jani.cpp @@ -20,7 +20,7 @@ std::string janiToString(Model const& m) { } void define_jani(py::module& m) { - py::class_> md(m, "JaniModel", "A Jani Model"); + py::classh md(m, "JaniModel", "A Jani Model"); md.def(py::init(), "other_model"_a) .def_property_readonly("name", &Model::getName, "model name") .def_property_readonly("model_type", &storm::jani::Model::getModelType, "Model type") @@ -65,7 +65,7 @@ void define_jani(py::module& m) { return ss.str(); }); - py::class_> automaton(m, "JaniAutomaton", "A Jani Automation"); + py::classh automaton(m, "JaniAutomaton", "A Jani Automation"); automaton.def(py::init()) .def_property_readonly( "edges", [](const Automaton& a) -> auto& { return a.getEdges(); }, "get edges") @@ -84,7 +84,7 @@ void define_jani(py::module& m) { .def("add_edge", &Automaton::addEdge, "edge"_a) .def("get_location_index", &Automaton::getLocationIndex, "name"_a); - py::class_> edge(m, "JaniEdge", "A Jani Edge"); + py::classh edge(m, "JaniEdge", "A Jani Edge"); edge.def(py::init, std::shared_ptr, std::vector>>(), "source_location_index"_a, "action_index"_a, "rate"_a, "template_edge"_a, "destinations_with_probabilities"_a) @@ -100,24 +100,24 @@ void define_jani(py::module& m) { .def("substitute", &Edge::substitute, py::arg("mapping"), py::arg("substitute_transcendental_numbers")) .def("has_silent_action", &Edge::hasSilentAction, "Is the edge labelled with the silent action"); - py::class_> templateEdge(m, "JaniTemplateEdge", "Template edge, internal data structure for edges"); + py::classh templateEdge(m, "JaniTemplateEdge", "Template edge, internal data structure for edges"); templateEdge.def(py::init()) .def_property_readonly("assignments", [](TemplateEdge& te) -> auto& { return te.getAssignments(); }) .def_property("guard", &TemplateEdge::getGuard, &TemplateEdge::setGuard) .def_property_readonly("destinations", [](TemplateEdge& te) -> auto& { return te.getDestinations(); }) .def("add_destination", &TemplateEdge::addDestination); - py::class_> edgeDestination(m, "JaniEdgeDestination", "Destination in Jani"); + py::classh edgeDestination(m, "JaniEdgeDestination", "Destination in Jani"); edgeDestination.def_property_readonly("target_location_index", &EdgeDestination::getLocationIndex) .def_property_readonly("probability", &EdgeDestination::getProbability) .def_property_readonly("assignments", &EdgeDestination::getOrderedAssignments); - py::class_> templateEdgeDestination( - m, "JaniTemplateEdgeDestination", "Template edge destination, internal data structure for edge destinations"); + py::classh templateEdgeDestination(m, "JaniTemplateEdgeDestination", + "Template edge destination, internal data structure for edge destinations"); templateEdgeDestination.def(py::init(), "ordered_assignments"_a) .def_property_readonly("assignments", [](TemplateEdgeDestination& ted) -> auto& { return ted.getOrderedAssignments(); }); - py::class_> orderedAssignments(m, "JaniOrderedAssignments", "Set of assignments"); + py::classh orderedAssignments(m, "JaniOrderedAssignments", "Set of assignments"); orderedAssignments .def( "__iter__", [](OrderedAssignments& v) { return py::make_iterator(v.begin(), v.end()); }, @@ -131,18 +131,18 @@ void define_jani(py::module& m) { "add", [](OrderedAssignments& oa, Assignment const& newAssignment, bool addToExisting) { return oa.add(newAssignment, addToExisting); }, "new_assignment"_a, "add_to_existing"_a = false); - py::class_> assignment(m, "JaniAssignment", "Jani Assignment"); + py::classh assignment(m, "JaniAssignment", "Jani Assignment"); assignment.def(py::init(), "lhs"_a, "rhs"_a, "lvl"_a = 0) .def("__str__", &streamToString) .def_property("expression", &Assignment::getAssignedExpression, &Assignment::setAssignedExpression) .def_property_readonly("variable", &Assignment::getVariable, "variable that is assigned to, if any"); - py::class_> location(m, "JaniLocation", "A Location in JANI"); + py::classh location(m, "JaniLocation", "A Location in JANI"); location.def(py::init(), "name"_a, "assignments"_a) .def_property_readonly("name", &Location::getName, "name of the location") .def_property_readonly("assignments", [](Location& loc) { loc.getAssignments(); }, "location assignments"); - py::class_> variableSet(m, "JaniVariableSet", "Jani Set of Variables"); + py::classh variableSet(m, "JaniVariableSet", "Jani Set of Variables"); variableSet.def(py::init<>()) .def( "__iter__", [](VariableSet& v) { return py::make_iterator(v.begin(), v.end()); }, py::keep_alive<0, 1>()) @@ -155,27 +155,27 @@ void define_jani(py::module& m) { py::return_value_policy::reference) .def("erase_variable", &VariableSet::eraseVariable, "variable"); - py::class_> janiType(m, "JaniType", "A Variable Type in JANI"); + py::classh janiType(m, "JaniType", "A Variable Type in JANI"); janiType.def_property_readonly("is_array_type", &JaniType::isArrayType) .def_property_readonly("is_bounded_type", &JaniType::isBoundedType) .def_property_readonly("is_clock_type", &JaniType::isClockType) .def_property_readonly("is_basic_type", &JaniType::isBasicType) .def_property_readonly("is_continuous_type", &JaniType::isContinuousType) .def("__str__", &JaniType::getStringRepresentation); - py::class_> basicType(m, "BasicType", "A basic type in JANI", janiType); + py::classh basicType(m, "BasicType", "A basic type in JANI", janiType); basicType.def_property_readonly("inner_type", &BasicType::get, "the inner type"); - py::class_> boundedType(m, "BoundedType", "A bounded type in JANI", janiType); + py::classh boundedType(m, "BoundedType", "A bounded type in JANI", janiType); boundedType.def_property_readonly("base_type", &BoundedType::getBaseType, "the base type") .def_property_readonly( "lower_bound", [](const BoundedType& tp) -> storm::expressions::Expression const& { return tp.getLowerBound(); }, "the lower bound") .def_property_readonly( "upper_bound", [](const BoundedType& tp) -> storm::expressions::Expression const& { return tp.getUpperBound(); }, "the upper bound"); - py::class_> clockType(m, "ClockType", "A clock type in JANI", janiType); - py::class_> arrayType(m, "ArrayType", "An array type in JANI", janiType); + py::classh clockType(m, "ClockType", "A clock type in JANI", janiType); + py::classh arrayType(m, "ArrayType", "An array type in JANI", janiType); arrayType.def_property_readonly("base_type", [](const ArrayType& tp) -> JaniType const& { return tp.getBaseType(); }, "the base type"); - py::class_> continuousType(m, "ContinuousType", "A continuous type in JANI", janiType); + py::classh continuousType(m, "ContinuousType", "A continuous type in JANI", janiType); - py::class_> variable(m, "JaniVariable", "A Variable in JANI"); + py::classh variable(m, "JaniVariable", "A Variable in JANI"); variable.def_property_readonly("name", &Variable::getName, "name of constant") .def_property_readonly( "type", [](Variable& v) -> JaniType const& { return v.getType(); }, "type of the variable") @@ -183,7 +183,7 @@ void define_jani(py::module& m) { .def_property_readonly("init_expression", &Variable::getInitExpression) .def_property_readonly("is_transient", &Variable::isTransient); - py::class_> constant(m, "JaniConstant", "A Constant in JANI"); + py::classh constant(m, "JaniConstant", "A Constant in JANI"); constant.def(py::init()) .def_property_readonly("defined", &Constant::isDefined, "is constant defined by some expression") .def_property_readonly("name", &Constant::getName, "name of constant") @@ -199,7 +199,7 @@ void define_jani(py::module& m) { }, "Eliminate reward accumulations", py::arg("model"), py::arg("properties")); - py::class_ informationObject(m, "JaniInformationObject", "An object holding information about a JANI model"); + py::classh informationObject(m, "JaniInformationObject", "An object holding information about a JANI model"); informationObject.def_readwrite("model_type", &InformationObject::modelType) .def_readwrite("nr_automata", &InformationObject::nrAutomata) .def_readwrite("nr_edges", &InformationObject::nrEdges) @@ -219,11 +219,11 @@ void define_jani(py::module& m) { } void define_jani_transformers(py::module& m) { - py::class_(m, "JaniLocationExpander", "A transformer for Jani expanding variables into locations") + py::classh(m, "JaniLocationExpander", "A transformer for Jani expanding variables into locations") .def(py::init(), py::arg("model")) .def("transform", &JaniLocationExpander::transform, py::arg("automaton_name"), py::arg("variable_name")); - py::class_(m, "JaniScopeChanger", "A transformer for Jani changing variables from local to global and vice versa") + py::classh(m, "JaniScopeChanger", "A transformer for Jani changing variables from local to global and vice versa") .def(py::init<>()) .def( "make_variables_local", diff --git a/src/storage/labeling.cpp b/src/storage/labeling.cpp index 5a5b965e0a..7a1f2ebcb8 100644 --- a/src/storage/labeling.cpp +++ b/src/storage/labeling.cpp @@ -9,7 +9,7 @@ // Define python bindings void define_labeling(py::module& m) { // ItemLabeling - py::class_> labeling(m, "ItemLabeling", "Labeling"); + py::classh labeling(m, "ItemLabeling", "Labeling"); labeling.def( "add_label", [](storm::models::sparse::ItemLabeling& labeling, std::string label) { labeling.addLabel(label); }, py::arg("label"), "Add label") .def("get_labels", &storm::models::sparse::ItemLabeling::getLabels, "Get all labels") @@ -17,7 +17,7 @@ void define_labeling(py::module& m) { .def("__str__", &streamToString); // StateLabeling - py::class_>(m, "StateLabeling", "Labeling for states", labeling) + py::classh(m, "StateLabeling", "Labeling for states", labeling) .def(py::init(), "state_count"_a) .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")) @@ -32,7 +32,7 @@ void define_labeling(py::module& m) { "Add a label to the given states", py::arg("label"), py::arg("states")) .def("__str__", &streamToString); - py::class_(m, "ChoiceLabeling", "Labeling for choices", labeling) + py::classh(m, "ChoiceLabeling", "Labeling for choices", labeling) .def(py::init(), "choice_count"_a) .def("get_labels_of_choice", &storm::models::sparse::ChoiceLabeling::getLabelsOfChoice, py::arg("choice"), "Get labels of the given choice") .def("add_label_to_choice", &storm::models::sparse::ChoiceLabeling::addLabelToChoice, "Adds a label to a given choice", py::arg("label"), diff --git a/src/storage/matrix.cpp b/src/storage/matrix.cpp index bad12bfd7c..3919e535b8 100644 --- a/src/storage/matrix.cpp +++ b/src/storage/matrix.cpp @@ -33,7 +33,7 @@ void define_sparse_matrix_nt(py::module& m) { template void define_sparse_matrix(py::module& m, std::string const& vtSuffix) { // MatrixEntry - py::class_>(m, (vtSuffix + "SparseMatrixEntry").c_str(), "Entry of sparse matrix") + py::classh>(m, (vtSuffix + "SparseMatrixEntry").c_str(), "Entry of sparse matrix") .def("__str__", &streamToString>) // def_property threw "pointer being freed not allocated" after exiting .def("value", &MatrixEntry::getValue, "Value") @@ -41,7 +41,7 @@ void define_sparse_matrix(py::module& m, std::string const& vtSuffix) { .def_property_readonly("column", &MatrixEntry::getColumn, "Column"); // SparseMatrixBuilder - py::class_>(m, (vtSuffix + "SparseMatrixBuilder").c_str(), "Builder of sparse matrix") + py::classh>(m, (vtSuffix + "SparseMatrixBuilder").c_str(), "Builder of sparse matrix") .def(py::init(), "rows"_a = 0, "columns"_a = 0, "entries"_a = 0, "force_dimensions"_a = true, "has_custom_row_grouping"_a = false, "row_groups"_a = 0) @@ -104,7 +104,7 @@ void define_sparse_matrix(py::module& m, std::string const& vtSuffix) { py::arg("replacements"), py::arg("offset")); // SparseMatrix - py::class_>(m, (vtSuffix + "SparseMatrix").c_str(), "Sparse matrix") + py::classh>(m, (vtSuffix + "SparseMatrix").c_str(), "Sparse matrix") .def( "__iter__", [](SparseMatrix& matrix) { return py::make_iterator(matrix.begin(), matrix.end()); }, py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */) @@ -172,7 +172,7 @@ void define_sparse_matrix(py::module& m, std::string const& vtSuffix) { py::return_value_policy::reference, py::keep_alive<1, 0>()); // Rows - py::class_::rows>(m, (vtSuffix + "SparseMatrixRows").c_str(), "Set of rows in a sparse matrix") + py::classh::rows>(m, (vtSuffix + "SparseMatrixRows").c_str(), "Set of rows in a sparse matrix") .def( "__iter__", [](typename SparseMatrix::rows& rows) { return py::make_iterator(rows.begin(), rows.end()); }, py::keep_alive<0, 1>()) .def("__str__", &containerToString::rows>) diff --git a/src/storage/memorystructure.cpp b/src/storage/memorystructure.cpp index 5fa4800a91..960f36edfb 100644 --- a/src/storage/memorystructure.cpp +++ b/src/storage/memorystructure.cpp @@ -8,8 +8,8 @@ #include template -void define_memorystructure_product_each(py::class_>& memoryStructure, - py::class_& reverseData, std::string const& vtSuffix) { +void define_memorystructure_product_each(py::classh& memoryStructure, + py::classh& reverseData, std::string const& vtSuffix) { memoryStructure.def( ("_product_model" + vtSuffix).c_str(), [](storm::storage::MemoryStructure& ms, storm::models::sparse::Model const& sparseModel) { return ms.product(sparseModel); }); @@ -19,12 +19,12 @@ void define_memorystructure_product_each(py::class_> memoryStructure(m, "MemoryStructure"); + py::classh memoryStructure(m, "MemoryStructure"); memoryStructure.def("product", [](MemoryStructure& ms, MemoryStructure const& memModel) { return ms.product(memModel); }); memoryStructure.def_property_readonly("nr_states", &MemoryStructure::getNumberOfStates); memoryStructure.def_property_readonly("state_labeling", &MemoryStructure::getStateLabeling); - py::class_ memoryProductReverseData(m, "SparseModelMemoryProductReverseData"); + py::classh memoryProductReverseData(m, "SparseModelMemoryProductReverseData"); define_memorystructure_product_each(memoryStructure, memoryProductReverseData, "_double"); define_memorystructure_product_each(memoryStructure, memoryProductReverseData, "_exact"); define_memorystructure_product_each(memoryStructure, memoryProductReverseData, "_parametric"); @@ -33,7 +33,7 @@ void define_memorystructure_untyped(py::module& m) { template void define_memorystructure_typed(py::module& m, std::string const& vtSuffix) { typedef storm::storage::MemoryStructureBuilder MemoryStructureBuilder; - py::class_> msb(m, ("MemoryStructureBuilder" + vtSuffix).c_str()); + py::classh msb(m, ("MemoryStructureBuilder" + vtSuffix).c_str()); msb.def(py::init const&, bool>(), py::arg("nr_memory_states"), py::arg("model"), py::arg("only_initial_states_relevant") = true); msb.def("build", &MemoryStructureBuilder::build); @@ -43,7 +43,7 @@ void define_memorystructure_typed(py::module& m, std::string const& vtSuffix) { msb.def("set_initial_memory_state", &MemoryStructureBuilder::setInitialMemoryState, py::arg("state"), py::arg("value")); typedef storm::storage::SparseModelMemoryProduct MemoryStructureProduct; - py::class_> msp(m, ("MemoryStructureProduct" + vtSuffix).c_str()); + py::classh msp(m, ("MemoryStructureProduct" + vtSuffix).c_str()); msp.def("build", &MemoryStructureProduct::build, py::arg("preserve_model_type") = false); msp.def("set_build_full_product", &MemoryStructureProduct::setBuildFullProduct, "Enforces that every state is considered reachable and thus constructed. This causes the product to have the size of the product of the original " diff --git a/src/storage/model.cpp b/src/storage/model.cpp index 6d71cfe957..269bf7d0f8 100644 --- a/src/storage/model.cpp +++ b/src/storage/model.cpp @@ -92,7 +92,7 @@ storm::models::sparse::StateLabeling& getLabeling(SparseModel& model) } template -void define_model_as_sparse(py::class_>& modelBase) { +void define_model_as_sparse(py::classh& modelBase) { std::string prefix; if constexpr (std::is_same_v) prefix = ""; @@ -116,7 +116,7 @@ void define_model_as_sparse(py::class_>& m } template -void define_model_as_symbolic(py::class_>& modelBase) { +void define_model_as_symbolic(py::classh& modelBase) { std::string prefix; if constexpr (std::is_same_v) prefix = ""; @@ -150,7 +150,7 @@ void define_model(py::module& m) { .finalize(); // ModelBase - py::class_> modelBase(m, "_ModelBase", "Base class for all models"); + py::classh modelBase(m, "_ModelBase", "Base class for all models"); modelBase.def_property_readonly("nr_states", &ModelBase::getNumberOfStates, "Number of states") .def_property_readonly("nr_transitions", &ModelBase::getNumberOfTransitions, "Number of transitions") .def_property_readonly("nr_choices", &ModelBase::getNumberOfChoices, "Number of choices") @@ -176,8 +176,7 @@ void define_model(py::module& m) { // Bindings for sparse models template void define_sparse_model(py::module& m, std::string const& vtSuffix) { - py::class_, std::shared_ptr>, ModelBase> model(m, ("_Sparse" + vtSuffix + "Model").c_str(), - "A probabilistic model in a sparse matrix representation"); + py::classh, ModelBase> model(m, ("_Sparse" + vtSuffix + "Model").c_str(), "A probabilistic model in a sparse matrix representation"); model.def_property_readonly("supports_uncertainty", &SparseModel::supportsUncertainty, "Flag whether model supports uncertainty via intervals") .def_property_readonly("labeling", &getLabeling, "Labels") .def( @@ -265,18 +264,15 @@ void define_sparse_model(py::module& m, std::string const& vtSuffix) { }, py::arg("parameter"), "Find states with a particular parameter"); } - py::class_, std::shared_ptr>> detModel( - m, ("_SparseDeterministic" + vtSuffix + "Model").c_str(), "Deterministic sparse model", model); - py::class_, std::shared_ptr>> nondetModel( - m, ("_SparseNondeterministic" + vtSuffix + "Model").c_str(), "Nondeterministic sparse model", model); + py::classh> detModel(m, ("_SparseDeterministic" + vtSuffix + "Model").c_str(), "Deterministic sparse model", model); + py::classh> nondetModel(m, ("_SparseNondeterministic" + vtSuffix + "Model").c_str(), "Nondeterministic sparse model", + model); - py::class_, std::shared_ptr>>(m, ("Sparse" + vtSuffix + "Dtmc").c_str(), "DTMC in sparse representation", - detModel) + py::classh>(m, ("Sparse" + vtSuffix + "Dtmc").c_str(), "DTMC in sparse representation", detModel) .def(py::init>(), py::arg("other_model")) .def(py::init const&>(), py::arg("components")) .def("__str__", &getModelInfoPrinter); - py::class_, std::shared_ptr>> mdp(m, ("Sparse" + vtSuffix + "Mdp").c_str(), "MDP in sparse representation", - nondetModel); + py::classh> mdp(m, ("Sparse" + vtSuffix + "Mdp").c_str(), "MDP in sparse representation", nondetModel); 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) .def_property_readonly("nondeterministic_choice_indices", [](SparseMdp const& mdp) { return mdp.getNondeterministicChoiceIndices(); }) @@ -297,8 +293,7 @@ void define_sparse_model(py::module& m, std::string const& vtSuffix) { }, "apply scheduler", "scheduler"_a, "drop_unreachable_states"_a = true) .def("__str__", &getModelInfoPrinter); - py::class_, std::shared_ptr>>(m, ("Sparse" + vtSuffix + "Pomdp").c_str(), "POMDP in sparse representation", - mdp) + py::classh>(m, ("Sparse" + vtSuffix + "Pomdp").c_str(), "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) .def("__str__", &getModelInfoPrinter) @@ -307,15 +302,13 @@ void define_sparse_model(py::module& m, std::string const& vtSuffix) { .def_property_readonly("nr_observations", &SparsePomdp::getNrObservations) .def("has_observation_valuations", &SparsePomdp::hasObservationValuations) .def_property_readonly("observation_valuations", &SparsePomdp::getObservationValuations); - py::class_, std::shared_ptr>>(m, ("Sparse" + vtSuffix + "Ctmc").c_str(), "CTMC in sparse representation", - detModel) + py::classh>(m, ("Sparse" + vtSuffix + "Ctmc").c_str(), "CTMC in sparse representation", detModel) .def(py::init>(), py::arg("other_model")) .def(py::init const&>(), py::arg("components")) .def_property_readonly("exit_rates", [](SparseCtmc const& ctmc) { return ctmc.getExitRateVector(); }) .def("probability_matrix", &SparseCtmc::computeProbabilityMatrix) .def("__str__", &getModelInfoPrinter); - py::class_, std::shared_ptr>>(m, ("Sparse" + vtSuffix + "MA").c_str(), - "MA in sparse representation", nondetModel) + py::classh>(m, ("Sparse" + vtSuffix + "MA").c_str(), "MA in sparse representation", nondetModel) .def(py::init>(), py::arg("other_model")) .def(py::init const&>(), py::arg("components")) .def_property_readonly("exit_rates", [](SparseMarkovAutomaton const& ma) { return ma.getExitRates(); }) @@ -336,14 +329,13 @@ void define_sparse_model(py::module& m, std::string const& vtSuffix) { "Check whether the MA can be converted into a CTMC.") .def("convert_to_ctmc", &SparseMarkovAutomaton::convertToCtmc, "Convert the MA into a CTMC."); - py::class_, std::shared_ptr>>(m, ("Sparse" + vtSuffix + "Smg").c_str(), "SMG in sparse representation", - nondetModel) + py::classh>(m, ("Sparse" + vtSuffix + "Smg").c_str(), "SMG in sparse representation", nondetModel) .def(py::init>(), py::arg("other_model")) .def(py::init const&>(), py::arg("components")) .def("get_state_player_indications", &SparseSmg::getStatePlayerIndications, "Get for each state its corresponding player") .def("get_player_of_state", &SparseSmg::getPlayerOfState, py::arg("state"), "Get player for the given state"); - py::class_>(m, ("Sparse" + vtSuffix + "RewardModel").c_str(), "Reward structure for sparse models") + py::classh>(m, ("Sparse" + vtSuffix + "RewardModel").c_str(), "Reward structure for sparse models") .def(py::init> const&, std::optional> const&, std::optional> const&>(), py::arg("optional_state_reward_vector") = std::nullopt, py::arg("optional_state_action_reward_vector") = std::nullopt, @@ -372,8 +364,8 @@ void define_sparse_model(py::module& m, std::string const& vtSuffix) { // Bindings for symbolic models template void define_symbolic_model(py::module& m, std::string vt_suffix) { - py::class_, std::shared_ptr>, ModelBase> model( - m, ("_Symbolic" + vt_suffix + "Model").c_str(), "A probabilistic model in a symbolic representation"); + py::classh, ModelBase> model(m, ("_Symbolic" + vt_suffix + "Model").c_str(), + "A probabilistic model in a symbolic representation"); model.def_property_readonly( "reward_models", [](SymbolicModel& model) { return model.getRewardModels(); }, "Reward models") .def_property_readonly("dd_manager", &SymbolicModel::getManager, "dd manager") @@ -395,20 +387,16 @@ void define_symbolic_model(py::module& m, std::string vt_suffix) { if constexpr (std::is_same_v) { model.def("get_parameters", &SymbolicModel::getParameters, "Get parameters"); } - py::class_, std::shared_ptr>>(m, ("Symbolic" + vt_suffix + "Dtmc").c_str(), - "DTMC in symbolic representation", model) + py::classh>(m, ("Symbolic" + vt_suffix + "Dtmc").c_str(), "DTMC in symbolic representation", model) .def("__str__", &getModelInfoPrinter); - py::class_, std::shared_ptr>>(m, ("Symbolic" + vt_suffix + "Mdp").c_str(), - "MDP in symbolic representation", model) + py::classh>(m, ("Symbolic" + vt_suffix + "Mdp").c_str(), "MDP in symbolic representation", model) .def("__str__", &getModelInfoPrinter); - py::class_, std::shared_ptr>>(m, ("Symbolic" + vt_suffix + "Ctmc").c_str(), - "CTMC in symbolic representation", model) + py::classh>(m, ("Symbolic" + vt_suffix + "Ctmc").c_str(), "CTMC in symbolic representation", model) .def("__str__", &getModelInfoPrinter); - py::class_, std::shared_ptr>>( - m, ("Symbolic" + vt_suffix + "MA").c_str(), "MA in symbolic representation", model) + py::classh>(m, ("Symbolic" + vt_suffix + "MA").c_str(), "MA in symbolic representation", model) .def("__str__", &getModelInfoPrinter); - py::class_>(m, ("Symbolic" + vt_suffix + "RewardModel").c_str(), "Reward structure for symbolic models") + py::classh>(m, ("Symbolic" + vt_suffix + "RewardModel").c_str(), "Reward structure for symbolic models") .def_property_readonly("has_state_rewards", &SymbolicRewardModel::hasStateRewards) .def_property_readonly("has_state_action_rewards", &SymbolicRewardModel::hasStateActionRewards) .def_property_readonly("has_transition_rewards", &SymbolicRewardModel::hasTransitionRewards); diff --git a/src/storage/model_components.cpp b/src/storage/model_components.cpp index 3b3f4c24d3..8a0b7df846 100644 --- a/src/storage/model_components.cpp +++ b/src/storage/model_components.cpp @@ -21,8 +21,7 @@ using SparseModelComponents = storm::storage::sparse::ModelComponents template void define_sparse_model_components(py::module& m, std::string const& vtSuffix) { - py::class_, std::shared_ptr>>(m, ("Sparse" + vtSuffix + "ModelComponents").c_str(), - "Components required for building a sparse model") + py::classh>(m, ("Sparse" + vtSuffix + "ModelComponents").c_str(), "Components required for building a sparse model") .def(py::init const&, StateLabeling const&, std::unordered_map> const&, bool, boost::optional const&, boost::optional> const&>(), diff --git a/src/storage/prism.cpp b/src/storage/prism.cpp index 6f42616ee2..c44ce0727d 100644 --- a/src/storage/prism.cpp +++ b/src/storage/prism.cpp @@ -31,7 +31,7 @@ template void define_stateGeneration(py::module& m); void define_prism(py::module& m) { - py::class_> program(m, "PrismProgram", "A Prism Program"); + py::classh program(m, "PrismProgram", "A Prism Program"); program.def_property_readonly("constants", &Program::getConstants, "Get Program Constants") .def_property_readonly("global_boolean_variables", &Program::getGlobalBooleanVariables, "Retrieves the global boolean variables of the program") .def_property_readonly("global_integer_variables", &Program::getGlobalIntegerVariables, "Retrieves the global integer variables of the program") @@ -97,7 +97,7 @@ void define_prism(py::module& m) { "Get the expression of the given label.", py::arg("label")) .def_property_readonly("labels", &Program::getLabels, "Get all labels in the program"); - py::class_ module(m, "PrismModule", "A module in a Prism program"); + py::classh module(m, "PrismModule", "A module in a Prism program"); module.def_property_readonly( "commands", [](Module const& module) { return module.getCommands(); }, "Commands in the module") .def_property_readonly("name", &Module::getName, "Name of the module") @@ -108,7 +108,7 @@ void define_prism(py::module& m) { .def("get_command_indices_by_action_index", &Module::getCommandIndicesByActionIndex, py::arg("action_index")) .def("__str__", &streamToString); - py::class_ command(m, "PrismCommand", "A command in a Prism program"); + py::classh command(m, "PrismCommand", "A command in a Prism program"); command.def_property_readonly("global_index", &Command::getGlobalIndex, "Get global index") .def_property_readonly("labeled", &Command::isLabeled, "Is the command labeled") .def_property_readonly("action_index", &Command::getActionIndex, "What is the action index of the command") @@ -119,7 +119,7 @@ void define_prism(py::module& m) { "updates", [](Command const& command) { return command.getUpdates(); }, "Updates in the command") .def("__str__", &streamToString); - py::class_ update(m, "PrismUpdate", "An update in a Prism command"); + py::classh update(m, "PrismUpdate", "An update in a Prism command"); update.def(py::init const&>()) .def_property_readonly( "assignments", [](Update const& update) { return update.getAssignments(); }, "Assignments in the update") @@ -131,13 +131,13 @@ void define_prism(py::module& m) { .def("get_as_variable_to_expression_map", &Update::getAsVariableToExpressionMap, "Creates a mapping representation of this update") .def("__str__", &streamToString); - py::class_ assignment(m, "PrismAssignment", "An assignment in prism"); + py::classh assignment(m, "PrismAssignment", "An assignment in prism"); assignment.def(py::init()) .def_property_readonly("variable", &Assignment::getVariable, "Variable that is updated") .def_property_readonly("expression", &Assignment::getExpression, "Expression for the update") .def("__str__", &streamToString); - py::class_