Message Boards Message Boards

Unexpected NMinimize result?

Posted 7 years ago

Hi All, I have a function that I need to minimize respect to parameters (you can assume/call them variable). My function is symmetric about variable. The first one is fine and gives the result what I want/need. But when I swapped variables meaning that c1 to c2, p1 to p2 and so on I get second model2 which is identical to model1 (only variables swapped). For second model NMinimize does not give me the same result. What I expect that result should be also swapped. What could be reason for that. Please see attachment. I could not pasted it without expanding numbers. Thanks for your suggestions..

parameters = {\[Gamma], \[Epsilon], \[CapitalDelta]G0\[Sigma], c1, c2,
    p1, p2, is1, is2};

model1 = (-2.1854299595896594` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 1.000000082740371`*^-10^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-2.148499751935299` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 7.0000000001`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-2.165853903098805` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 7.333333333433334`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-2.153728528742603` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 7.666666666766666`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-2.181932979446157` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 8.0000000001`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-2.3200797478784416` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 8.333333333433334`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-2.5442133224636487` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 8.666666666766666`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-2.9656716667220615` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 9.0000000001`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-3.4393085264061805` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 9.333333333433334`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-3.745588067468914` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 9.666666666766666`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-3.8528225095375954` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 10.0000000001`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-3.9562089647319443` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c1/(
      1 + 11.0000000001`^p1 (1/is1)^
        p1)) + \[Epsilon])^2 + (-2.5240218975771156` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 1.000000082740371`*^-10^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-2.5639652137289466` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 7.0000000001`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-3.1172018966206143` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 7.333333333433334`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-3.810722260825236` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 7.666666666766666`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-4.067452942005365` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 
       8.0000000001`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-4.177312132725905` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 8.333333333433334`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-4.175421643002467` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 8.666666666766666`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-4.205924127075317` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 9.0000000001`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-4.227977224090168` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 9.333333333433334`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-4.230734790283301` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 9.666666666766666`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-4.2429121713876` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 10.0000000001`^p2 (1/is2)^
        p2)) + \[Epsilon])^2 + (-4.266437299348293` + (
     E^-\[CapitalDelta]G0\[Sigma] \[Gamma])/(
     1 + E^-\[CapitalDelta]G0\[Sigma] + c2/(
      1 + 11.0000000001`^p2 (1/is2)^p2)) + \[Epsilon])^2;

fit = NMinimize[{model1, c1 > 0 && c2 > 0 && is1 > 0 && is2 > 0}, 
   parameters] // Chop

{0.0795293, {\[Gamma] -> 12.3332, \[Epsilon] -> 
   2.01739, \[CapitalDelta]G0\[Sigma] -> 1.54579, c1 -> 21.4073, 
  c2 -> 4.3431, p1 -> 22.8236, p2 -> 41.89, is1 -> 8.05893, 
  is2 -> 7.17248}}
Attachments:
POSTED BY: Okkes Dulgerci
3 Replies

Okkes,

I checked your assertion that they are the same with c1 and c2 and p1 and p2 interchanged by swapping the variables. the minimum is the same but the expression appears a bit different at first glance.

In[21]:= mod2 = 
  model2 /. p1 -> p3 /. p2 -> p1 /. p3 -> p2 /. c1 -> c3 /. c2 -> c1 /. 
   c3 -> c2;

In[29]:= fit2 = 
 NMinimize[{model1, c1 > 0 && c2 > 0 && is1 > 0 && is2 > 0}, 
   parameters] // Chop

Out[29]= {0.0795293, {\[Gamma] -> 12.3339, \[Epsilon] -> 
   2.01739, \[CapitalDelta]G0\[Sigma] -> 1.54585, c1 -> 21.4073, 
  c2 -> 4.34306, p1 -> 22.8236, p2 -> 41.89, is1 -> 8.05893, 
  is2 -> 7.17248}}

In[22]:= fit2 = 
 NMinimize[{mod2, c1 > 0 && c2 > 0 && is1 > 0 && is2 > 0}, 
   parameters] // Chop

Out[22]= {0.0795293, {\[Gamma] -> 12.904, \[Epsilon] -> 
   2.04318, \[CapitalDelta]G0\[Sigma] -> 1.61479, c1 -> 27.1908, 
  c2 -> 4.53967, p1 -> 22.8236, p2 -> 41.8901, is1 -> 7.16493, 
  is2 -> 7.97499}}

It appears, however, that because the system is nonlinear you are falling into a local minimum. You will need to guide the result by giving starting ranges for one or more of the parameters or add more constraints:

In[28]:= fit2 = 
 NMinimize[{model2, c1 > 0 && c2 > 0 && is1 > 0 && is2 > 0}, 
   parameters /. c2 -> {c2, 1, 10}] // Chop

Out[28]= {0.0795293, {\[Gamma] -> 19.644, \[Epsilon] -> 
   2.01061, \[CapitalDelta]G0\[Sigma] -> 2.08409, c1 -> 3.96859, 
  c2 -> 18.748, p1 -> 41.8901, p2 -> 22.8236, is1 -> 7.17438, 
  is2 -> 8.07787}}

Note that each solution that gives the same minimum (model1, mod2, and model2 with a starting range on c2) has different combinations of the parameters. This suggests that there are multiple combinations of parameters that have the same minimum. This appears to be an ill conditioned fit. You may need to go back to the physics for some guidance (or post more details about the origin of the expressions).

POSTED BY: Neil Singer
Posted 7 years ago

Hi Neil, thanks your for your time and suggestions. It makes sense now and I will discuss this with my advisor. As you said, maybe we need more constrains on parameters.

Best,

Okkes

POSTED BY: Okkes Dulgerci
Posted 7 years ago
POSTED BY: Okkes Dulgerci
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract