-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e666491
commit 30d91cb
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
flour = 4000; | ||
banana = 6; | ||
sugar = 2000; | ||
butter = 500; | ||
cocoa = 500; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
numBins = 5; | ||
numSlots = 5; | ||
|
||
chainLen = 4; | ||
chain = [2, 8, 1, 3]; | ||
|
||
numDescriptors = 8; | ||
weights = [3, 2, 2, 1, 1, 1, 1, 1]; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
int: n; % number of rooms | ||
set of int: ROOM = 1..n; | ||
int: m; % number of rectangle/offsets | ||
set of int: ROFF = 1..m; | ||
array[ROFF,1..4] of int: d; % defns | ||
set of int: ROT = 1..4; | ||
array[ROOM,ROT] of set of ROFF: shape; | ||
int: h; % height of roll | ||
int: maxl; % maximum length of roll | ||
|
||
n = 3; m = 7; | ||
d = [| 0,0,3,4 % (xoffset,yoffset,xsize,ysize) | ||
| 0,1,4,3 | ||
| 1,4,1,1 | ||
| 3,1,1,2 | ||
| 4,2,1,1 | ||
| 1,0,2,1 | ||
| 0,0,4,3 |]; | ||
shape = [| {1,3,4}, {2,5,6}, {}, {} | ||
| {1,3,4}, {2,5,6}, {}, {} | ||
| {1}, {7}, {}, {} |]; | ||
h = 7; maxl = 12; | ||
|
||
array[ROOM] of var 0..maxl: x; | ||
array[ROOM] of var 0..h: y; | ||
array[ROOM] of var ROT: rot; | ||
|
||
var 0..maxl: l; % length of carpet used | ||
|
||
solve minimize l; | ||
|
||
constraint forall(i in ROOM)(shape[i,rot[i]] != {}); | ||
|
||
constraint forall(i in ROOM)(forall(r in ROFF) | ||
(r in shape[i,rot[i]] -> | ||
(x[i] + d[r,1] + d[r,3] <= l /\ | ||
y[i] + d[r,2] + d[r,4] <= h))); | ||
|
||
constraint forall(i,j in ROOM where i < j) | ||
(forall(r1,r2 in ROFF) | ||
(r1 in shape[i,rot[i]] /\ | ||
r2 in shape[j,rot[j]] -> | ||
(x[i] + d[r1,1] + d[r1,3] <= x[j] + d[r2,1] | ||
\/ | ||
x[j] + d[r2,1] + d[r2,3] <= x[i] + d[r1,1] | ||
\/ | ||
y[i] + d[r1,2] + d[r1,4] <= y[j] + d[r2,2] | ||
\/ | ||
y[j] + d[r2,2] + d[r2,4] <= y[i] + d[r1,2]) | ||
)); | ||
|
||
output ["l = \(l);\nx = \(x);\ny = \(y);\nrot = \(rot);\n"]; | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
int: n = 8; % no of tasks max | ||
set of int: TASK = 1..n; | ||
int: foundations = 1; int: interior_walls =2; int: exterior_walls = 3; | ||
int: chimney = 4; int: roof = 5; int: doors = 6; | ||
int: tiles = 7; int: windows = 8; | ||
array[TASK] of int: duration = | ||
[7,4,3,3,2,2,3,3]; | ||
int: p = 8; % number of precedences | ||
set of int: PREC = 1..p; | ||
array[PREC,1..2] of TASK: pre = | ||
[| foundations, interior_walls | ||
| foundations, exterior_walls | ||
| foundations, chimney | ||
| exterior_walls, roof | ||
| exterior_walls, windows | ||
| interior_walls, doors | ||
| chimney, tiles | ||
| roof, tiles |]; | ||
|
||
|
||
int: t = sum(duration); | ||
array[TASK] of var 0..t: start; | ||
|
||
constraint forall(i in PREC) | ||
(start[pre[i,1]] + duration[pre[i,1]] <= start[pre[i,2]]); | ||
|
||
var int: makespan = max(t in TASK)(start[t] + duration[t]); | ||
|
||
solve minimize makespan; | ||
|
||
output [show(makespan)," = ", show(start)]; |