I use a list of variables to Minimize a particular quantity
{ Q, val1, Table[Pi, {i, 1, m, 1}}
where i is the subscript of P. However in this way I have
{ Q, val1, {P1, P2.. Pm}}
that does not work (it is necessary a list of variables).
This is my code, I have to minimize the total cost of the supply chain. For exemple for m=1 the P (production rate) that determinate the minimum cost should be 300:
Remove["Global`*"];
Av = 10;
Ab = 4;
b = 0.0001;
beta = 1;
Cv = 0.01;
Cb = 0.1;
Edom = 100;
g = 8;
hv = 0.0025;
hb = 0.004;
Z = 5;
alfa = 2;
delta = 5;
gamma = 1;
dev = 20;
w0 = 30;
k = 0.01;
e = 0.1;
ton = 0.1;
o = 0.1;
Ar = 2;
ctotfin = 100000000000000;
ctotparz = 100000000000000;
m = 0;
While[ctotparz <= ctotfin,
m++;
x = NMinimize[{(Av*Edom)/Round[Q] + (m*Ar*Edom)/
Round[Q] + ((m*(m - 1))/Edom + 1/Subscript[P, 1] -
Sum[(Sum[1/Subscript[P, j], {j, 2, i - 1}] +
Sum[1/Subscript[P, j], {j, 2, i}]), {i, 2, m}])*(
Edom*hv*Round[Q])/(2*m^2) +
Edom/m*(Sum[(g/Subscript[P, i] +
b*(Subscript[P, i])^beta + (w0/Subscript[P, i] + k)*
e), {i, 1, m}]) + (w0 +
Max[Table[Subscript[P, i], {i, 1, m, 1}]]*k)*o +
alfa*Edom*Cv + Edom/Round[Q]*(m*Ab + m*Z) +
Cb*Edom + (Round[Q]/(2*m) +
val1*dev*Sqrt[Round[Q]/(m*Subscript[P, 1]) + delta + ton])*
hb + (gamma*Edom*dev)/
Round[Q]*(Sqrt[
Round[Q]/(m*Subscript[P, 1]) + delta +
ton]*(PDF[NormalDistribution[0, 1], val1] -
val1*(1 - CDF[NormalDistribution[0, 1], val1])) + (m - 1)*
Sqrt[delta]*(PDF[
NormalDistribution[0,
1], (val1*Sqrt[
Round[Q]/(m*Subscript[P, 1]*delta) + ton/delta +
1])] - (val1*Sqrt[
Round[Q]/(m*Subscript[P, 1]*delta) + ton/delta +
1])*(1 -
CDF[NormalDistribution[0,
1], (val1*Sqrt[
Round[Q]/(m*Subscript[P, 1]*delta) + ton/delta +
1])]))),
Round[Q] > 0 && Table[Subscript[P, i], {i, 1, m, 1}] >= 101 &&
Table[Subscript[P, i], {i, 1, m, 1}] <= 300 &&
Table[Subscript[P, i], {i, 1, m, 1}] ∈
Integers && (1 -
CDF[NormalDistribution[0, 1],
val1] + (m - 1)*(1 -
CDF[NormalDistribution[0,
1], (val1*Sqrt[
Round[Q]/(m*Subscript[P, 1]*delta) + ton/delta +
1])])) == (hb*Round[Q])/(gamma*Edom) },
Flatten[{ Table[Subscript[P, i], {i, 1, m, 1}], Round[Q], val1}]];
ctotparz = x[[1]];
y = x[[2]];
Pparz = Table[Subscript[P, i], {i, 1, m, 1}] /. y[[1 ;; m]];
Qparz = Round[Round[Q] /. y[[m + 1]]];
val1parz = val1 /. y[[m + 2]];
If[ctotparz <= ctotfin, ( ctotfin = ctotparz; Qfin = Qparz;
Pfin = Pparz), ctotparz = ctotparz]];
mfin = m - 1;
Print[ctotfin];
Print[Qfin] ;
Print[Pfin];
Print[mfin]
Pi
is the symbol for the mathematical constant Pi $\endgroup$ – Rohit Namjoshi Nov 24 '18 at 17:14{ Q, val1, {P1, P2.. Pm}}
is how the programm see my list of variables, and it returns this error: ` Variables { Q, val1, {P1, P2.. Pm}} should be a list of variables`. I think that is for the double brackets. $\endgroup$ – E. Kelly Nov 24 '18 at 17:34Flatten[{Q, val1, {P1, P2, P3}}]
? Gives{Q, val1, P1, P2, P3}
. $\endgroup$ – Rohit Namjoshi Nov 24 '18 at 17:38Element[Table[Pi, {i, 1, m, 1}], Integers]
but this cause an elimination of some integers that actually determinate the minimum of my function! How is it possible? $\endgroup$ – E. Kelly Nov 24 '18 at 18:17indexed variable
rather than aSubscript
. If you wantP[i]
displayed as aSubscript
useFormat
, e.g., evaluateFormat[P[i_]] := Subscript[P, i]; pVar = Array[P, 3]
This will make the code that you post here something that will evaluate after being copied and pasted into a notebook. $\endgroup$ – Bob Hanlon Nov 24 '18 at 22:28