/* Blending problem in Picat. From the OPL model blending.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 => NbMetals = 3, NbRaw = 2, NbScrap = 2, NbIngo = 1, CostMetal = [22.0, 10.0, 13.0], CostRaw = [6.0, 5.0], CostScrap = [7.0, 8.0], CostIngo = [9.0], Low = [0.05, 0.30, 0.60], Up = [0.10, 0.40, 0.80], PercRaw = [[0.20, 0.01], [0.05, 0.0], [0.05, 0.30]], PercScrap = [[0.0, 0.01], [0.60, 0.0], [0.40, 0.70]], PercIngo = [[0.10], [0.45], [0.45]], Alloy = 71.0, % decision variables P = new_list(NbMetals), P :: 0.0..100.0, R = new_list(NbRaw), R :: 0.0..100.0, S = new_list(NbScrap), S :: 0.0..100.0, I = new_list(NbIngo), I :: 0..100, % integer Metal = new_list(NbMetals), Metal :: 0.0..100.0, Z #= sum([CostMetal[J] * P[J] : J in 1..NbMetals]) + sum([CostRaw[J] * R[J] : J in 1..NbRaw]) + sum([CostScrap[J] * S[J] : J in 1..NbScrap]) + sum([CostIngo[J] * I[J] : J in 1..NbIngo]) , foreach(J in 1..NbMetals) Metal[J] #>= Low[J] * Alloy, Metal[J] #<= Up[J] * Alloy, Metal[J] #= P[J] + sum([PercRaw[J,K] * R[K] : K in 1..NbRaw]) + sum([PercScrap[J,K] * S[K] : K in 1..NbScrap]) + sum([PercIngo[J,K] * I[K] : K in 1..NbIngo]) end, Alloy #= sum(Metal), solve($[min(Z)],P++R++S++I), println(p=P), println(r=R), println(s=S), println(i=I), println(metal=Metal), println(z=Z), nl. % p: [0.04666666666666576, 0.0, 0.0] % r: [0.0, 0.0] % s: [17.41666666666666, 30.33333333333334] % i: [32] % metal: [3.5500000000000003, 24.849999999999994, 42.6] % z: 653.61