Hi Todd, Thanks again for your reply. It solves for 3 trucks and 2 port
In[2]:= NMinimize[{total,
t11 >= 0 && t12 >= 0 && t21 >= 0 && t22 >= 0 && t31 >= 0 &&
t32 >= 0 &&
(t11 + n[[1, 1]] <= t12 ||
t12 + n[[1, 2]] <= t11) && (t21 + n[[2, 1]] <= t22 ||
t22 + n[[2, 2]] <= t21) &&
(t31 + n[[3, 1]] <= t32 || t32 + n[[3, 2]] <= t31) &&
(t11 + n[[1, 1]] <= t21 || t21 + n[[2, 1]] <= t11) &&
(t11 + n[[1, 1]] <= t31 || t31 + n[[3, 1]] <= t11) &&
(t21 + n[[2, 1]] <= t31 || t31 + n[[3, 1]] <= t21) &&
(t12 + n[[1, 2]] <= t22 || t22 + n[[2, 2]] <= t12) &&
(t12 + n[[1, 2]] <= t32 || t32 + n[[3, 2]] <= t12) &&
(t22 + n[[2, 2]] <= t32 || t32 + n[[3, 2]] <= t22) &&
total >= t11 + n[[1, 1]] && total >= t12 + n[[1, 2]] &&
total >= t21 + n[[2, 1]] && total >= t22 + n[[2, 2]] &&
total >= t31 + n[[3, 1]] && total >= t32 + n[[3, 2]]}, {t11, t12,
t21, t22, t31, t32, total}]
Out[2]= {41., {t11 -> 0., t12 -> 22., t21 -> 19., t22 -> 0.,
t31 -> 28., t32 -> 13., total -> 41.}}
But when it comes 5 trucks and 4 port it takes hours, an I have to quit the program..
NMinimize[{total,
t11 >= 0 && t12 >= 0 && t13 >= 0 && t14 >= 0 && t21 >= 0 &&
t22 >= 0 && t23 >= 0 && t24 >= 0 && t31 >= 0 && t32 >= 0 &&
t33 >= 0 && t34 >= 0 && t41 >= 0 && t42 >= 0 && t43 >= 0 &&
t44 >= 0 && t51 >= 0 && t52 >= 0 && t53 >= 0 && t54 >= 0 &&
(t11 + n[[1, 1]] <= t12 || t12 + n[[1, 2]] <= t11) &&
(t11 + n[[1, 1]] <= t13 || t13 + n[[1, 3]] <= t11) &&
(t11 + n[[1, 1]] <= t14 || t14 + n[[1, 4]] <= t11) &&
(t12 + n[[1, 2]] <= t13 || t13 + n[[1, 3]] <= t12) &&
(t12 + n[[1, 2]] <= t14 || t14 + n[[1, 4]] <= t12) &&
(t13 + n[[1, 3]] <= t14 || t14 + n[[1, 4]] <= t13) &&
(t21 + n[[2, 1]] <= t22 || t22 + n[[2, 2]] <= t21) &&
(t21 + n[[2, 1]] <= t23 || t23 + n[[2, 3]] <= t21) &&
(t21 + n[[2, 1]] <= t24 || t24 + n[[2, 4]] <= t21) &&
(t22 + n[[2, 2]] <= t23 || t23 + n[[2, 3]] <= t22) &&
(t22 + n[[2, 2]] <= t24 || t24 + n[[2, 4]] <= t22) &&
(t23 + n[[2, 3]] <= t24 || t24 + n[[2, 4]] <= t23) &&
(t31 + n[[3, 1]] <= t32 || t32 + n[[3, 2]] <= t31) &&
(t31 + n[[3, 1]] <= t33 || t33 + n[[3, 3]] <= t31) &&
(t31 + n[[3, 1]] <= t34 || t34 + n[[3, 4]] <= t31) &&
(t32 + n[[3, 2]] <= t33 || t33 + n[[3, 3]] <= t32) &&
(t32 + n[[3, 2]] <= t34 || t34 + n[[3, 4]] <= t32) &&
(t33 + n[[3, 3]] <= t34 || t34 + n[[3, 4]] <= t33) &&
(t41 + n[[4, 1]] <= t42 || t42 + n[[4, 2]] <= t41) &&
(t41 + n[[4, 1]] <= t43 || t43 + n[[4, 3]] <= t41) &&
(t41 + n[[4, 1]] <= t44 || t44 + n[[4, 4]] <= t41) &&
(t42 + n[[4, 2]] <= t43 || t43 + n[[4, 3]] <= t42) &&
(t42 + n[[4, 2]] <= t44 || t44 + n[[4, 4]] <= t42) &&
(t43 + n[[4, 3]] <= t44 || t44 + n[[4, 4]] <= t43) &&
(t51 + n[[5, 1]] <= t52 || t52 + n[[5, 2]] <= t51) &&
(t51 + n[[5, 1]] <= t53 || t53 + n[[5, 3]] <= t51) &&
(t51 + n[[5, 1]] <= t54 || t54 + n[[5, 4]] <= t51) &&
(t52 + n[[5, 2]] <= t53 || t53 + n[[5, 3]] <= t52) &&
(t52 + n[[5, 2]] <= t54 || t54 + n[[5, 4]] <= t52) &&
(t53 + n[[5, 3]] <= t54 || t54 + n[[5, 4]] <= t53) &&
(t11 + n[[1, 1]] <= t21 || t21 + n[[2, 1]] <= t11) &&
(t11 + n[[1, 1]] <= t31 || t31 + n[[3, 1]] <= t11) &&
(t11 + n[[1, 1]] <= t41 || t41 + n[[4, 1]] <= t11) &&
(t11 + n[[1, 1]] <= t51 || t51 + n[[5, 1]] <= t11) &&
(t21 + n[[2, 1]] <= t31 || t31 + n[[3, 1]] <= t21) &&
(t21 + n[[2, 1]] <= t41 || t41 + n[[4, 1]] <= t21) &&
(t21 + n[[2, 1]] <= t51 || t51 + n[[5, 1]] <= t21) &&
(t31 + n[[3, 1]] <= t41 || t41 + n[[4, 1]] <= t31) &&
(t31 + n[[3, 1]] <= t51 || t51 + n[[5, 1]] <= t31) &&
(t41 + n[[4, 1]] <= t51 || t51 + n[[5, 1]] <= t41) &&
(t12 + n[[1, 2]] <= t22 || t22 + n[[2, 2]] <= t12) &&
(t12 + n[[1, 2]] <= t32 || t32 + n[[3, 2]] <= t12) &&
(t12 + n[[1, 2]] <= t42 || t42 + n[[4, 2]] <= t12) &&
(t12 + n[[1, 2]] <= t52 || t52 + n[[5, 2]] <= t12) &&
(t22 + n[[2, 2]] <= t32 || t32 + n[[3, 2]] <= t22) &&
(t22 + n[[2, 2]] <= t42 || t42 + n[[4, 2]] <= t22) &&
(t22 + n[[2, 2]] <= t52 || t52 + n[[5, 2]] <= t22) &&
(t32 + n[[3, 2]] <= t42 || t42 + n[[4, 2]] <= t32) &&
(t32 + n[[3, 2]] <= t52 || t52 + n[[5, 2]] <= t32) &&
(t42 + n[[4, 2]] <= t52 || t52 + n[[5, 2]] <= t42) &&
(t13 + n[[1, 3]] <= t23 || t23 + n[[2, 3]] <= t13) &&
(t13 + n[[1, 3]] <= t33 || t33 + n[[3, 3]] <= t13) &&
(t13 + n[[1, 3]] <= t43 || t43 + n[[4, 3]] <= t13) &&
(t13 + n[[1, 3]] <= t53 || t53 + n[[5, 3]] <= t13) &&
(t23 + n[[2, 3]] <= t33 || t33 + n[[3, 3]] <= t23) &&
(t23 + n[[2, 3]] <= t43 || t43 + n[[4, 3]] <= t23) &&
(t23 + n[[2, 3]] <= t53 || t53 + n[[5, 3]] <= t23) &&
(t33 + n[[3, 3]] <= t43 || t43 + n[[4, 3]] <= t33) &&
(t33 + n[[3, 3]] <= t53 || t53 + n[[5, 3]] <= t33) &&
(t43 + n[[4, 3]] <= t53 || t53 + n[[5, 3]] <= t43) &&
(t14 + n[[1, 4]] <= t24 || t24 + n[[2, 4]] <= t14) &&
(t14 + n[[1, 4]] <= t34 || t34 + n[[3, 4]] <= t14) &&
(t14 + n[[1, 4]] <= t44 || t44 + n[[4, 4]] <= t14) &&
(t14 + n[[1, 4]] <= t54 || t54 + n[[5, 4]] <= t14) &&
(t24 + n[[2, 4]] <= t34 || t34 + n[[3, 4]] <= t24) &&
(t24 + n[[2, 4]] <= t44 || t44 + n[[4, 4]] <= t24) &&
(t24 + n[[2, 4]] <= t54 || t54 + n[[5, 4]] <= t24) &&
(t34 + n[[3, 4]] <= t44 || t44 + n[[4, 4]] <= t34) &&
(t34 + n[[3, 4]] <= t54 || t54 + n[[5, 4]] <= t34) &&
(t44 + n[[4, 4]] <= t54 || t54 + n[[5, 4]] <= t44) &&
total >= t11 + n[[1, 1]] && total >= t12 + n[[1, 2]] &&
total >= t13 + n[[1, 3]] && total >= t14 + n[[1, 4]] &&
total >= t21 + n[[2, 1]] && total >= t22 + n[[2, 2]] &&
total >= t23 + n[[2, 3]] && total >= t24 + n[[2, 4]] &&
total >= t31 + n[[3, 1]] && total >= t32 + n[[3, 2]] &&
total >= t33 + n[[3, 3]] && total >= t34 + n[[3, 4]] &&
total >= t41 + n[[4, 1]] && total >= t42 + n[[4, 2]] &&
total >= t43 + n[[4, 3]] && total >= t44 + n[[4, 4]] &&
total >= t51 + n[[5, 1]] && total >= t52 + n[[5, 2]] &&
total >= t53 + n[[5, 3]] && total >= t54 + n[[5, 4]]}, {t11, t12,
t13, t14, t21, t22, t23, t24, t31, t32, t33, t34, t41, t42, t43,
t44, t51, t52, t53, t54, total}] // Timing
I don't know what to do.. And there should be easy way to set up equations and constraints, doing by hand is very painful and easy to make mistakes..
Regards,