How would a Constraint Programming formulation do on this problem: http://yetanothermathprogrammingconsultant.blogspot.com/2014/04/playing-with-ft10-job-shop-1.html. A straightforward translation of the MIP formulation into Minizinc can look like:

int: numjobs = 10; set of int: Jobs = 1..numjobs; array[Jobs,Stages] of int: ProcTimes = array[Jobs,Stages] of int: MachineNumbers = int: horizon = sum([ ProcTimes[j,s] | j in Jobs, s in Stages]); array[Jobs,Stages] of var 0..horizon: Start; % positive variables % order % no overlap constraint solve minimize makespan; |

This looks actually quite nice. We can drop the binary variables that deal with the overlap, and the objective is more intuitive. As most CP solvers don’t deal very well or not at all with continuous variables, we used integer variables. This is ok here as we deal with integer valued processing times. In the real world you may need to rescale and/or approximate these numbers. Unfortunately this model does not solve. I am looking at the cursor and don’t see any feedback about any progress:

There is an alternative formulation that is often much better: replace the no overlap constraints by a global constraint called cumulative. Not totally intuitive but we can translate the model quite easily. In addition we added some bounds on all variables:

include "globals.mzn"; int: numjobs = 10; set of int: Jobs = 1..numjobs; array[Jobs,Stages] of int: ProcTimes = array[Jobs,Stages] of int: Machine = int: last_end = sum([ ProcTimes[j,s] | j in Jobs, s in Stages]); array[Jobs,Stages] of var 0..last_start: Start; % order % no overlap constraint % helper |

Unfortunately still just a blinking cursor…

Any better Minizinc formulation available? Here are some alternative formulations which I have not tried out:

- https://github.com/MiniZinc/minizinc-benchmarks/blob/master/jobshop/jobshop.mzn
- https://github.com/hakank/hakank/blob/master/minizinc/jobshop.mzn

Some questions:

- No log when solving the models? One would like to see some progress log.
- How to debug models? Something like a limrow/limcol in GAMS or expand in AMPL? One could look at the “flatzinc” output, but that is difficult to digest.
- Can we set a time limit and then get the best solution so far?

Hi Erwin.

ReplyDeleteHere are some answers on your questions:

1) Logging: If you put an output section you see some progress, i.e. the intermittent solutions. Example:

output

[

"makespan: " ++ show(makespan) ++ "\n"

]

++

[

if s = 1 then "\n" else " " endif ++

show(Start[j,s])

| j in Jobs, s in Stages

];

2. For debugging models I tend to use "trace(show(....), true)" for showing indices etc. However, inferred domains etc are not shown.

3. Time limit: For fzn-gecode, the time limit is set with "-time millis". I run your model like this (on my Linux) with a time limit of 10s

$ minizinc -v -G gecode ft10.mzn -f "/home/hakank/gecode/svn/trunk/tools/flatzinc/fzn-gecode -a -mode stat -time 10000"

After 10s some statistics is shown.

Also, you should probably experiment with search strategies, for example (instead of "solve minimize makespan"):

solve :: int_search([Start[j,s] | j in Jobs, s in Stages ], first_fail, indomain_split, complete) minimize makespan;

This finds a makespan of 1110 fast, but then it's stuck.

I don't think my model (jobshop.mzn) is much faster.

/hakank

Thanks. for that info!

Delete