https://github.com/cschen1205/lmea
Large language model as optimizer
https://github.com/cschen1205/lmea
Last synced: 13 days ago
JSON representation
Large language model as optimizer
- Host: GitHub
- URL: https://github.com/cschen1205/lmea
- Owner: cschen1205
- Created: 2024-04-26T05:05:23.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-04-26T08:13:29.000Z (12 months ago)
- Last Synced: 2025-03-24T12:17:30.203Z (30 days ago)
- Language: Python
- Size: 32.2 KB
- Stars: 13
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LMEA
Code for paper: [Large Language Models as Evolutionary Optimizers](https://arxiv.org/abs/2310.19046)# Quick Start
## Setup Environment
```bash
# clone the repo
git clone https://github.com/cschen1205/LMEA.git# Go to directory
cd LEMA# create a new environment and activated it
python -m venv venv
source ./venv/bin/activate# pyconcorde installation and steup
pip install 'pyconcorde @ git+https://github.com/jvkersch/pyconcorde'# install dependent pacakges
pip install -r requirements.txt
```## Setup OpenAI Key
In the **src/utils.py** file, line 14, place the openai keys in array "**open_ai_keys**"
```bash
# place your openai key in this array. You can put multiple keys if you want to run multiple threads
open_ai_keys = [""]
```## Dataset
The TSP problems used in experiments of this page are located in Folder **data/tsp**
# Generate TSP problem files
run src/problem.py to generate TSP problems files
```bash
python scr/problem.py -name "tsp" -t "rue" -d "tsp" -nc 10,15 -pc 10
```## Run experiment
You can run the **experiment.py** python script for experiments. For example:
```python
python src/executor.py -n rue,clu -nc 10,15 -pi 1 -al ec
```The above command will run "**LLM-EC**" experiments on the these problem files:
```
clu_10_1.tsp (clu type, 10 nodes, 1st problem instance)
clu_15_1.tsp (clu type, 15 nodes, 1st problem instance)
rue_10_1.tsp (rue type, 10 nodes, 1st problem instance)
rue_15_1.tsp (rue type, 15 nodes, 1st problem instance)
```The log files of the experiments will be saved in folder "**data/logs**"
# Issues and FAQ
> Coming soon!
* Plese feel free to contact [@cschen]() if you encounter issues on the project.