# Stream(LLM)

## Contained Material

This folder contains the following supplementary material of the paper Generating Streamlining Constraints with Large Language Models:
- A folder for each of the 21 problems (7 original, 7 disguised and 7 obfuscated problems) containing 
    - The MiniZinc encoding
    - A folder for the 15 training instances
    - A folder for the 35 training instances for the offline training (only for BH and CC problem)
    - A folder for the test instances
- The file Stream_LLM.py
- The extended workshop abstract: extended_abstract.pdf
- The longer version of the paper that contains additional experimental results: long_version.pdf

The following list shows which original problem belongs to which disguised and obfuscated problem:
- Car_Sequencing -> A 
- Hypergraph_Coloring -> B
- Balanced_Incomplete_Block_Design -> C
- Black_Hole -> D
- Carpet_Cutting -> E
- Social_Golfers -> F
- Vessel_Loading -> G


## Fixed parameters

The code contains the version of our Stream(LLM) approach as we used it, namely with
- Number of requested streamliners in each API call n = 5
- Number of returned streamliners k = 3
- The Large Language Models GPT-4o (pt-4o-2024-11-20) and Claude 3.5 Sonnet (claude-3-5-sonnet-20241022))

## Experimental Setup

We use MiniZinc version 2.8.3 and the Chuffed 0.13.1 solver. We access them via the openai 1.29.0 and anthropic 0.25.8 packages in Python 3.11.5. The experiments to evaluate the running time of the test instances are conducted on compute nodes with 2.40GHz, 10-core 2× Intel Xeon E5-2640 v4. 

# How to use the Stream_LLM.py file

Before using the Stream_LLM.py file, one has to ensure to following:

- All required Python packages, including anthropic and openai, have to be installed
- The API keys have to be set up
- minizinc_distr has to containt the location of the MiniZinc distribution, like "home/user/MiniZincIDE-2.8.3-bundle-linux-x86_64/bin/minizinc". In case there is no MiniZinc distribution available, one has to download it
- original_enc has to contain the path to the folder with all training instances
- instance_folder has to contain the path to the original encoding
- In the last line, one can decide whether to use the GPT-4o or Claude 3.5 Sonnet LLM by using one of the functions run_variant_on_gpt(system_request, adaptive) or run_variant_on_claude(system_request, adaptive)
    - system_request
    - adaptive is a boolean variable. Set it to True for the adaptive approach and the False for the static approach

The output should be a list of three streamliners.