Contents Previous Next Subchapters

Optimization Without Derivatives Using Conjugate Directions
Syntax [xoutnout] = conjdir(function f xinstepmitrlevel)
See Also neldermead , conjgrad , minline , nlsq

Description
Uses a variation of Powell's conjugate direction method to minimize the function f(x) with respect to x.

f(x)
this function call returns the value of the objective function at x; i.e., f(x). The argument x has the same type and dimension as xin.

xin
The real or double-precision column vector xin specifies the initial estimate for the value of x that minimizes f(x).

step
The column vector step has the same type and dimension as xin. The minimization process has converged when the absolute change in x(i) is less than or equal to step(i) for all i. All of the elements of step must be greater than 0.

mitr
The integer scalar mitr specifies the number of iterations of the conjugate gradient method to try before giving up on convergence.

level
The integer scalar level specifies the amount of tracing to do inside of conjdir:
Case Heading Description
level > 1 f(xitr) objective function for current iteration
level > 2 xitr' value of x for current iteration
level > 3 nf number calls to f during line search
level > 3 beta a step factor during line search
level > 3 f(x) an objective function value during line search
level > 3 bmin final step factor during line search
level > 3 fmin final objective function value during line search

xout
If nout is not present, the ith column of the return value xout is the value of x at the ith iteration. Otherwise the return value xout is the value of x at the last iteration. The return value xout has the same type and row dimension as xin.

nout
The return value nout is optional. If it is present, it contains the number of iterations required for convergence. If nout is present and convergence cannot be achieved, the return value of nout is mitr+1 and xout is the best value of x so far. If nout is not present and convergence cannot be achieved, the return value of xout is equal to novalue .

Example
The program below solves the problem
                      2            2
     minimize (x  - 1)  +  (x  - 2)   with respect to x
                1            1
The solution to this problem is x = {1, 2}

clear
function f(x) begin
     return (x(1) - 1.)^2 + (x(2) - 2.)^2
end
level = 0
mitr  = 20
xin   = {0., 0.}
step  = {.01, .01}
[xout, nout]  = conjdir(function f, xin, step, mitr, level)
print "nout =", nout
print "xout'=", xout'