Constraint modeling with MiniZinc and GPT-4 is fun.

Here’s my problem:

“Given sets of planes and pilots and flights that happen 3x a day: find a fair assignment of planes/pilots to flights.”

Here’s a solution assuming 5 planes and 5 pilots:

Reply to this note

Please Login to reply.

Discussion

Pilot 5 and Plane 5 will fly in the first a lot of day 1. Pilot 3 and Plane 3 will fly in the first slot of day 2. Pilot 3 will fly Plane 1 in the second slot of day 3.

I’m not a MiniZinc expert but liked that I could describe the problem at a high level:

GPT-4 was able to iteratively better understand the problem domain. I started by fixing mechanical errors:

and then moved into fixing semantic errors:

GPT-4 eventually got me to a place where I could quickly add constraints to the problem domain. Here’s my final objective function:

Using MiniZinc with GPT-4 was pleasant. I would try again with a more realistic example from daily life. If you want to see the full code, I did a longer write up: https://buttondown.email/aostiles/archive/flight-optimization-with-minizinc-and-gpt-4/