Skip to content

Instantly share code, notes, and snippets.

@User-DK
Created June 19, 2024 10:08
Show Gist options
  • Save User-DK/6bc76218d47cd0d7b170c69ad6a2ff57 to your computer and use it in GitHub Desktop.
Save User-DK/6bc76218d47cd0d7b170c69ad6a2ff57 to your computer and use it in GitHub Desktop.
template <typename AgentT>
void generate_bindings(py::module_ &m, std::string name)
{
std::string ClassName;
if(name == "Int"){
ClassName = "SimulationI"
}
else if(name == "Double"){
ClassName = "SimulationD"
}
py::class_<Seldon::Simulation<AgentT>>(m, ClassName)
.def(py::init<Seldon::Config::SimulationOptions &, const std::optional<std::string> &, const std::optional<std::string> &>())
.def("run", &Seldon::Simulation<AgentT>::run, "Run the Simulation",
py::arg("output_dir_path") = "./output")
.def("create_network", &Seldon::Simulation<AgentT>::create_network, "Create the network") // exposing it here so that it can be used to create a network file
.def("create_model", &Seldon::Simulation<AgentT>::create_model, "Create the model"); // exposing it here so that it can be used to create a model according to the simulation options
}
PYBIND11_MODULE(seldoncore, m)
{
m.doc() = "Python bindings for Seldon Cpp Engine";
generate_bindings<int>(m, "Int");
generate_bindings<double>(m, "Double");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment