1
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
4
<LANGUAGE>eng</LANGUAGE>
6
<TYPE>Scilab Function</TYPE>
8
<SHORT_DESCRIPTION name="NDcost"> generic external for optim
9
computing gradient using finite differences</SHORT_DESCRIPTION>
11
<CALLING_SEQUENCE_ITEM>[f,g,ind]=CDcost(x,ind,fun,varargin) </CALLING_SEQUENCE_ITEM>
16
<PARAM_NAME>x</PARAM_NAME>
18
<SP>: real vector or matrix</SP>
22
<PARAM_NAME>ind</PARAM_NAME>
24
<SP>: integer parameter (see optim)</SP>
28
<PARAM_NAME>fun</PARAM_NAME>
30
<SP>: Scilab function with calling sequence <VERB>F=fun(x,varargin)</VERB>
31
varargin may be use to pass parameters <VERB>p1,...pn</VERB></SP>
35
<PARAM_NAME>f</PARAM_NAME>
37
<SP>: criterion value at point <VERB>x</VERB> (see optim)</SP>
41
<PARAM_NAME>g</PARAM_NAME>
43
<SP>: gradient value at point <VERB>x</VERB> (see optim)</SP>
50
This function can be used as an external for <VERB>optim</VERB> to minimize
51
problem where gradient is too complicated to be programmed. only the
52
function <VERB>fun</VERB> which computes the criterion is required.</P>
54
This function should be used as follow:
55
<VERB>[f,xopt,gopt]=optim(list(CDcost,fun,p1,...pn),x0,...)</VERB></P>
59
//function to minimize
60
function f=rosenbrock(x,varagin)
62
f=1+sum( p*(x(2:$)-x(1:$-1)^2)^2 + (1-x(2:$))^2)
66
[f,xopt,gopt]=optim(list(NDcost,rosenbrock,200),x0)
77
<LINK>derivative</LINK>