## Running the ILP Exercise Scripts

Activate the Python environment first, then change into the code directory:

```bash
source "$HOME/src/mod-env/bin/activate"
cd /Users/daniel/myshare/BigFiles/Teaching/Algochem-2026/Material/ilp-slides-exercises/Exercises/code
```

### Naming convention

The filenames now match the actual optimization task:

- `min-max-*` means: minimize the maximum value
- `max-min-*` means: maximize the minimum value
- `enumerate-ppp.py` solves the PPP enumeration / second-best-support task
- `min-max-ppp.py` solves the PPP min-max energy-barrier task

### Parameters

For Exercises 1 and 2, the command-line arguments are:

```text
i m M target_sum
```

with

- `i`: number of candidate variables
- `m`: lower bound for each chosen variable
- `M`: upper bound for each chosen variable
- `target_sum`: required sum of the chosen variables

For Exercise 2, the linearization also uses an auxiliary constant `U`.
In this setup, a valid and convenient choice is simply `U = M`, but the
sheet and code now keep these two roles separate in the notation.

For Exercises 3 and 4, the arguments are:

```text
fixed_numbers... target_sum
```

For Exercise 6, the PPP min-max script accepts an optional random seed:

```text
seed
```

### Copy-paste commands for all 6 exercises

```bash
# Exercise 1: generic min-max
python min-max-gen.py 10 0 20 100

# Exercise 2: generic max-min
python max-min-gen.py 10 0 20 100

# Exercise 3: fixed-number min-max
python min-max-spe.py 5 8 15 21 22 25 26 27 36 50 100

# Exercise 4: fixed-number max-min
python max-min-spe.py 5 8 15 21 22 25 26 27 36 50 100

# Exercise 5: PPP enumeration + second-best solution with different support
python enumerate-ppp.py

# Exercise 6: PPP min-max energy barriers + second-best solution
python min-max-ppp.py 42
```

### Short output only

If you only want the key result lines instead of the full solver log:

```bash
python min-max-gen.py 10 0 20 100 | egrep "Selected values|Maximum value|Verwendete Zahlen|Maximaler Wert"
python max-min-gen.py 10 0 20 100 | egrep "Selected values|Minimum value|Verwendete Zahlen|Minimaler Wert"
python min-max-spe.py 5 8 15 21 22 25 26 27 36 50 100 | egrep "Selected values|Maximum value|Verwendete Zahlen|Maximaler Wert"
python max-min-spe.py 5 8 15 21 22 25 26 27 36 50 100 | egrep "Selected values|Minimum value|Verwendete Zahlen|Minimaler Wert"
python enumerate-ppp.py | egrep "Optimal Solution|Second Best Solution|Total flow|Number of used hyperedges"
python min-max-ppp.py 42 | egrep "Optimal Solution|Second Best Solution|Objective variable z|Max r_|Number of used hyperedges"
```
