Python developers can now solve AI planning problems (such as the vehicle routing problem and employee rostering) with OptaPy.
Let me show you how to use OptaPy and a bit of plain Python code to tackle a typical mathematical optimization problem: generate a better school timetable schedule for teachers and students.
OptaPy is an open source project. It’s available in PyPI and is usable from a normal Python installation.
Internally, OptaPy uses OptaPlanner, so it does need a JDK installed.
Currently, it’s significantly slower than using OptaPlanner directly from Java (or Kotlin for that matter), but it works and we’re investigating ways to bridge the performance gap.
Let’s optimize that school timetable in pure Python. Feel free to follow along in the OptaPy Jupyter notebook.
- Python 3.9 or later is installed.
- JDK 11 or later is installed with the environment variable JAVA_HOME configured to the JDK installation directory.
- Create a new Python virtual environment.
python3 -m venv optapy-env
- Activate the Python virtual environment.
- Use pip to install OptaPy.
python3 -m pip install optapy