this repo has no description
at develop 1.8 kB view raw
1% RUNS ON mzn20_fd 2% RUNS ON mzn-fzn_fd 3% RUNS ON mzn20_fd_linear 4% RUNS ON mzn20_mip 5%------------------------------------------------------------------------------% 6% trucking.mzn 7% Jakob Puchinger 8% December 2007 9% vim: ft=zinc ts=4 sw=4 et tw=0 10% Original model comes from Peters Student Tim 11% There are N Trucks which have to can be used in every time period, 12% Each truck can transport a given Load of material. 13% Each truck has an associated cost. 14% In each time period a demand has to be fulfilled. 15% Truck1 and Truck2 have some further constraints, disallowing 16% them to be used more than once in consecutive or two consecutive time periods. 17% The goal is to minimise the cost 18%------------------------------------------------------------------------------% 19 20 % Time Periods 21int: T; 22 % Trucks 23int: N; 24 251..N: Truck1; 261..N: Truck2; 27 28array[1..T] of int: Demand; 29array[1..N] of int: Cost; 30array[1..N] of int: Loads; 31 32array[1..N, 1..T] of var 0..1: x; 33 34constraint 35 forall(t in 1..T)( 36 sum(i in 1..N)( Loads[i] * x[i,t]) >= Demand[t] 37 ); 38 39constraint 40 forall(tau in 1..T-2)( 41 sum(t in tau..tau+2)( x[Truck1, t] ) <= 1 42 ); 43 44constraint 45 forall(tau in 1..T-1)( 46 sum(t in tau..tau+1)( x[Truck2, t] ) <= 1 47 ); 48 49solve minimize 50 sum(i in 1..N)(sum(t in 1..T )( Cost[i] * x[i,t] )); 51 52 % required for showing the objective function 53var int: obj; 54constraint 55 obj = sum(i in 1..N)(sum(t in 1..T )( Cost[i] * x[i,t] )); 56 57output 58[ "Cost = ", show( obj ), "\n" ] ++ 59[ "X = \n\t" ] ++ 60[ show(x[i, t]) ++ if t = T then "\n\t" else " " endif | 61 i in 1..N, t in 1..T ] ++ 62[ "\n" ]; 63 64%------------------------------------------------------------------------------% 65% Data 66 67T = 6; 68N = 4; 69Cost = [30, 27, 23, 20]; 70Loads = [20, 18, 15, 13]; 71Demand = [27, 11, 14, 19, 25, 22]; 72Truck1 = 3; 73Truck2 = 4;