/* Ice cream production in Picat. From "Understanding and Using Linear Programming", page 16f. Ice cream production during a year given monthly demands. 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 ?=> % demand % jan feb mar apr may jun jul aug sep oct nov dec D = [0, 340, 330, 450, 650, 650, 550, 700, 680, 350, 440, 400, 650], Year = 12+1, % we start at month 0 StorageCost = 20, % decision variables X = new_list(Year), % production X :: 0.. 1000, S = new_list(Year), % surplus S :: 0..1000, Y = new_list(Year), % increase from month i-1 to month i Y :: 0..1000, Z = new_list(Year), % decrease from month i-1 to month i Z :: 0..1000, Obj #= 50*sum(Y) + 50*sum(Z) + StorageCost*sum(S), X[1] #= 0, S[1] #= 0, S[Year] #= 0, foreach(I in 2..Year) X[I] + S[I-1] - S[I] #= D[I] end, foreach(I in 2..Year) X[I] - X[I-1] #= Y[I] - Z[I] end, Vars = X ++ S ++ Y ++ Z, solve($[min(Obj),ff,split],Vars), println(obj=Obj), println(s=S), println(x=X), println(y=Y), println(z=Z), nl. go => true.