# Problems Minimizing a Function

I need to minimize a function, but it takes a long time. So I don't know if it's normal or if there's something wrong with my model.

u=(y0-μ)/(σ+r);
v=(y0-μ)/(σ-r);

a=PDF[NormalDistribution[μ,σ],u];
b=PDF[NormalDistribution[μ,σ],v];
q=CDF[NormalDistribution[μ,σ],u]-CDF[NormalDistribution[μ,σ],v];

c=μ+σ/q(b-a);
d=σ^2(1+1/q(v*b-u*a)-1/q^2(b-a)^2);
L=k((c-y0)^2+d^2);
γ=1-∫(y0-rσ)^(y0+rσn)(1/q)(1/(√2π σ) e^(((-1)/2)(yn-μ)^2/σ^2 ) dyn
γe=(1-γ)*m1+γ*(1-m2)
Cr=(ICr*(1-γ)*m1)/(1-γe)
Ca=(ICa*γ*m2)/(1-γe )
TC=L+(1-q)SC+Ca+Cr+Exp[1-Abs[1-μ/y0]]MC+(Exp[(σ1-σ)/(σ1-σ2)]-1)DC;

n=D[TC,{{σ,μ}}];

Solve[n==0,{σ,μ}]


The model is so complicated, so I will attach the wolfram mathematica file and related paper.

Thank you

• Could you explain what your model is better? From the paper you linked, it looks like you want to minimize TC. Look into NMinimize. The paper says the authors solved this in Mathematica. Have you tried writing them? – Chris K Apr 23 '19 at 11:20
• I'm sorry, I haven't listed Ca and Cr, so what distinguishes the paper model is I add Ca and Cr and before, I have tried it with NMinimize but the result was an error like this:: nminimize :: nnum: The function value is 1.16028 +8 [364.099 +0.513643 [0.999979] ^ 2] is not a number at {\ [Mu], \ [Sigma]} = {0.918621,0.716689}. @ChrisK – devi Apr 23 '19 at 11:35
• You'll get more help if you edit your question to make it more clear. Few people will click that link and read the paper to figure it out. – Chris K Apr 23 '19 at 11:51
• @devi 1) Do not use $\sigma _t^2=...$, use $\sigma _t=\sqrt {…}$. 2)Do not use RealAbs[], use branch with $\mu <20$. 3) Do not use Solve[], use FindRoot[n == {0, 0}, {{\[Sigma], 2.9}, {\[Mu], 6.8}}] .4) The function TC may not have local extremum. Therefore it is necessary to use NMinimize. – Alex Trounev Apr 23 '19 at 12:43
• @AlexTrounev I'm sorry, I don't understand from where you get 2.9 dan 6.8? – devi Apr 23 '19 at 13:25

## 1 Answer

After correcting all typos, Mathematica 12 finds a solution.

k = 8;
DC = 1;
MC = 1;
SC = 1;
IC = 1/10;
Subscript[y, 0] = 20;
r = 3;
Subscript[\[Sigma], 1] = 7256/10000;
Subscript[\[Sigma], 2] = 5/100;
u = (Subscript[y, 0] - \[Mu])/(\[Sigma] + r
);
v = (Subscript[y, 0] - \[Mu])/(\[Sigma] - r);
a = PDF[NormalDistribution[\[Sigma], \[Mu]], u];
b = PDF[NormalDistribution[\[Sigma], \[Mu]], v];
q = CDF[NormalDistribution[\[Sigma], \[Mu]], u] -
CDF[NormalDistribution[\[Sigma], \[Mu]], v];
Subscript[\[Mu], t] = \[Mu] + \[Sigma]/q (b - a);
Subscript[\[Sigma], t] =
Sqrt[\[Sigma]^2 (1 + (1/q (v*b) - (u*a)) - (1/q^2 (b - a)))];
L = k ((Subscript[\[Mu], t] - Subscript[y, 0])^2 +
\!$$\*SubsuperscriptBox[\(\[Sigma]$$, $$t$$, $$2$$]\));
TC = L + (1 - q)*SC + IC +
Exp[\[Mu]/Subscript[y, 0]]*
MC + (Exp[(Subscript[\[Sigma], 1] - \[Sigma])/(
Subscript[\[Sigma], 1] - Subscript[\[Sigma], 2])] - 1)*DC;
n = D[TC, {{\[Sigma], \[Mu]}}];

FindRoot[n == {0, 0}, {{\[Sigma], .19}, {\[Mu], 19.9}}]

(*Out[]= {\[Sigma] -> 0.19285, \[Mu] -> 19.9092}*)


To make sure that this is solution, we plot TC

ContourPlot[TC, {\[Sigma], .1, 1}, {\[Mu], 19, 20}, Contours -> 150,
PlotLegends -> Automatic, ColorFunction -> "Rainbow",
PlotRange -> {0, 10}]