Until now, I have used the Gurobi, CPLEX and OR-Tools (GCO) interface to formulate mixed-integer-programming models.
Recently, I have discovered MiniZinc and want to utilize it to formulate big models.
With GCO I would only initialize the decision variables I need and only give the data without all non-existent index combinations.
Scheduling Example
Indices:
- $e$: employee
- $d$: day
- $s$: shift
- $z$: skill
This means, there are different employees, that can work on different days and different shifts within each day and the employees may also have different skills.
The way I visualize the data is in a 2D matrix. The row has the employee index and the column the tuple of indices $(d,s,z)$.
If the employee Bob, is available on Monday, for the shift 2 pm to 8 pm and has the skill bartender he gets the value 1 otherwise 0.
To avoid saving 0-values, I would construct Lists/HashMaps/Dictionaries that only contain non-zero elements. If for a certain index combination there is no entry within the lists then I do not construct any constraint with it or take it in consideration, hopefully saving computing time.
I am not sure if this is the best way to optimize running-time, but after implementing this method it was much faster than giving the solver the whole matrix with 0 values (non-existent index combinations).
Now, I would like to implement something similar, within MiniZinc using Python. This means I have to somehow give the data in such a form to hopefully make the solver run faster, instead of giving a large 2D matrix with many 0-values.