# What is wrong with my NMinimize code? [closed]

I don't know how to write the code to find Mu1 and Mu2. Can you help me Please?.

This is what I tried. • Please do not post images of your work. Please post your actual Mathematica code in the form of text that can be copied and pasted into a Mathematica notebook. Without such, it will be difficult to reproduce your problem and to experiment with possible solutions. – m_goldberg Apr 6 '19 at 23:39
• I'm sorry, i can't post the Mathematical code because I don't know to make easier posted here. I'm newbie :( But maybe you can download this file here : [link] (drive.google.com/file/d/1BtDzvN8FA190BFKj5pjd1C58BGUQlujm/…) @m_goldberg – Habib Asnan Apr 7 '19 at 0:06
• Maybe you should start with a simple Minimization problem, get that working, and then slowly make it more complex. For example, you are missing a comma after the {mu1, mu2} term. – bill s Apr 7 '19 at 0:56
• You may find this meta Q&A helpful for formatting code. – Michael E2 Apr 7 '19 at 2:01
• The error message {Method mu1, Method mu2} -> NelderMead is not a valid variable is showing you that it is multiplying {mu1, mu2} and Method -> "NelderMead" together. Make sure to add a comma after the } and before Method. I don't know if that will make the code work, but it's one problem that I see. – MassDefect Apr 7 '19 at 3:06

K11=30;K12=20;K22=10;m1=8;m2=20;δ1=1;δ2=0.5;θ1=1;θ2=0.4;
a=0.5;b=0.5;λ=0.05;α=10;β=3;P=500;d=300;CR=4;S=100;r=0.2;
H=5;CA=30;Q=131;σ1=Sqrt[a];σ2=Sqrt[b];

NMinimize[{(d/Q(K11(a+(μ1-m1)^2)+K22(b(μ2-m2)^2)+K12((μ1-m1)*
(μ2-m2)))Q/P+(K11 a+K22 b)((Q/P)^2/2-(Q/P)/λ+(1-Exp[-λ Q/P])/
λ^2)+((K11(2(μ1-m1)δ1)+K22(2(μ2-m2)δ2)+K12((μ1-m1)δ2+(μ2-m2)δ1))+
(K11 δ1^2+K22 δ2^2+K12 δ1 δ2))(Q/P-(1-Exp[-λ Q/P])/λ)+
((K11(2(μ1-m1)θ1)+K22(2(μ2-m2)θ2)+K12((μ1-m1)θ2+(μ2-m2)θ1))+
(K11(2 δ1 θ1)+K22(2 δ2 θ2)+K22(δ1 θ2+δ2 θ1)))(0.5(Q/P)^2-
(Q/P)/λ+(1-Exp[-λ Q/P])/λ^2)+(K11 θ1^2+K22 θ2^2+K12 θ1 θ2)*
((Q/P)^3/3-(Q/P)^2/λ+2(Q/P)/λ^2+2(1-Exp[-λ Q/P])/λ^3))+(d/Q*
CR((μ1+δ1)Q/P-δ1(1-Exp[-λ Q/P])/λ+θ1(0.5(Q/P)^2-(Q/P)/λ+
(1-Exp[-λ Q/P])/λ^2))+CR((μ2+δ2)Q/P-δ2(1-Exp[-λ Q/P])/λ+θ2*
(0.5(Q/P)^2-(Q/P)/λ+(1-Exp[-λ Q/P])/λ^2)))+(S d/Q)+(r*CR*
((μ1+δ1)Q/P-δ1(1-Exp[-λ Q/P])/λ+δ1(0.5(Q/P)^2-(Q/P)/λ+
(1-Exp[-λ Q/P])/λ^2))+CR((μ2+δ2)Q/P-δ2(1-Exp[-λ Q/P])/λ+θ2*
(0.5(Q/P)^2-(Q/P)/λ+(1-Exp[-λ Q/P])/λ^2))d/Q)+(d/Q CA)+
(d/Q(α Q/P+0.5 β(Q/P)^2)),


almost instantly returns

{16893.179829995734, {μ1 -> 8.355626751067383, μ2 -> 18.704839508932128}}


EDIT

Several errors in my translation found and fixed. The result is much closer, but still not exactly the same, as what the author found.

Please check all this very carefully, character by character, to try to understand why I made each change and to make certain that I have made no mistakes. I expect that additional errors remain.

• Thank you so much @Bill that's helpful. But in the paper that I review show the result Mu1 = 8 and Mu2 = 19.34 – Habib Asnan Apr 7 '19 at 13:00
• Woww, Thank you so much @Bill it works when I tried again with your code. And sorry for my slow respond because I can't open my PC since 3 days before. Once again thank you very much – Habib Asnan Apr 10 '19 at 15:04
• I'm sorry @Bill, maybe I need your help again with the same question about this function. There is some revision with the function, but I tried again with your answer it doesn't work well. Maybe you can see my newest quoestion about the revision of my function. Thanks – Habib Asnan Apr 30 '19 at 3:14