Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.68 KB

File metadata and controls

52 lines (36 loc) · 1.68 KB

Demand forecasting with OR-Tools

This is an example of how to use OR-Tools to solve a demand forecasting problem. The goal is to use historical demands by time to forecast a given demand in the future.

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

  • main.py implements a Least Absolute Deviation (LAD) Regression to forecast demand.
  • 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 demand forecasting 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.