@ -101,24 +101,28 @@ void define_build(py::module& m) {
// Build model
m.def("_build_sparse_model_from_symbolic_description",&buildSparseModel<double>,"Build the model in sparse representation",py::arg("model_description"),py::arg("formulas")=std::vector<std::shared_ptr<storm::logic::Formulaconst>>(),py::arg("use_jit")=false,py::arg("doctor")=false);
m.def("_build_sparse_exact_model_from_symbolic_description",&buildSparseModel<storm::RationalNumber>,"Build the model in sparse representation with exact number representation",py::arg("model_description"),py::arg("formulas")=std::vector<std::shared_ptr<storm::logic::Formulaconst>>(),py::arg("use_jit")=false,py::arg("doctor")=false);
m.def("_build_sparse_parametric_model_from_symbolic_description",&buildSparseModel<storm::RationalFunction>,"Build the parametric model in sparse representation",py::arg("model_description"),py::arg("formulas")=std::vector<std::shared_ptr<storm::logic::Formulaconst>>(),py::arg("use_jit")=false,py::arg("doctor")=false);
m.def("build_sparse_model_with_options",&buildSparseModelWithOptions<double>,"Build the model in sparse representation",py::arg("model_description"),py::arg("options"),py::arg("use_jit")=false,py::arg("doctor")=false);
m.def("build_sparse_exact_model_with_options",&buildSparseModelWithOptions<storm::RationalNumber>,"Build the model in sparse representation with exact number representation",py::arg("model_description"),py::arg("options"),py::arg("use_jit")=false,py::arg("doctor")=false);
m.def("build_sparse_parametric_model_with_options",&buildSparseModelWithOptions<storm::RationalFunction>,"Build the model in sparse representation",py::arg("model_description"),py::arg("options"),py::arg("use_jit")=false,py::arg("doctor")=false);
m.def("_build_symbolic_model_from_symbolic_description",&buildSymbolicModel<storm::dd::DdType::Sylvan,double>,"Build the model in symbolic representation",py::arg("model_description"),py::arg("formulas")=std::vector<std::shared_ptr<storm::logic::Formulaconst>>());
m.def("_build_symbolic_parametric_model_from_symbolic_description",&buildSymbolicModel<storm::dd::DdType::Sylvan,storm::RationalFunction>,"Build the parametric model in symbolic representation",py::arg("model_description"),py::arg("formulas")=std::vector<std::shared_ptr<storm::logic::Formulaconst>>());
m.def("_build_sparse_model_from_drn",&storm::api::buildExplicitDRNModel<double>,"Build the model from DRN",py::arg("file"),py::arg("options")=storm::parser::DirectEncodingParserOptions());
m.def("_build_sparse_exact_model_from_drn",&storm::api::buildExplicitDRNModel<storm::RationalNumber>,"Build the model from DRN",py::arg("file"),py::arg("options")=storm::parser::DirectEncodingParserOptions());
m.def("_build_sparse_parametric_model_from_drn",&storm::api::buildExplicitDRNModel<storm::RationalFunction>,"Build the parametric model from DRN",py::arg("file"),py::arg("options")=storm::parser::DirectEncodingParserOptions());
m.def("build_sparse_model_from_explicit",&storm::api::buildExplicitModel<double>,"Build the model model from explicit input",py::arg("transition_file"),py::arg("labeling_file"),py::arg("state_reward_file")="",py::arg("transition_reward_file")="",py::arg("choice_labeling_file")="");
m.def("make_sparse_model_builder",&storm::api::makeExplicitModelBuilder<double>,"Construct a builder instance",py::arg("model_description"),py::arg("options"));
m.def("make_sparse_model_builder_exact",&storm::api::makeExplicitModelBuilder<storm::RationalNumber>,"Construct a builder instance",py::arg("model_description"),py::arg("options"));
m.def("make_sparse_model_builder_parametric",&storm::api::makeExplicitModelBuilder<double>,"Construct a builder instance",py::arg("model_description"),py::arg("options"));
py::class_<storm::builder::ExplicitModelBuilder<double>>(m,"ExplicitModelBuilder_Double","Model builder for sparse models")
py::class_<storm::builder::ExplicitModelBuilder<double>>(m,"ExplicitModelBuilder","Model builder for sparse models")
.def("build",&storm::builder::ExplicitModelBuilder<double>::build,"Build the model")
.def("export_lookup",&storm::builder::ExplicitModelBuilder<double>::exportExplicitStateLookup,"Export a lookup model")
;
py::class_<storm::builder::ExplicitModelBuilder<storm::RationalFunction>>(m,"ExplicitModelBuilder_RF","Model builder for sparse models")
py::class_<storm::builder::ExplicitModelBuilder<storm::RationalFunction>>(m,"ExplicitParametricModelBuilder","Model builder for sparse models")
.def("build",&storm::builder::ExplicitModelBuilder<storm::RationalFunction>::build,"Build the model")
.def("export_lookup",&storm::builder::ExplicitModelBuilder<storm::RationalFunction>::exportExplicitStateLookup,"Export a lookup model")
;
@ -164,6 +168,8 @@ void define_export(py::module& m) {
// TODO make one export_to_drn that infers which of the folliwng to use.
m.def("export_to_drn",&exportDRN<double>,"Export model in DRN format",py::arg("model"),py::arg("file"),py::arg("options")=storm::exporter::DirectEncodingOptions());
m.def("export_exact_to_drn",&exportDRN<double>,"Export model in DRN format",py::arg("model"),py::arg("file"),py::arg("options")=storm::exporter::DirectEncodingOptions());
m.def("export_parametric_to_drn",&exportDRN<storm::RationalFunction>,"Export parametric model in DRN format",py::arg("model"),py::arg("file"),py::arg("options")=storm::exporter::DirectEncodingOptions());
.def("set_produce_schedulers",&CheckTask<double>::setProduceSchedulers,"Set whether schedulers should be produced (if possible)",py::arg("produce_schedulers")=true)
;
// CheckTask
py::class_<CheckTask<storm::RationalNumber>,std::shared_ptr<CheckTask<storm::RationalNumber>>>(m,"ExactCheckTask","Task for model checking with exact numbers")
//m.def("create_check_task", &storm::api::createTask, "Create task for verification", py::arg("formula"), py::arg("only_initial_states") = false);
.def("set_produce_schedulers",&CheckTask<storm::RationalNumber>::setProduceSchedulers,"Set whether schedulers should be produced (if possible)",py::arg("produce_schedulers")=true)
;
py::class_<CheckTask<storm::RationalFunction>,std::shared_ptr<CheckTask<storm::RationalFunction>>>(m,"ParametricCheckTask","Task for parametric model checking")
//m.def("create_check_task", &storm::api::createTask, "Create task for verification", py::arg("formula"), py::arg("only_initial_states") = false);
m.def("_model_checking_sparse_engine",&modelCheckingSparseEngine<double>,"Perform model checking using the sparse engine",py::arg("model"),py::arg("task"),py::arg("environment")=storm::Environment());
m.def("_exact_model_checking_sparse_engine",&modelCheckingSparseEngine<storm::RationalNumber>,"Perform model checking using the sparse engine",py::arg("model"),py::arg("task"),py::arg("environment")=storm::Environment());
m.def("_parametric_model_checking_sparse_engine",&modelCheckingSparseEngine<storm::RationalFunction>,"Perform parametric model checking using the sparse engine",py::arg("model"),py::arg("task"),py::arg("environment")=storm::Environment());
m.def("_model_checking_dd_engine",&modelCheckingDdEngine<storm::dd::DdType::Sylvan,double>,"Perform model checking using the dd engine",py::arg("model"),py::arg("task"),py::arg("environment")=storm::Environment());
m.def("_parametric_model_checking_dd_engine",&modelCheckingDdEngine<storm::dd::DdType::Sylvan,storm::RationalFunction>,"Perform parametric model checking using the dd engine",py::arg("model"),py::arg("task"),py::arg("environment")=storm::Environment());
py::class_<storm::simulator::DiscreteTimeSparseModelSimulator<double>>dtsmsd(m,"_DiscreteTimeSparseModelSimulatorDouble","Simulator for sparse discrete-time models in memory (ValueType = double)");
py::class_<storm::simulator::DiscreteTimeSparseModelSimulator<ValueType>>dtsmsd(m,("_DiscreteTimeSparseModelSimulator"+vtSuffix).c_str(),"Simulator for sparse discrete-time models in memory (ValueType = double)");
py::class_<NDPomdpTrackerSparse<double>>ndetbelieftracker(m,"NondeterministicBeliefTrackerDoubleSparse","Tracker for belief states and uncontrollable actions");
py::class_<NDPomdpTrackerSparse<ValueType>>ndetbelieftracker(m,("NondeterministicBeliefTracker"+vtSuffix+"Sparse").c_str(),"Tracker for belief states and uncontrollable actions");
// py::class_<NDPomdpTrackerDense<double>> ndetbelieftrackerd(m, "NondeterministicBeliefTrackerDoubleDense", "Tracker for belief states and uncontrollable actions");
py::class_<storm::pomdp::ObservationTraceUnfolder<ValueType>>unfolder(m,("ObservationTraceUnfolder"+vtSuffix).c_str(),"Unfolds observation traces in models");
.def("new_row_group",&SparseMatrixBuilder<double>::newRowGroup,py::arg("starting_row"),"Start a new row group in the matrix")
.def("build",&SparseMatrixBuilder<double>::build,py::arg("overridden_row_count")=0,py::arg("overridden_column_count")=0,py::arg("overridden-row_group_count")=0,"Finalize the sparse matrix")
.def("get_last_row",&SparseMatrixBuilder<double>::getLastRow,"Get the most recently used row")
.def("get_current_row_group_count",&SparseMatrixBuilder<double>::getCurrentRowGroupCount,"Get the current row group count")
.def("get_last_column",&SparseMatrixBuilder<double>::getLastColumn,"the most recently used column")
.def("new_row_group",&SparseMatrixBuilder<RationalFunction>::newRowGroup,py::arg("starting_row"),"Start a new row group in the matrix")
.def("build",&SparseMatrixBuilder<RationalFunction>::build,py::arg("overridden_row_count")=0,py::arg("overridden_column_count")=0,py::arg("overridden-row_group_count")=0,"Finalize the sparse matrix")
.def("get_last_row",&SparseMatrixBuilder<RationalFunction>::getLastRow,"Get the most recently used row")
.def("get_current_row_group_count",&SparseMatrixBuilder<RationalFunction>::getCurrentRowGroupCount,"Get the current row group count")
.def("get_last_column",&SparseMatrixBuilder<RationalFunction>::getLastColumn,"the most recently used column")
.def("new_row_group",&SparseMatrixBuilder<ValueType>::newRowGroup,py::arg("starting_row"),"Start a new row group in the matrix")
.def("build",&SparseMatrixBuilder<ValueType>::build,py::arg("overridden_row_count")=0,py::arg("overridden_column_count")=0,py::arg("overridden-row_group_count")=0,"Finalize the sparse matrix")
.def("get_last_row",&SparseMatrixBuilder<ValueType>::getLastRow,"Get the most recently used row")
.def("get_current_row_group_count",&SparseMatrixBuilder<ValueType>::getCurrentRowGroupCount,"Get the current row group count")
.def("get_last_column",&SparseMatrixBuilder<ValueType>::getLastColumn,"the most recently used column")
py::class_<SparseModel<double>,std::shared_ptr<SparseModel<double>>,ModelBase>model(m,"_SparseModel","A probabilistic model where transitions are represented by doubles and saved in a sparse matrix");
.def("has_choice_labeling",[](SparseModel<ValueType>const&model){returnmodel.hasChoiceLabeling();},"Does the model have an associated choice labelling?")
.def("get_choice_index",[](SparseMdp<double>const&mdp,uint64_tstate,uint64_tactOff){returnmdp.getNondeterministicChoiceIndices()[state]+actOff;},py::arg("state"),py::arg("action_offset"),"gets the choice index for the offset action from the given state.")
.def("get_choice_index",[](SparseMdp<ValueType>const&mdp,uint64_tstate,uint64_tactOff){returnmdp.getNondeterministicChoiceIndices()[state]+actOff;},py::arg("state"),py::arg("action_offset"),"gets the choice index for the offset action from the given state.")
py::class_<SparseMarkovAutomaton<ValueType>,std::shared_ptr<SparseMarkovAutomaton<ValueType>>>(m,("Sparse"+vtSuffix+"MA").c_str(),"MA in sparse representation",model)
.def_property_readonly("convertible_to_ctmc",&SparseMarkovAutomaton<double>::isConvertibleToCtmc,"Check whether the MA can be converted into a CTMC.")
.def("convert_to_ctmc",&SparseMarkovAutomaton<double>::convertToCtmc,"Convert the MA into a CTMC.")
.def_property_readonly("convertible_to_ctmc",&SparseMarkovAutomaton<ValueType>::isConvertibleToCtmc,"Check whether the MA can be converted into a CTMC.")
.def("convert_to_ctmc",&SparseMarkovAutomaton<ValueType>::convertToCtmc,"Convert the MA into a CTMC.")
;
py::class_<SparseRewardModel<double>>(m,"SparseRewardModel","Reward structure for sparse models")
.def("get_zero_reward_states",&SparseRewardModel<double>::getStatesWithZeroReward<double>,"get states where all rewards are zero",py::arg("transition_matrix"))
.def("reduce_to_state_based_rewards",[](SparseRewardModel<double>&rewardModel,storm::storage::SparseMatrix<double>const&transitions,boolonlyStateRewards){returnrewardModel.reduceToStateBasedRewards(transitions,onlyStateRewards);},py::arg("transition_matrix"),py::arg("only_state_rewards"),"Reduce to state-based rewards")
.def("get_zero_reward_states",&SparseRewardModel<ValueType>::templategetStatesWithZeroReward<ValueType>,"get states where all rewards are zero",py::arg("transition_matrix"))
.def("reduce_to_state_based_rewards",[](SparseRewardModel<ValueType>&rewardModel,storm::storage::SparseMatrix<ValueType>const&transitions,boolonlyStateRewards){returnrewardModel.reduceToStateBasedRewards(transitions,onlyStateRewards);},py::arg("transition_matrix"),py::arg("only_state_rewards"),"Reduce to state-based rewards")
;
}
voiddefine_sparse_parametric_model(py::module&m){
// Parametric models
py::class_<SparseModel<RationalFunction>,std::shared_ptr<SparseModel<RationalFunction>>,ModelBase>modelRatFunc(m,"_SparseParametricModel","A probabilistic model where transitions are represented by rational functions and saved in a sparse matrix");
py::class_<SparseModelComponents<ValueType>,std::shared_ptr<SparseModelComponents<ValueType>>>(m,("Sparse"+vtSuffix+"ModelComponents").c_str(),"Components required for building a sparse model")
py::class_<SparseModelComponents<double>,std::shared_ptr<SparseModelComponents<double>>>(m,"SparseModelComponents","Components required for building a sparse model")
.def_readwrite("state_labeling",&SparseModelComponents<double>::stateLabeling,"The state labeling")
.def_readwrite("reward_models",&SparseModelComponents<double>::rewardModels,"Reward models associated with the model")
.def_readwrite("choice_labeling",&SparseModelComponents<double>::choiceLabeling,"A list that stores a labeling for each choice")
.def_readwrite("state_valuations",&SparseModelComponents<double>::stateValuations,"A list that stores for each state to which variable valuation it belongs")
.def_readwrite("choice_origins",&SparseModelComponents<double>::choiceOrigins,"Stores for each choice from which parts of the input model description it originates")
.def_readwrite("state_labeling",&SparseModelComponents<ValueType>::stateLabeling,"The state labeling")
.def_readwrite("reward_models",&SparseModelComponents<ValueType>::rewardModels,"Reward models associated with the model")
.def_readwrite("choice_labeling",&SparseModelComponents<ValueType>::choiceLabeling,"A list that stores a labeling for each choice")
.def_readwrite("state_valuations",&SparseModelComponents<ValueType>::stateValuations,"A list that stores for each state to which variable valuation it belongs")
.def_readwrite("choice_origins",&SparseModelComponents<ValueType>::choiceOrigins,"Stores for each choice from which parts of the input model description it originates")
// Continuous time specific components (CTMCs, Markov Automata):
.def_readwrite("rate_transitions",&SparseModelComponents<double>::rateTransitions,"True iff the transition values (for Markovian choices) are interpreted as rates")
.def_readwrite("exit_rates",&SparseModelComponents<double>::exitRates,"The exit rate for each state. Must be given for CTMCs and MAs, if rate_transitions is false. Otherwise, it is optional.")
.def_readwrite("markovian_states",&SparseModelComponents<double>::markovianStates,"A list that stores which states are Markovian (only for Markov Automata)")
.def_readwrite("rate_transitions",&SparseModelComponents<ValueType>::rateTransitions,"True iff the transition values (for Markovian choices) are interpreted as rates")
.def_readwrite("exit_rates",&SparseModelComponents<ValueType>::exitRates,"The exit rate for each state. Must be given for CTMCs and MAs, if rate_transitions is false. Otherwise, it is optional.")
.def_readwrite("markovian_states",&SparseModelComponents<ValueType>::markovianStates,"A list that stores which states are Markovian (only for Markov Automata)")
// Stochastic two player game specific components:
.def_readwrite("player1_matrix",&SparseModelComponents<double>::observabilityClasses,"Matrix of player 1 choices (needed for stochastic two player games")
.def_readwrite("player1_matrix",&SparseModelComponents<ValueType>::observabilityClasses,"Matrix of player 1 choices (needed for stochastic two player games")
xxxxxxxxxx