fminsearch problem "x not correct"
Show older comments
Dear all,
I am using MATLAB fminsearch function to minimize total cost wrt one variable.
Mathematically, equating the derivative to zero fits the scenario. Numerically, I using fminsearch which minimizes function wrt to a variable 'a'. Variable names are pretty long , so they have been shortened for convenience.
c = 360; b = 2.86*1e-6;
options = optimset;
options = optimset(options,'Display', 'off','TolX',1e-6,'TolFun',1e-6);
[x,fval,exitflag,output] = fminsearch(@(a)((c * (a+b) )/(c-64)*((1-d)^(c-64))),5*1e-9,options) % Equation 1
I am running the above equation in a loop by varying parameter d as in above eq.
0.112025106741765
0.0807987244135386
0.0566959141239181
0.0389242232814075
0.0262823154685904
0.0175303143416118
0.0115909029869100
0.00761728968485800
0.00498520646430364
0.00325359149672530
0.00211959284745732
0.00137920761942953
0.000896765531209532
For all values of d, I am getting following results
fval(cost) is obtained for value a which minimized the cost. For all the cases the a is the starting estimate as given in equation above i.e 5*1e-9. whereas a should be different for different values of d, since in equation all other variable have a constant value.
"When only d is varied, then the value of a which minimized the fval(cost) should also be different"
Kindly support.
Answers (2)
"When only d is varied, then the value of a which minimized the fval(cost) should also be different"
Don't think so. The expression ((1-d)^(c-64)) is just a global scale factor applied to your function. Global scale factors do not affect the result of a minimization and changing the global scale factor will have no effect as long as it doesn't change sign.
Aside from this, your function is linear in 'a', so the minimum will trivially lie at infinity. The only reason fminsearch isn't giving you that is because of your initial point and stopping criteria. If you try initializing at a=-1, you will get very different results.
Walter Roberson
on 25 Nov 2012
Edited: Walter Roberson
on 25 Nov 2012
0 votes
Your function minimizes at a = infinity * sign(d) at which point it becomes -infinity
In the area of 1E-9, the function value is on the order of 1E-13, far below your TolFun, so it is basically being detected as already being minimized enough.
Categories
Find more on Mathematics 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!