diff --git a/Makefile b/Makefile index 027693e..ba5847c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: traveltime constant peaked periodic linux debug windows visual docs +.PHONY: traveltime constant peaked periodic linux debug windows visual docs binding traveltime: clear ./test.wsl ./data/matrix.dat ./data/vehicletype.dat 300 200 15001 @@ -31,4 +31,7 @@ visual: python3 ./utils/visual.py docs: clear - doxygen Doxyfile \ No newline at end of file + doxygen Doxyfile +binding: + clear + ./src/compile.sh \ No newline at end of file diff --git a/README.md b/README.md index 82344db..15b027d 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,6 @@ With this script you can also merge differents PNG files into a unique GIF file, You can also run the library on Python keeping the optimization level given by C++. To make this you have to make the Pybinding of the code on your personal environment. -To do so, in the main folder run the following commands: +To do so, in the main folder you can just run: - python3 setup.py sdist - pip install . \ No newline at end of file + make binding \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 6f52d2c..c09a373 100644 --- a/docs/index.html +++ b/docs/index.html @@ -134,8 +134,7 @@
You can also run the library on Python keeping the optimization level given by C++. To make this you have to make the Pybinding of the code on your personal environment.
-To do so, in the main folder run the following commands:
python3 setup.py sdist -pip install . +To do so, in the main folder you can just run:
make bindingdiff --git a/src/binding.cc b/src/binding.cc index 7a88612..1cf9b47 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -9,14 +9,12 @@ #include "VehicleType.cpp" #include "VehicleType.hpp" -namespace py = pybind11; - PYBIND11_MODULE(TrafficModel,m) { m.doc() = "A library for generating traffic flow dynamics data."; // Graph class - py::class_(m,"Graph") - .def(py::init ()) + pybind11::class_ (m,"Graph") + .def(pybind11::init ()) .def("addVehicle", static_cast (&Graph::addVehicle)) .def("addRndmVehicles", &Graph::addRndmVehicles) .def("addVehiclesUniformly", &Graph::addVehiclesUniformly) @@ -37,8 +35,8 @@ PYBIND11_MODULE(TrafficModel,m) { .def("test", &Graph::test); // Street class - py::class_ (m,"Street") - .def(py::init ()) + pybind11::class_ (m,"Street") + .def(pybind11::init ()) .def("getOrigin",&Street::getOrigin) .def("getDestination",&Street::getDestination) .def("getIndex",&Street::getIndex) @@ -55,15 +53,15 @@ PYBIND11_MODULE(TrafficModel,m) { .def("remVehicle",&Street::remVehicle); // VehicleType class - py::class_ (m,"VehicleType") - .def(py::init ()) + pybind11::class_ (m,"VehicleType") + .def(pybind11::init ()) .def("getSource", &VehicleType::getSource) .def("getDestination", &VehicleType::getDestination) .def("setTransMatrix", &VehicleType::setTransMatrix); // Vehicle class - py::class_ (m,"Vehicle") - .def(py::init ()) + pybind11::class_ (m,"Vehicle") + .def(pybind11::init ()) .def_static("addVehicleType", static_cast (&Vehicle::addVehicleType)) .def_static("addVehicleType", static_cast (&Vehicle::addVehicleType)) .def_static("getVehicleType", &Vehicle::getVehicleType) @@ -81,11 +79,11 @@ PYBIND11_MODULE(TrafficModel,m) { .def("getTimeTraveled",&Vehicle::getTimeTraveled) .def("resetTimeTraveled",&Vehicle::resetTimeTraveled); - py::class_ >(m, "SparseMatrix") - .def(py::init<>()) - .def(py::init ()) - .def(py::init ()) - .def(py::init const &>()) + pybind11::class_ >(m, "SparseMatrix") + .def(pybind11::init<>()) + .def(pybind11::init ()) + .def(pybind11::init ()) + .def(pybind11::init const &>()) .def("insert", static_cast ::*)(int, int, bool)>( &SparseMatrix ::insert)) .def("insert", static_cast ::*)(int, bool)>( diff --git a/src/compile.sh b/src/compile.sh index a421ecf..a42ef3c 100755 --- a/src/compile.sh +++ b/src/compile.sh @@ -1,3 +1,3 @@ # -g++ -Wall -shared -std=c++20 -fPIC $(python3 -m pybind11 --includes) ./binding.cc -o TrafficModel$(python3-config --extension-suffix) +g++ -O3 -Wall -shared -std=c++20 -fPIC $(python3 -m pybind11 --includes) ./src/binding.cc -o TrafficModel$(python3-config --extension-suffix)