How do I optimise a nonlinear objective function which doesn't have an analytical expression

13 views (last 30 days)
I have an objective function that for particular design variables( say s1 and s2) gives a value, but I don't exactly have any analytical expression.( It goes through a lot of nonlinear newton iteration and converges to find the a solution). How do I proceed to optimize such objective function? Its a unconstrained optimization problem. I tried using conjugate gradient, but as i don't have any analytical expression, its difficult to find alpha

Accepted Answer

Sean de Wolski
Sean de Wolski on 8 May 2013
The objective function doesn't have to have an analytical expression. Write the function you wish to optimize as a function and then pass it into one of the minimizers in the Optimization Toolbox or Global Optimization Toolbox.
Optim Toolbox if your function is not discontinuous
doc fminunc
Global Optim Toolbox if the function is discontinuous:
doc patternsearch
doc ga
And in base ML:
doc fminsearch

More Answers (2)

Alan Weiss
Alan Weiss on 8 May 2013
As long as you have a program that eventually gives the value of the objective function, you can use fminsearch or (with Optimization Toolbox) fminunc to minimize the function. Just be sure to put your design variables, s1 and s2, into a vector that is usually called x.
Suppose your objective function is
function obj = myfunction(x)
s1 = x(1)
s2 = x(2)
% now do your calculations that give obj
Then to find the minimum, call
solution = fminsearch(@myfunction,x0)
where x0 is an initial guess for the minimization. See the fminsearch function reference page or the documentation on minimizing functions of several variables.
Alan Weiss
MATLAB mathematical toolbox documentation

Ayan
Ayan on 10 May 2013
Thanks a lot!! I guess I got it

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!