/
production.pi
54 lines (36 loc) · 1.11 KB
/
production.pi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
Production-planning in Picat.
From the OPL model production.mod.
This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com
See also my Picat page: http://www.hakank.org/picat/
*/
import mip.
main => go.
go =>
Products = [kluski, capellini, fettucine],
NumProducts = Products.length,
Resources = [flour, eggs],
% Consumption[Products, Resources]
Consumption = [
[0.5, 0.2],
[0.4, 0.4],
[0.3, 0.6] ],
Capacity = [ 20, 40 ],
Demand = [ 100, 200, 300 ],
InsideCost = [0.6, 0.8, 0.3 ],
OutsideCost = [0.8, 0.9, 0.4],
% decision variables
Inside = new_list(NumProducts),
Outside = new_list(NumProducts),
Z #= sum([InsideCost[P]*Inside[P] + OutsideCost[P] * Outside[P] : P in 1..NumProducts]),
foreach(R in 1..Resources.length)
sum([Consumption[P,R]*Inside[P] : P in 1..NumProducts]) #<= Capacity[R]
end,
foreach(P in 1..NumProducts)
Inside[P] + Outside[P] #>= Demand[P]
end,
solve($[min(Z)], Inside ++ Outside),
println(z=Z),
println(inside=Inside),
println(outside=Outside),
nl.