Minimize and Table of variables

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]

• The code you posted, does not evaluate to the result you posted. Please edit and fix the syntax error and other problems. e.g. Pi is the symbol for the mathematical constant Pi – Rohit Namjoshi Nov 24 '18 at 17:14
• I didn't write the symbol for the mathematical constant Pi, as I said also in the post i is the subscript of P. { 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. – E. Kelly Nov 24 '18 at 17:34
• Maybe Flatten[{Q, val1, {P1, P2, P3}}]? Gives {Q, val1, P1, P2, P3}. – Rohit Namjoshi Nov 24 '18 at 17:38
• It works!! thankyou!! I have an other question, I put in Minimize this constriaint Element[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? – E. Kelly Nov 24 '18 at 18:17
• Use an indexed variable rather than a Subscript. If you want P[i] displayed as a Subscript use Format, e.g., evaluate Format[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. – Bob Hanlon Nov 24 '18 at 22:28