Sebastian Junges
4 years ago
24 changed files with 297 additions and 326 deletions
-
4CHANGELOG.md
-
12lib/stormpy/__init__.py
-
5lib/stormpy/simulator.py
-
10src/core/core.cpp
-
10src/core/modelchecking.cpp
-
23src/core/simulator.cpp
-
3src/core/simulator.h
-
4src/mod_core.cpp
-
5src/mod_pomdp.cpp
-
18src/mod_storage.cpp
-
59src/pomdp/tracker.cpp
-
3src/pomdp/tracker.h
-
14src/pomdp/transformations.cpp
-
4src/storage/distribution.cpp
-
1src/storage/jani.cpp
-
187src/storage/matrix.cpp
-
5src/storage/matrix.h
-
140src/storage/model.cpp
-
4src/storage/model.h
-
39src/storage/model_components.cpp
-
3src/storage/model_components.h
-
3src/storage/scheduler.cpp
-
64src/storage/state.cpp
-
3src/storage/state.h
@ -1,14 +1,17 @@ |
|||
#include "simulator.h"
|
|||
#include <storm/simulator/DiscreteTimeSparseModelSimulator.h>
|
|||
|
|||
void define_sparse_model_simulator(py::module& m) { |
|||
py::class_<storm::simulator::DiscreteTimeSparseModelSimulator<double>> dtsmsd(m, "_DiscreteTimeSparseModelSimulatorDouble", "Simulator for sparse discrete-time models in memory (ValueType = double)"); |
|||
dtsmsd.def(py::init<storm::models::sparse::Model<double> const&>()); |
|||
dtsmsd.def("set_seed", &storm::simulator::DiscreteTimeSparseModelSimulator<double>::setSeed, py::arg("seed")); |
|||
dtsmsd.def("step", &storm::simulator::DiscreteTimeSparseModelSimulator<double>::step, py::arg("action")); |
|||
dtsmsd.def("random_step", &storm::simulator::DiscreteTimeSparseModelSimulator<double>::randomStep); |
|||
dtsmsd.def("get_last_reward", &storm::simulator::DiscreteTimeSparseModelSimulator<double>::getLastRewards); |
|||
dtsmsd.def("get_current_state", &storm::simulator::DiscreteTimeSparseModelSimulator<double>::getCurrentState); |
|||
dtsmsd.def("reset_to_initial_state", &storm::simulator::DiscreteTimeSparseModelSimulator<double>::resetToInitial); |
|||
template<typename ValueType> |
|||
void define_sparse_model_simulator(py::module& m, std::string const& vtSuffix) { |
|||
py::class_<storm::simulator::DiscreteTimeSparseModelSimulator<ValueType>> dtsmsd(m, ("_DiscreteTimeSparseModelSimulator" + vtSuffix).c_str(), "Simulator for sparse discrete-time models in memory (ValueType = double)"); |
|||
dtsmsd.def(py::init<storm::models::sparse::Model<ValueType> const&>()); |
|||
dtsmsd.def("set_seed", &storm::simulator::DiscreteTimeSparseModelSimulator<ValueType>::setSeed, py::arg("seed")); |
|||
dtsmsd.def("step", &storm::simulator::DiscreteTimeSparseModelSimulator<ValueType>::step, py::arg("action")); |
|||
dtsmsd.def("random_step", &storm::simulator::DiscreteTimeSparseModelSimulator<ValueType>::randomStep); |
|||
dtsmsd.def("get_last_reward", &storm::simulator::DiscreteTimeSparseModelSimulator<ValueType>::getLastRewards); |
|||
dtsmsd.def("get_current_state", &storm::simulator::DiscreteTimeSparseModelSimulator<ValueType>::getCurrentState); |
|||
dtsmsd.def("reset_to_initial_state", &storm::simulator::DiscreteTimeSparseModelSimulator<ValueType>::resetToInitial); |
|||
} |
|||
|
|||
} |
|||
template void define_sparse_model_simulator<double>(py::module& m, std::string const& vtSuffix); |
|||
template void define_sparse_model_simulator<storm::RationalNumber>(py::module& m, std::string const& vtSuffix); |
@ -1,4 +1,5 @@ |
|||
#pragma once |
|||
#include "common.h" |
|||
|
|||
void define_tracker(py::module& m); |
|||
template<typename ValueType> |
|||
void define_tracker(py::module& m, std::string const& vtSuffix); |
@ -1,51 +1,39 @@ |
|||
#include "state.h"
|
|||
|
|||
void define_state(py::module& m) { |
|||
template<typename ValueType> |
|||
void define_state(py::module& m, std::string const& vtSuffix) { |
|||
|
|||
// SparseModelStates
|
|||
py::class_<SparseModelStates<double>>(m, "SparseModelStates", "States in sparse model") |
|||
.def("__getitem__", &SparseModelStates<double>::getState) |
|||
.def("__len__", &SparseModelStates<double>::getSize) |
|||
; |
|||
py::class_<SparseModelStates<storm::RationalFunction>>(m, "SparseParametricModelStates", "States in sparse parametric model") |
|||
.def("__getitem__", &SparseModelStates<storm::RationalFunction>::getState) |
|||
.def("__len__", &SparseModelStates<storm::RationalFunction>::getSize) |
|||
py::class_<SparseModelStates<ValueType>>(m, ("Sparse" + vtSuffix + "ModelStates").c_str(), "States in sparse model") |
|||
.def("__getitem__", &SparseModelStates<ValueType>::getState) |
|||
.def("__len__", &SparseModelStates<ValueType>::getSize) |
|||
; |
|||
|
|||
// SparseModelState
|
|||
py::class_<SparseModelState<double>>(m, "SparseModelState", "State in sparse model") |
|||
.def("__str__", &SparseModelState<double>::toString) |
|||
.def_property_readonly("id", &SparseModelState<double>::getIndex, "Id") |
|||
.def_property_readonly("labels", &SparseModelState<double>::getLabels, "Labels") |
|||
.def_property_readonly("actions", &SparseModelState<double>::getActions, "Get actions") |
|||
.def("__int__",&SparseModelState<double>::getIndex) |
|||
; |
|||
py::class_<SparseModelState<storm::RationalFunction>>(m, "SparseParametricModelState", "State in sparse parametric model") |
|||
.def("__str__", &SparseModelState<storm::RationalFunction>::toString) |
|||
.def_property_readonly("id", &SparseModelState<storm::RationalFunction>::getIndex, "Id") |
|||
.def_property_readonly("labels", &SparseModelState<storm::RationalFunction>::getLabels, "Labels") |
|||
.def_property_readonly("actions", &SparseModelState<storm::RationalFunction>::getActions, "Get actions") |
|||
.def("__int__",&SparseModelState<storm::RationalFunction>::getIndex) |
|||
py::class_<SparseModelState<ValueType>>(m, ("Sparse" + vtSuffix + "ModelState").c_str(), "State in sparse model") |
|||
.def("__str__", &SparseModelState<ValueType>::toString) |
|||
.def_property_readonly("id", &SparseModelState<ValueType>::getIndex, "Id") |
|||
.def_property_readonly("labels", &SparseModelState<ValueType>::getLabels, "Labels") |
|||
.def_property_readonly("actions", &SparseModelState<ValueType>::getActions, "Get actions") |
|||
.def("__int__",&SparseModelState<ValueType>::getIndex) |
|||
; |
|||
|
|||
|
|||
// SparseModelActions
|
|||
py::class_<SparseModelActions<double>>(m, "SparseModelActions", "Actions for state in sparse model") |
|||
.def("__getitem__", &SparseModelActions<double>::getAction) |
|||
.def("__len__", &SparseModelActions<double>::getSize) |
|||
; |
|||
py::class_<SparseModelActions<storm::RationalFunction>>(m, "SparseParametricModelActions", "Actions for state in sparse parametric model") |
|||
.def("__getitem__", &SparseModelActions<storm::RationalFunction>::getAction) |
|||
.def("__len__", &SparseModelActions<storm::RationalFunction>::getSize) |
|||
py::class_<SparseModelActions<ValueType>>(m, ("Sparse" + vtSuffix + "ModelActions").c_str(), "Actions for state in sparse model") |
|||
.def("__getitem__", &SparseModelActions<ValueType>::getAction) |
|||
.def("__len__", &SparseModelActions<ValueType>::getSize) |
|||
; |
|||
|
|||
// SparseModelAction
|
|||
py::class_<SparseModelAction<double>>(m, "SparseModelAction", "Action for state in sparse model") |
|||
.def("__str__", &SparseModelAction<double>::toString) |
|||
.def_property_readonly("id", &SparseModelAction<double>::getIndex, "Id") |
|||
.def_property_readonly("transitions", &SparseModelAction<double>::getTransitions, "Get transitions") |
|||
; |
|||
py::class_<SparseModelAction<storm::RationalFunction>>(m, "SparseParametricModelAction", "Action for state in sparse parametric model") |
|||
.def("__str__", &SparseModelAction<storm::RationalFunction>::toString) |
|||
.def_property_readonly("id", &SparseModelAction<storm::RationalFunction>::getIndex, "Id") |
|||
.def_property_readonly("transitions", &SparseModelAction<storm::RationalFunction>::getTransitions, "Get transitions") |
|||
py::class_<SparseModelAction<ValueType>>(m, ("Sparse" + vtSuffix + "ModelAction").c_str(), "Action for state in sparse model") |
|||
.def("__str__", &SparseModelAction<ValueType>::toString) |
|||
.def_property_readonly("id", &SparseModelAction<ValueType>::getIndex, "Id") |
|||
.def_property_readonly("transitions", &SparseModelAction<ValueType>::getTransitions, "Get transitions") |
|||
; |
|||
|
|||
} |
|||
|
|||
template void define_state<double>(py::module& m, std::string const& vtSuffix); |
|||
template void define_state<storm::RationalNumber>(py::module& m, std::string const& vtSuffix); |
|||
template void define_state<storm::RationalFunction>(py::module& m, std::string const& vtSuffix); |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue