Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have to optimize some contrained functions and I am trying to use NMaximize.

I have the following problem (see code below). I use NMaximize for the first function f1 (constraints c1 and variables with start intervals vs1) and get what I want to get. After that I use NMaximize for the function f2 (with c2 and vs2). After this second numerical optimization I run again the very same optimization for f1 again and get a different result although I have not changed the start intervals.

Could you please explain this? The only way I have found to solve this, is to restart everything with Quit but maybe you know an easier way to restart only the command NMaximize. I have also tried to set the Method for all optimizations but it does not make any difference, the results still vary.

f1 = 1445250/(13229 - 4223 Sqrt[30] (v1 + v2));
c1 = Sqrt[30] + 30 v1 >= 0 && Sqrt[30] + 30 v2 >= 0 && 
   Sqrt[30] + 30 v3 >= 0 && 
   2 + 45 v2 v3 + 45 v1 (v2 + v3) >= 2 Sqrt[30] (v1 + v2 + v3) && 
   v1 + v2 + v3 <= Sqrt[(2/15)];
vs1 = {{v1, 0, 0.01}, {v2, 0, 0.01}, {v3, 0, 0.01}};

f2 = 1445250/(13229 - 8446 Sqrt[30] v1);
c2 = 45 v1 <= Sqrt[30] && Sqrt[30] + 30 v1 >= 0;
vs2 = {{v1, 0, 0.01}};

NMaximize[{f1, c1}, vs1]
NMaximize[{f2, c2}, vs2]
NMaximize[{f1, c1}, vs1]

Out[8]= {190.206, {v1 -> 0.121716, v2 -> 0.121716, v3 -> -0.0111781}}
Out[9]= {190.206, {v1 -> 0.121716}}
During evaluation of In[1]:= NMaximize::cvmit: Failed to converge 
to the requested accuracy or precision within 100 iterations. >>
Out[10]= {190.253, {v1 -> 0.121759, v2 -> 0.121754, v3 -> -0.0111782}}
share|improve this question
1  
Could be due to different values of the random seed. Try SeedRandom[some value] before each NMaximize run and see if the results come out more consistently. –  Oleksandr R. Oct 29 '13 at 19:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.