/* Freight Transfer in Picat. From John Hooker, A framework for integrating optimization and constraint programming, http://web.tepper.cmu.edu/jnh/sara07.pdf page 23f """ Transport 42 tons of freight using 8 trucks, which come in 4 sizes... Truck Number Capacity Cost type available (tons) per truck 1 3 7 90 2 3 5 60 3 3 4 50 4 3 3 40 """ There are 4 optimal solutions with Z = 530 This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> % % data % N = 4, % number of trucks Available = [3,3,3,3], % number trucks available Capacity = [7,5,4,3], % capacity of truck Cost = [90,60,50,40], % cost per truck Transport = 42, % ton to transport % number of trucks to use of each size X = new_list(N), X :: 0..N, Z #= sum([X[I]*Cost[I] : I in 1..N]), % Z #= 530, Transported #= sum([X[I]*Capacity[I] : I in 1..N]), Transported #>= Transport, foreach(I in 1..N) X[I] #<= Available[I] end, solve($[min(Z)],X), % solve($[],X), println(z=Z), println(transported=Transported), println(x=X), fail, nl. go => true.