Please help me...
S = 100;
hv[1] = 3.5; hv[2] = 4;
c[1] = 10; c[2] = 50;
Cv[1] = 2.4; Cv[2] = 3;
Cf[1] = 3; Cf[2] = 1.2;
s[1] = 0.3; s[2] = 0.1;
th[1] = 0.01; th[2] = 0.03;
A[1, 1] = 3; A[2, 1] = 2; A[1, 2] = 1; A[2, 2] = 1.1;
d[1, 1] = 1850; d[2, 1] = 2000; d[1, 2] = 2100; d[2, 2] = 1300;
k[1, 1] = d[1, 1]*0.05 ; k[1, 2] = d[1, 2]*0.05 ;
k[2, 1] = d[2, 1]*0.05 ; k[2, 2] = d[2, 2]*0.05 ;
so[1, 1] = 3.5; so[2, 1] = 1.5; so[1, 2] = 0.3; so[2, 2] = 0.6;
t[1, 1] = 1; t[2, 1] = 1; t[1, 2] = 1; t[2, 2] = 1;
e[1, 1] = 2; e[2, 1] = 2; e[1, 2] = 2; e[2, 2] = 2;
Y[1, 1] = 3; Y[2, 1] = 3; Y[1, 2] = 3; Y[2, 2] = 3;
hb[1, 1] = 2.4; hb[2, 1] = 1.3; hb[1, 2] = 4.5; hb[2, 2] = 3.6;
W[1] = 500; W[2] = 1000;
w[1] = 12; w[2] = 2; w[3] = 3;
P[1] = 8000; P[2] = 10000; P[3] = 6000;
NMinimize[{Sum[(S*de[i])/(m[i]*Q[i])+(hv[i]*Q[i])/2*((m[i]-1)*(1-de[i]/P[i])
+de[i]/P[i])+de[i]/(m[i]*Q[i])*(m[i]*c[i]+m[i]*Q[i]*Cv[i]+Cf[i])
+(m[i]*s[i]*de[i]*Q[i]*th[i])/2, {i, 1, 2}]
+Sum[(A[i, j]*d[i, j])/q[i, j]+(hb[i, j]*(1 - k[i, j])^2*q[i, j])/2
+(k[i, j]^2*so[i, j]*q[i, j])/2+(m[i]*t[i, j]*d[i, j])/q[i, j]
+(m[i]*e[i, j]*d[i, j])/q[i, j] + Y[i, j]*d[i, j], {i,1, 2}, {j, 1, 2}],
Table[{Table[1000 > q[i, j] > 0, {j, 1, 2}],Element[m[i], Integers], 1000 > m[i] >= 1,
Q[i] == Sum[q[i, j], {j, 2}] > 0, de[i] == Sum[d[i, j], {j, 2}],
Sum[(q[i, 1]*w[i]/m[i]), {i, 2}] <= W[1],Sum[(q[i, 2]*w[i]/m[i]), {i, 2}] <= W[2]}, {i, 1, 2}]},
Join[Flatten@{Table[{m[i], Table[q[i, j], {j, 1, 2}]}, {i, 1,2}]}, {Q[1], Q[2], de[1], de[2]}], MaxIterations -> 100]
I made this code for solving the problem. When i run, i got a message.
NMinimize::lvar: Variables {{{m[1],{q[1,1],q[1,2]}},{m[2],{q[2,1],q[2,2]}}}} should be a list of variables, with each element being a variable, or a list containing a variable and lower and upper bounds for the starting region for that variable. >>
I followed the tutorial of Nminimize, however, it happened. What am i wrong with this code?
{{{m[1],{q[1,1],q[1,2]}},{m[2],{q[2,1],q[2,2]}}}}
should be a list of variables, with each element being a variable". This error message is one of the more clear ones you will encounter in any programming language: you need a list where the elements are variables. You have a nested list of variables. Replace{Table[{m[i], Table[q[i, j], {j, 1, 2}]}, {i, 1, 2}]}
withFlatten@{Table[{m[i], Table[q[i, j], {j, 1, 2}]}, {i, 1, 2}]}
. (But also fix your mismatched brackets.) $\endgroup$