objfun must calculate the nonlinear part of the objective function fx and (optionally) its gradient =fx for a specified n1 (n) element vector x. If there are no nonlinear objective variables (i.e., nonln=0), objfun will never be called by e04ug and objfun may be the dummy method E04UGN. (E04UGN is included in the NAG Library.)

Syntax

C#
public delegate void E04UG_OBJFUN(
	ref int mode,
	int nonln,
	double[] x,
	ref double objf,
	double[] objgrd,
	int nstate
)
Visual Basic
Public Delegate Sub E04UG_OBJFUN ( _
	ByRef mode As Integer, _
	nonln As Integer, _
	x As Double(), _
	ByRef objf As Double, _
	objgrd As Double(), _
	nstate As Integer _
)
Visual C++
public delegate void E04UG_OBJFUN(
	int% mode, 
	int nonln, 
	array<double>^ x, 
	double% objf, 
	array<double>^ objgrd, 
	int nstate
)
F#
type E04UG_OBJFUN = 
    delegate of 
        mode : int byref * 
        nonln : int * 
        x : float[] * 
        objf : float byref * 
        objgrd : float[] * 
        nstate : int -> unit

Parameters

mode
Type: System..::..Int32%
On entry: indicates which values must be assigned during each call of objfun. Only the following values need be assigned:
mode=0
objf.
mode=1
All available elements of objgrd.
mode=2
objf and all available elements of objgrd.
On exit: you may set to a negative value as follows:
mode-2
The solution to the current problem is terminated and in this case e04ug will terminate with ifail set to mode.
mode=-1
The nonlinear part of the objective function cannot be calculated at the current x. e04ug will then terminate with ifail=-1 unless this occurs during the linesearch; in this case, the linesearch will shorten the step and try again.
nonln
Type: System..::..Int32
On entry: n1, the number of nonlinear objective variables. These must be the first nonln variables in the problem.
x
Type: array<System..::..Double>[]()[][]
On entry: x, the vector of nonlinear variables at which the nonlinear part of the objective function and/or all available elements of its gradient are to be evaluated.
objf
Type: System..::..Double%
On exit: if mode=0 or 2, objf must be set to the value of the objective function at x.
objgrd
Type: array<System..::..Double>[]()[][]
On entry: the elements of objgrd are set to special values which enable e04ug to detect whether they are changed by objfun.
On exit: if mode=1 or 2, objgrd must return the available elements of the gradient evaluated at x.
nstate
Type: System..::..Int32
On entry: if nstate=1, e04ug is calling objfun for the first time. This parameter setting allows you to save computation time if certain data must be read or calculated only once.
If nstate2, e04ug is calling objfun for the last time. This parameter setting allows you to perform some additional computation on the final solution. In general, the last call to objfun is made with nstate=2+ifail (see []).
Otherwise, nstate=0.

See Also