Created
June 19, 2024 10:08
-
-
Save User-DK/6bc76218d47cd0d7b170c69ad6a2ff57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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