Message Boards Message Boards

0
|
4682 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

A problem about the FindMinimum and the NMinimize?

Posted 5 years ago

I have a problem with the optimization by using Mathematica. It will provide the information which shows that '"The function value {28642.3 +4.0735910^-13i ,-2.0001710^-7+4.0612110^-16i,-0.000457679-5.3639110^-16i,<<17>>,0.000119602 -6.6041510^-17i,0.00141834 -4.4543710^-16i} is not a list of real numbers with dimensions {22} at {r,c1,c2,c3,c4,c5,c6,c7} = {4.,0.5,0.,0.,0.,0.,0.,0.}"' when I used the FindMinimum. However, it will keep running when I used NMinimize. What is the problem? Also, are there any problems in my code? Thanks for your help.

m = 7;
n = 20;
coh = 5;
phi = 0.01/180*Pi;
r0 = 2;
segamax = 10;
segamay = 15;
seta[j_] := 2*Pi*(j - 1)/(2 n + 1);
ck = {{c1}, {c2}, {c3}, {c4}, {c5}, {c6}, {c7}};

ce[j_] := 
c1*E^(-I*seta[j]) + c2*E^(-I*2*seta[j]) + c3*E^(-I*3*seta[j]) + 
c4*E^(-I*4*seta[j]) + c5*E^(-I*5*seta[j]) + c6*E^(-I*6*seta[j]) + 
c7*E^(-I*7*seta[j]);
dd[j_] := 
Sqrt[r^2*(E^(I*seta[j]) + ce[j])*(E^(-I*seta[j]) + 
Conjugate[ce[j]])]/r0;
eee[j_, t_] := E^(-I*t*seta[j]);
ma = Table[eee[j, t], {j, 1, (2*n + 1)}, {t, n, 1, -1}];
mb = Table[Conjugate[eee[j, t]], {j, 1, (2*n + 1)}, {t, 1, n}];
iii = Transpose[{Table[1, {2*n + 1}]}];
haib = Table[Join[ma[[i]], iii[[i]], mb[[i]]], {i, (2*n + 1)}];
ihaib = Inverse[N[haib]];

ee[j_] := (E^(I*seta[j]) + ce[j])/Conjugate[E^(I*seta[j]) + ce[j]];
bb[j_] := 
coh*Cot[phi]/(1 - Sin[phi])*dd[j]^(2 Sin[phi]/(1 - Sin[phi]));
cc[j_] := 
coh*Cos[phi]/(1 - Sin[phi])*dd[j]^(2 Sin[phi]/(1 - Sin[phi]))*ee[j];
fb = Table[{bb[j]}, {j, 2 n + 1}];
fc = Table[{cc[j]}, {j, 2 n + 1}];
d1 = ihaib.fb;
e1 = ihaib.fc;

d11 = d1[[1 ;; n + 1, 1]];
e11 = e1[[1 ;; n + 1, 1]];
es = e1[[m - 1 ;; n, 1]];

f[s_] := Which[s < m - 1, 
Sum[(m - s - k)*ck[[m - s - k, 1]]*f[m - k + 1], {k, m - s - 1}] + 
ck[[s, 1]], True, ck[[s, 1]]];
e2[k_] := 
Which[k == 
0, -2*Sum[j*f[j + 1]*d[j], {j, m - 1}] + (segamay - segamax)/2, 
k > m - 2, 0, True, -2*Sum[j*f[j + k + 1]*d[j], {j, m - k - 1}]];

e22 = Table[e2[k], {k, n, 0, -1}];
d[j_] := d1[[-j + n + 1, 1]];
e[j_] := e1[[-j + n + 1, 1]];
dx = 2 (segamax + segamay)/4 + coh*Cos[phi];

capf = Sum[Abs[es[[i, 1]]], {i, n - m + 2}];
cons = {d[0] - dx == 0, e[0] - e2[0] == 0, 
Table[e11[[i]] - e22[[i]] == 0, {i, n - m + 3, n}]};

SetOptions[Simplify, TimeConstraint -> Infinity];
(*sol=NMinimize[{capf,cons},{r,c1,c2,c3,c4,c5,c6,c7}]*)
sol = FindMinimum[{capf, 
cons}, {{r, 4}, {c1, 0.5}, {c2, 0}, {c3, 0}, {c4, 0}, {c5, 0}, {c6,
0}, {c7, 0}},
POSTED BY: Nick Wang

It appears that for some values of the variables the constraints get evaluated to complex values. Maybe using Abs would help there? Admittedly, this is just a guess.

POSTED BY: Daniel Lichtblau
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