MSc thesis · Optimization2024Completed
Improving a Grey Wolf Optimizer for job shop scheduling
My MSc thesis in AI: three changes to a hybrid Grey Wolf Optimizer that keep the search from stalling. On 22 standard benchmark instances, the mean gap to the best-known makespan fell from 5.55% to 2.43%.
- Role
- Author, MSc thesis in AI
- Institution
- Polytechnic University of Madrid
- Date
- February 2024
- Stack
- Python, NumPy, Pandas, Jupyter, Matplotlib, Plotly
- Benchmarks
- Lawrence and Fisher–Thompson sets
- Python
- NumPy
- Pandas
- Metaheuristics
- Grey Wolf Optimizer
- Variable Neighborhood Search
- Job shop scheduling
- Statistical testing

- Problem
- Job shop scheduling: order every job's operations on shared machines so that the last one finishes as early as possible.
- Starting point
- A hybrid Grey Wolf Optimizer: a population of candidate schedules that recombines with its three best members and refines them with local search.
- What I added
- A per-machine swap mutation, duplicate control and a local search that accepts ties: three ways to keep the search from stalling.
- Mean RPD across 22 benchmark instances
- 2.43%
- Baseline: 5.55%. Lower is better.
- Instances where the best-known makespan was matched
- 9 / 22
- Baseline: 5 / 22
- Instances where the best schedule got worse
- 0 / 22
- 14 better, 8 tied
Computed from the thesis results table: baseline (5-mix) against final configuration (MIX-v2). RPD is the percentage above the best-known solution. Mean RPD is the average of the 22 per-instance values.
The order of operations alone can double the finish time
A job shop runs a set of jobs on a set of machines. Each job is a fixed sequence of operations, and each operation needs a specific machine for a known time. A machine handles one operation at a time, an operation cannot be interrupted, and a job's operations must run in order.
The only decision is the order in which each machine processes its operations. The objective is the makespan: the moment the last operation finishes. The toy instance below has three jobs and three machines. Changing nothing but the order takes the makespan from 17 time units to 8.
- J1M1 2→M2 3→M3 2
- J2M2 3→M3 2→M1 2
- J3M3 3→M1 2→M2 2
Same order on every machine: J1, J2, J3
J2 cannot start until t = 5 and J3 until t = 10: each waits for the jobs ranked ahead of it.
Best order: M1 J1, J3, J2 · M2 J2, J1, J3 · M3 J3, J2, J1
M2 never idles, so 8 is also the lower bound: its total load.
A pack of candidate schedules that follows its three best
Even that toy has 216 combinations of machine orders: 152 are impossible because jobs end up waiting on each other in a circle, and only one reaches 8. The count grows factorially with the number of jobs, so realistic instances are handled with metaheuristics, which trade the guarantee of an optimum for good schedules in bounded time.
The Grey Wolf Optimizer (GWO) is a population metaheuristic modeled on a hunting pack. Each wolf is a search agent holding one candidate schedule. The three best are the leaders (alpha, beta and delta), and the rest of the pack is pulled towards them.
The original GWO moves wolves through continuous space, and a schedule is an ordering, not a point. The hybrid version I started from turns "move towards the leaders" into crossover: new schedules inherit parts of the leaders' operation sequences, and a Variable Neighborhood Search (VNS) then refines them.
My thesis, Enhancement of Multi-Agent Grey Wolf Optimizer for Job Shop Scheduling, set out to lower the makespan by improving the balance between exploring new schedules and refining good ones.
One iteration: rank, recombine, refine, mutate, deduplicate
The pack starts as 200 schedules built with initialization rules. Each iteration runs the five stages below, and the number of iterations scales with the size of the instance. Items marked New are my additions.
01
Rank
Sort the pack by makespan
- Alpha, beta and delta: the three best schedules
02
Recombine
Crossover with alpha, beta and delta
- POX, keeping the best child
- PPX as the cheaper alternative
03
Refine
Variable Neighborhood Search
- Local search over several neighborhoods
- New: also accepts moves that keep the makespan equal (vns-v2)
04
Mutate
Adaptive mutation
- Swap, insert and inverse moves
- New: swap within one machine's sequence (swp_mqn)
05
Deduplicate
Duplicate control
- New: detect clone schedules
- New: replace them or mutate them lightly
Both crossovers were tested; the trade-off is in the lessons below. The loop repeats until the iteration budget is spent.
Three changes to keep the pack from stalling
A population search tends to stall in three ways: its moves are too coarse to polish a good schedule, the pack fills up with copies of the same schedule, or local search stops at the first plateau. Each change targets one of them.
| Component | Baseline hybrid GWO | Final configuration | Why it helps |
|---|---|---|---|
| Mutation | Adaptive swap, insert and inverse moves | Adds swp_mqn: swaps two operations within one machine's sequence | Refines the local sequence on one machine |
| Duplicates | No check: identical schedules can pile up | Clones are detected, then replaced or lightly mutated | Keeps the pack diverse; crossover between copies produces nothing new |
| VNS acceptance | Only moves that lower the makespan (<) | Also moves that keep it equal (≤), in vns-v2 | Lets the search cross plateaus of equal makespan instead of stopping |
In the results below, the final configuration is labelled MIX-v2 and the baseline 5-mix.
Every result is a gap to the best-known solution
A stochastic optimizer can look brilliant on one lucky run. I scored every configuration against published best-known solutions and compared configurations with non-parametric tests.
- Makespan
- The time at which the last operation finishes. The objective; lower is better.
- BKS
- Best-known solution: the lowest makespan reported for a benchmark instance.
- RPD
- Relative percentage deviation,
100 × (makespan − BKS) / BKS. 0% means the best-known solution was matched. - Benchmarks
- Lawrence (LA) and Fisher–Thompson (FT) instances. The final comparison covers FT06, FT10, FT20, LA01–LA04 and LA16–LA30.
- Wilcoxon test
- Compares two configurations at a time.
- Friedman + Nemenyi
- Ranks several configurations at once; the Nemenyi post-hoc test shows which pairs differ.
- Setup
- 200 wolves; the number of iterations scales with the size of each instance.
The mean gap shrank on 21 of 22 instances
Mean RPD per instance, baseline against final configuration. The one exception, FT06, was already at 0% for both.
Mean RPD (%)
The mean gap shrank on 21 of 22 instancesBenchmark instance
| Category | Baseline (5-mix) | Final (MIX-v2) |
|---|---|---|
| FT06 | 0% | 0% |
| FT10 | 8.08% | 4.71% |
| FT20 | 7.97% | 1.43% |
| LA01 | 0.02% | 0% |
| LA02 | 1.77% | 0.78% |
| LA03 | 4.34% | 2.73% |
| LA04 | 0.8% | 0.15% |
| LA16 | 5.72% | 3.56% |
| LA17 | 2.69% | 0.64% |
| LA18 | 2.65% | 1.16% |
| LA19 | 4.13% | 2.81% |
| LA20 | 3.73% | 2.04% |
| LA21 | 7.56% | 4.04% |
| LA22 | 10.32% | 4.05% |
| LA23 | 1.73% | 0.1% |
| LA24 | 7.97% | 4.12% |
| LA25 | 9.53% | 3.79% |
| LA26 | 5.56% | 1.44% |
| LA27 | 10.18% | 5.55% |
| LA28 | 9.18% | 2.85% |
| LA29 | 11.81% | 7.53% |
| LA30 | 6.34% | 0% |
Source: Thesis results table. MSc in Artificial Intelligence, Polytechnic University of Madrid, 2024.
Best schedules: 14 better, 8 tied, none worse
The best makespan found per instance, next to the mean RPD. ✓ marks a match with the best-known solution: 9 instances for the final configuration, 5 for the baseline.
| Instance | BKS | Baseline: mean RPD (%) | Baseline: best | Final: mean RPD (%) | Final: best |
|---|---|---|---|---|---|
| FT06 | 55 | 0.00 | 55 ✓ | 0.00 | 55 ✓ |
| FT10 | 930 | 8.08 | 937 | 4.71 | 936 |
| FT20 | 1165 | 7.97 | 1196 | 1.43 | 1178 |
| LA01 | 666 | 0.02 | 666 ✓ | 0.00 | 666 ✓ |
| LA02 | 655 | 1.77 | 655 ✓ | 0.78 | 655 ✓ |
| LA03 | 597 | 4.34 | 603 | 2.73 | 603 |
| LA04 | 590 | 0.80 | 590 ✓ | 0.15 | 590 ✓ |
| LA16 | 945 | 5.72 | 980 | 3.56 | 946 |
| LA17 | 784 | 2.69 | 792 | 0.64 | 784 ✓ |
| LA18 | 848 | 2.65 | 861 | 1.16 | 848 ✓ |
| LA19 | 842 | 4.13 | 850 | 2.81 | 850 |
| LA20 | 902 | 3.73 | 907 | 2.04 | 907 |
| LA21 | 1046 | 7.56 | 1080 | 4.04 | 1069 |
| LA22 | 927 | 10.32 | 993 | 4.05 | 935 |
| LA23 | 1032 | 1.73 | 1032 ✓ | 0.10 | 1032 ✓ |
| LA24 | 935 | 7.97 | 966 | 4.12 | 951 |
| LA25 | 977 | 9.53 | 1033 | 3.79 | 983 |
| LA26 | 1218 | 5.56 | 1261 | 1.44 | 1218 ✓ |
| LA27 | 1235 | 10.18 | 1297 | 5.55 | 1264 |
| LA28 | 1216 | 9.18 | 1290 | 2.85 | 1241 |
| LA29 | 1152 | 11.81 | 1221 | 7.53 | 1207 |
| LA30 | 1355 | 6.34 | 1375 | 0.00 | 1355 ✓ |
Source: thesis results table. Baseline = 5-mix, final = MIX-v2.
Ties in VNS came free; a cheaper crossover did not
What worked
- Accepting ties in VNS added exploration without degrading final quality.
- POX with best-child selection produced slightly better final schedules than PPX.
What did not, or not yet
- PPX needed fewer fitness evaluations but gave up some final quality, so operators have to be judged on quality and compute cost together.
- Runs still vary: on FT10 the best schedule is 0.65% above the BKS, but the mean RPD is 4.71%.
- LA29 and LA27 remain the furthest from best-known, at 7.53% and 5.55% mean RPD.
Next: adaptive mutation, tabu memory and more objectives
- Drive mutation with a measure of population similarity, so the search reacts as soon as the pack starts to converge.
- Add Tabu Search to filter moves that revisit known schedules and cut redundant evaluations.
- Try discrete GWO variants (DGWO, BGWO) and multi-objective versions that also weigh energy use or due dates.
Next case study
TempoParking: a live parking directory built with AI agents
Related
Machine learning2025Published
Gym exercise recognition from IMU data
A CNN-LSTM that recognises gym exercises from wrist-worn motion sensors.
Backtest realism
The backtest that lies, and the rules that stop it
The rules that keep short-horizon backtests honest: stop, take-profit, entry inside every bar, reaction latency, slippage, and payout and leakage audits.

Market systems2025–2026Stopped
Polymarket trading systems
Prediction-market research: a dataset builder, a 15-minute bot and a Rust + Python HFT recorder.
Get in touch
Working on something similar? I am happy to compare notes.