Objective function value stuck at a point for fminsearch optimization
Show older comments
Hi,
I have the following code that I am trying to optimize using fminsearch but the objective function value stuck at 3 and doesn't go below that even though I have tried hundreds of different initial guesses. Code is given below:
function [ h ] = newk( param )
sum=0;
a = param(1);
b = param(2);
pnot = param(3);
sm = param(4);
st = param(5);
if sm<st
sum=sum+((-0.0607)-pnot+a*s^2+b*s)^2;
sum=sum+(1.1429-((a*st^3)/3 + (b*st^2)/2 + (pnot*st) - (0.0001*a)/3 - (0.001*b)/2 -0.1*pnot))^2;
sum=sum+(0-((a*sm^3)/3 + (b*sm^2)/2 + (pnot*sm) - (0.0001*a)/3 - (0.001*b)/2 -0.1*pnot))^2;
sum=sum+(1-(-1*cos(180/pi)*((a*st^3)/3+(b*st^2)/2+pnot*st - (0.001*a)/3 - (0.001*b)/2 - 0.1*pnot)/(a*st^2 + b*st+pnot)) -(-1*cos(180/pi)*(0)/(a*st^2 + b*st+pnot)))^2;
sum=sum+(9-(-1*cos(180/pi)*((a*sm^3)/3+(b*sm^2)/2+pnot*sm - (0.001*a)/3 - (0.001*b)/2 - 0.1*pnot)/(a*sm^2 + b*sm+pnot)) -(-1*cos(180/pi)*(0)/(a*sm^2 + b*sm+pnot)))^2;
sum=sum+(33-((sin(180/pi)*(thetanot+(a*st^3)/3+(b*st^2)/2+pnot*st)-(0.0001*a)/3-(0.001*b)/2-(0.1*pnot))/a*st^2 + b*st + pnot))^2;
sum=sum+(20-((sin(180/pi)*(thetanot+(a*sm^3)/3+(b*sm^2)/2+pnot*sm)-(0.0001*a)/3-(0.001*b)/2-(0.1*pnot))/a*sm^2 + b*sm + pnot))^2;
h=sum;
else
h = NaN;
end
end
Does anyone know how to improve the objective function value or any other better way to solve this problem?
Thanks in advance
8 Comments
Geoff Hayes
on 30 Apr 2016
One comment - don't use sum as variable name as that is the name of a MATLAB built-in function.
Also, can you describe what the above code is doing and how you are using it with fminsearch?
Walter Roberson
on 30 Apr 2016
Edited: Walter Roberson
on 30 Apr 2016
We need to know what your function s or your shared variable s is. Also thetanot.
You will get further if you replace the NaN with realmax
Research Guy
on 2 May 2016
Research Guy
on 2 May 2016
Walter Roberson
on 2 May 2016
There is no s in your inputs. If you are constructing a polynomial in s, then you need to declare s as symbolic and you need to apply the polynomial to some value, as fminsearch cannot minimize symbolic functions. And you still have not said what thetanot is.
Research Guy
on 2 May 2016
Walter Roberson
on 2 May 2016
Are there any constraints other than sm<st and thetanot = 0? Are any of the values constrained to be positive? Are any of the values constrained to be real?
Could I ask you to confirm that the sin() and cos() only go as far as including the 180/pi ? sin(180/pi) and nothing more? Not sin(180/pi * the next expression) ?
Research Guy
on 2 May 2016
Answers (1)
Walter Roberson
on 2 May 2016
0 votes
My tests indicate
With parameter order a, b, pnot, s, sm, st
Overall best: approximately 0.653438069904368368 @ [-498.85377613580755, 221.483885941090421, -24.4119283679524557, 0.535194263358808153, 0.200512886217885877, 0.259221258479518379]
Best zone [-498.853793637251272, -498.853749303693007; 221.483880618247383, 221.483889651746154; -24.4119284892117108, -24.4119283114555756; -0.0912086804123130035, 0.535194279291770658; 0.200512882607536191, 0.200512891548387973; 0.259221254021537173, 0.259221265398527967]
The zone shows the search area containing the minima -- for example, the best for the first parameter, a, is -498.853793637251272 to -498.853749303693007
Notice the wide range for the 4th parameter, s: there are two s values that are very close in producing minima; my tests suggest that if the minima from the two are different then it is not by much.
The function minimized was
@(a,b,pnot,s,sm,st)(-607/10000-pnot+a.*s.^2+b.*s).^2+(1/900000000).*(10000.*a.*st.^3+15000.*b.*st.^2+30000.*pnot.*st-a-15.*b-3000.*pnot-34287).^2+(-(1/3).*a.*sm.^3-(1/2).*b.*sm.^2-pnot.*sm+(1/30000).*a+(1/2000).*b+(1/10).*pnot).^2+(1+cos(180/pi).*((1/3).*a.*st.^3+(1/2).*b.*st.^2+pnot.*st-(1/3000).*a-(1/2000).*b-(1/10).*pnot)./(a.*st.^2+b.*st+pnot)).^2+(9+cos(180/pi).*((1/3).*a.*sm.^3+(1/2).*b.*sm.^2+pnot.*sm-(1/3000).*a-(1/2000).*b-(1/10).*pnot)./(a.*sm.^2+b.*sm+pnot)).^2+(33-(sin(180/pi).*((1/3).*a.*st.^3+(1/2).*b.*st.^2+pnot.*st)-(1/30000).*a-(1/2000).*b-(1/10).*pnot).*st.^2./a-b.*st-pnot).^2+(20-(sin(180/pi).*((1/3).*a.*sm.^3+(1/2).*b.*sm.^2+pnot.*sm)-(1/30000).*a-(1/2000).*b-(1/10).*pnot).*sm.^2./a-b.*sm-pnot).^2
6 Comments
Research Guy
on 2 May 2016
Walter Roberson
on 2 May 2016
Earlier I asked about s and you said,
"And I want to find the value of s too. s is also unknown."
Walter Roberson
on 2 May 2016
With the correction of s to st, the best point I find so far is
a, b, pnot, sm, st as -18880.3302350366, 800.005971699948, -6.37050123940534, 0.0330024744393139,0.0491711511781789
Research Guy
on 2 May 2016
Walter Roberson
on 3 May 2016
A few months ago I wrote my own hybrid minimizer, and I have been tuning it since then. It uses a mix of brute force and fminsearch.
Unfortunately there are a number of local minima, which make it difficult to find good values using fmincon or ga. I have not had an opportunity yet to try simulated annealing.
Walter Roberson
on 26 May 2016
I noticed that your present posted code is not exactly the same as what I had optimized for (because I used the previous version of what you posted), so I re-optimized. I find two distinct minima groups.
[0.000555266562406788 -0.00389896399517703 0.00542068020598675 2.10243357365545 3.63610626474992]
The above is an area near which the residue is 1.34 -ish
[-527.652989562935 8869.56269660075 -1709.20884144656 0.194959774473371 0.196426461653078]
The above is an area near which the residue is 1.73 -ish
The difference between 1.34-ish and 1.73-ish is significant, so you might prefer one to the other, but on the other hand both of those are much smaller than "typical" values of the surface. The best I was able to do with simulanneabnd starting from random points was in the 81 to 83 range, way out near
[-887.209391792006 14913.4480950303 -2874.95731224742 0.194120083848097 0.194986847835464]
Categories
Find more on Nonlinear Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!