<< Diffcode Overview Diffcode diffcode_der >>

Diffcode >> Diffcode > diffcode_CDcost

diffcode_CDcost

Objective function for optim.

Calling Sequence

[f,g,ind]=diffcode_CDcost(x,ind,fun,varargin)

Parameters

x

real vector or matrix

ind

integer parameter (see optim)

fun

Scilab function with calling sequence F=fun(x,varargin) varargin may be use to pass parameters p1,...pn

f

objective value at point x

g

gradient value at point x

Description

This function can be used as an optim external to minimize problem where gradient is too complicated to program. only a the function fun which computes the criterion is required

This function should be used as follow:

      [f,xopt,gopt]=optim(list(diffcode_CDcost,fun,p1,...pn),x0,...)
    

Examples

//function to minimize
function f=rosenbrock(x, varagin)
  p=varargin(1)
  f=1+sum( p*(x(2:$)-x(1:$-1)^2)^2 + (1-x(2:$))^2)
endfunction

x0=[1;2;3;4];
[f,xopt,gopt]=optim(list(diffcode_CDcost,rosenbrock,200),x0)

See Also

Authors

<< Diffcode Overview Diffcode diffcode_der >>