Skip to content

hondong/opt_agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple CodeAgent for a Supply Chain Optimization Model Interpretations

Context

This repository is to accompany a live demo section in the online workshop AI agent masterclass on Jan 9, 2026. The entire presented deck of this workshop is available here. Code here covers the specific section (Slide 60-74) presented by Hongbo Dong.

Goal of this code repository is to illustrate LLM models can be used to create an interpretation agent to facilitate the interpretation of input/output and logic around an optimization model. The code contains two parts:

  1. A supply chain optimization model described in this paper: Optimisation model for multi-item multi-echelon supply chains with nested multi-level products. Quetschlich, Moetz & Otto, European Journal of Operations Research. 2020 with open data set. The benefits of using this set-up is its non-trivial and close to realisitic problems to be solved in supply chain planning/management.
  2. A simple CodeAgent (using HuggingFace smolagents library) that can write code to analyze model input/outputs. This is only to serve the purpose of a gentle introduction of writing AI agents to users with Operations Research background, and has no sophisticated implementation of agent memory or what so ever (which might come in future versions of this repository).

The idea of using LLM to resolve the bottleneck of human-model-interface is considered in recent research papers, such as:

  1. Democratizing Optimization with Generative AI, Simchi-Levi, Dai, Menache and Wu, Manuscript on SSRN, Oct. 2025
  2. Solver-in-the-Loop: MDP-Based Benchmarks for Self-Correction and Behavioral Rationality in Operations Research., Ao, Simchi-Levi and Wang, Jan. 2025

Running the model and agent in Docker environment

The code comes with Docker configurations to automatically install all necessary packages in an isolated container. Follow the steps to reproduce results presented in the live demo: (Current Dockerfile version works well for Mac OS X, for other systems, adjustments on Dockerfile may be needed to install pyscipopt properly.)

  1. Clone this repository.
git clone https://github.com/hbdong/opt_agent.git
cd opt_agent

Then create a HuggingFace account if you have not yet already. Further create an user access token. Replace the only line in my_secrets.py from

MY_HF_HUB_TOKEN = ""

to

MY_HF_HUB_TOKEN = "[my_created_hugging_face_token]"
  1. Make sure Docker daemon is running on your machine (e.g., if on Mac OS X terminal run open -a Docker). For Docker beginners, install Docker Desktop and open the app.

  2. Build Docker image and initiate a terminal.

docker build -t opt-agent .
docker run -it opt-agent bash
  1. Running the optimization model. The last code line in the previous step would open a terminal inside the Docker container. The optimization model can be then run by:
python3 src/run.py

Depending on performance of machine, this step will take approximately 10 minutes solving an SCIP optimization model (mixed-integer programming).

  1. Query the agent by.
python3 src/opt_agent.py -m 'Compute the number of distinct cars needed in each period from the input demand data. Save the results in a csv file and report the csv filename.'

Sample queries/prompts used in presentation are in the file example_prompts.py.

About

A simple CodeAgent for Supply Chain Optimization Model Interpretations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors