Optimization options parameter 'findiffrelstep'
Show older comments
I want to know exactly what this parameter is. i have two variables one is in the range 10 to 25 and other in the range 1000 to 2000... I am wondering whether setting findiffrelstep will improve my solution performance. Thanks in advance. Pappu murthy
Answers (1)
Matt J
on 5 Oct 2014
0 votes
8 Comments
Matt J
on 5 Oct 2014
Pappu Murthy Commented
I don't think the explanation given is good enough for me. Because I am not an expert in this field. For. e.g. the description says "delta = v.*sign(x).*max(abs(x),TypicalX);" Delta I am assuming the step length DX that is normally used to compute function values and then divide the difference by DX. However, I am not clear on "abs(X)" does it mean of the two parameters I take abs value of both the parameters? Also "TypicalX" what is that for my example is that my parameter 1 which is in range 10 to 20 or parameter 2 which varies in the range 1000 to 2000. See so much confusion and I tried some values based on my limited understanding but I got nothing . No improvement. So in my case of say if I gave [10, 1400] as my starting point, what should I use "v" for 'findiffrelstep' parameter?
does it mean of the two parameters I take abs value of both the parameters?
Not you. You supply the vector v and fminunc will evaluate the expression
delta = v.*sign(x).*max(abs(x),TypicalX)
to compute the vector of step lengths, delta. Here, x is a vector and the expression is executed exactly as shown, I imagine. TypicalX is another optimization option settable by optimoptions.
If you think the finite differences are giving a bad approximation of the derivatives, then just set v smaller.
Pappu Murthy
on 7 Oct 2014
I think it is best if you show your objective function and your code and start talking in more detail about why you think you need to play with FinDiffRelStep.
I set [0.05 0.05] as FindiffRelStep. My variables are like [10,1100] so my step should be [.5 55]
I don't really follow that logic. The magnitude needed for delta is not related to the size of your variables. It is related to the size of the derivatives of your objective function. For example, if you're approximating the derivative of a 1D function f(x), the second order term in the Taylor remainder theorem gives you the error,
(f(x+delta)-f(x))/delta=f'(x)+f''(y)*delta
So, here the error term in the finite difference approximation of f'(x) is f''(y)*delta, where y is a point on the line between x and x+delta. You need to choose delta small enough to make the error term negligible. This requires some pre-analysis and some knowledge of a global bound on the second derivative magnitudes |f''(x)|.
Pappu Murthy
on 7 Oct 2014
Well, I can venture guesses. Are you sure the function is differentiable? Failure to move far from the initial point is often linked to non-smoothness in the objective functions. Common mistakes are putting quantizing operations like floor, fix,ceil, round in your objective function. Nearest-neighbor interpolation is similarly bad, since it contains rounding. You must also avoid common non-differentiable operators like sqrt, abs, etc... People doing least squares minimization often make the mistake of putting in sqrt() operations unnecessarily instead of working purely with the squares.
Another suggestion is to try fminsearch, which should work well enough since you only have 2 parameters. fminsearch doesn't use derivatives, so you don't have to fuss with finite difference parameters. However, quantizing operations will still cause problems, if you have them.
Pappu Murthy
on 8 Oct 2014
It is not doing a closed form differentiation anyway. So for finite difference it should not matter at all. Right?
No, the theory of the algorithms assumes that the function is twice continuously differentiable. I'm not sure what distinction you're drawing between "closed-form differentiable" and other kinds. Either the function is continuously differentiable, or it's not. If it is not, the assumptions of the algorithm are violated, and that's the end of the story.
Finite difference operations are just a way of approximating the true derivative. The algorithm performs better if you provide an analytical gradient calculation (whether or not it is closed form). If the true derivative doesn't exist, the finite difference will not produce anything more useful. It will produce some unstable value greatly depending on the delta step size you use.
Categories
Find more on Solver Outputs and Iterative Display 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!