pip install google langchain google-generativeai langchain-google-genai python-dotenv gurobipy
python gpt4or.py --verbose True --maxtry 5 --mode 105 --prob ./data/introduction_to_linear_optimization/problem_1
This repository contains the official implementation for OptiMUS: Optimization Modeling Using mip Solvers and large language models.
Demo: https://optimus-solver.vercel.app/
You can download the dataset from https://nlp4lp.vercel.app/. Please note that NLP4LP is intended and licensed for research use only. The dataset is CC BY NC 4.0 (allowing only non-commercial use) and models trained using the dataset should not be used outside of research purposes.
-
Clone this repository
-
Download NLP4LP dataset zip file, extract the contents, and replace the empty
datasets/
folder in the root directory of the repo with the downloaded one (beside gpt4or.py): -
Add your OpenAI API key(s) in
configure.py
:
from utils import get_templates
api_keys = [
# "sk-API-KEY-1",
# "sk-API-KEY-2",
# ...
]
# Get templates
templates = get_templates()
...
- Install the requirements
pip install langchain
pip install openai
- Run the agent:
python gpt4or --model gpt-4 --maxtry 5 --mode 105 --verbose True --prob ./datasets/introduction_to_linear_optimization/problem_1
options:
-h, --help show this help message and exit
--model MODEL Model name
--prob PROB Problem path
--stdfname STDFNAME Description file name
--maxtry MAXTRY Maximum attempts
--human HUMAN Human test file
--aug AUG Number of augmentations. Uses the rephrases generated by using the --rephrase parameter.
--solver SOLVER Solver name (cvxpy/gurobi)
--mode MODE 102: Prompt, 103: Prompt + Debug, 104: Prompt + Debug + AutoTest, 105: Prompt + Debug + Human Test
--rephrase REPHRASE Number of rephrases. If more than 0, the agent will only generate rephrases of the problem and will
NOT solve the problem. The rephrased instances can then later be used by setting the aug parameter to
the number of rephrases.
--verbose VERBOSE Verbose mode