Created
December 22, 2024 02:06
-
-
Save bokner/4a820481def36e4101fe50436ac732e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include "globals.mzn"; | |
int: N; | |
int: M; | |
set of int: CARS = 1..N; | |
set of int: MACHINES = 1..M; | |
array[CARS, MACHINES] of int: durations; | |
array[CARS] of var CARS: sequence; | |
%% Start times (car i starts at start[i] at machine j) | |
array[CARS, MACHINES] of var 0..sum(durations): start; | |
% The car sequence[i] is at position i in the sequence. | |
constraint alldifferent(sequence); | |
constraint forall(c in CARS, m in 1..M-1)( | |
start[c, m] + durations[c, m] <= start[c, m +1] | |
); | |
constraint forall(c in 1..N-1, m in MACHINES)( | |
start[sequence[c], m] + durations[sequence[c], m] <= start[sequence[c+1], m] | |
); | |
var 0..sum(durations) : makespan; | |
constraint makespan = start[sequence[N], M] + durations[sequence[N], M] - 1; | |
solve minimize makespan; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
% Data (.dzn)
N = 11;
M = 5;
durations = array2d(1..11, 1..5, [
375, 12, 142, 245, 412,
632, 452, 758, 278, 398,
12, 876, 124, 534, 765,
460, 542, 523, 120, 499,
528, 101, 789, 124, 999,
796, 245, 632, 375, 123,
532, 230, 543, 896, 452,
14, 124, 214, 543, 785,
257, 527, 753, 210, 463,
896, 896, 214, 258, 259,
532, 302, 501, 765, 988]);