Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 1.69 KB

File metadata and controls

51 lines (35 loc) · 1.69 KB

Shift assignment with OR-Tools

This app solves a shift asssignment problem using OR-Tools. Given a set of previously planned shifts, in this app we assign workers to those shifts, taking different factors into account such as availability and qualification.

The most important files created are main.py and input.json.

  • main.py implements a MIP shift assignment solver.
  • input.json is a sample input file.

Usage

Follow these steps to run locally.

  1. The packages listed in the requirements.txt will get bundled with the app as defined in the app.yaml manifest. When working locally, make sure that these are installed as well:

    pip3 install -r requirements.txt
  2. Run the command below to check that everything works as expected:

    python3 main.py -input input.json -output output.json -duration 30
  3. A file output.json should have been created with a solution to the shift assignment problem.

Mirror running on Nextmv Cloud locally

Pre-requisites: Docker needs to be installed.

To run the application locally in the same docker image as the one used on the Nextmv Cloud, you can use the following command:

cat input.json | docker run -i --rm \
-v $(pwd):/app ghcr.io/nextmv-io/runtime/python:3.11 \
sh -c 'pip install -r requirements.txt > /dev/null && python3 /app/main.py'

You can also debug the application by running it in a Dev Container. This workspace recommends to install the Dev Container extension for VSCode. If you have the extension installed, you can open the workspace in a container by using the command Dev Containers: Reopen in Container.