Skip to content
forked from teshnizi/OptiMUS

Optimization Modeling Using mip Solvers and large language models

License

Notifications You must be signed in to change notification settings

Xinxin-m/OptiMUS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting started

Install dependencies

pip install google langchain google-generativeai langchain-google-genai python-dotenv gurobipy

Run the code

python gpt4or.py --verbose True --maxtry 5 --mode 105 --prob ./data/introduction_to_linear_optimization/problem_1

image OptiMUS: Optimization Modeling Using mip Solvers and large language models

This repository contains the official implementation for OptiMUS: Optimization Modeling Using mip Solvers and large language models.

Demo: https://optimus-solver.vercel.app/



optimus_agent

NLP4LP Dataset

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.

Usage

  1. Clone this repository

  2. 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):

    image
  3. 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()
...
  1. Install the requirements
pip install langchain
pip install openai
  1. Run the agent:
python gpt4or --model gpt-4 --maxtry 5 --mode 105 --verbose True --prob ./datasets/introduction_to_linear_optimization/problem_1

Modes and Options:

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

About

Optimization Modeling Using mip Solvers and large language models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 93.5%
  • Jupyter Notebook 6.5%