On entry

mode

indicates whether fObj or gObj or both must be assigned during the present call of funobj (0  mode 2).

This parameter can be ignored if Derivative linesearch is  selected (the default) and if Derivative level = 1 or 3.   In this case, mode will always have the value 2, and fObj and all elements of gObj must be assigned.

Otherwise, snopt will call funobj with mode =0, 1 or 2. You may test mode to decide what to do:

If mode = 2, assign fObj and the known components of gObj.

If mode = 1, assign the known components of gObjfObj is not required and is ignored.

If mode = 0, only fObj need be assigned; gObj is ignored.

nnObj

is the number of variables involved in f(x) (0 < nnObj n).  These must be the first nnObj variables in the problem.

x(nnObj)

contains the nonlinear objective variables x. The array x must not be altered.

nState

indicates the first and last calls to funobj.

If nState = 0, there is nothing special about the current call to funobj.

If nState = 1, SNOPT is calling your subroutine for the first time.  Some data may need to be input or computed and saved.  Note that if there are nonlinear constraints, the first call to funcon will occur before the first call to funobj.

If nState 2, SNOPT is calling your subroutine for the last   time.  You may wish to perform some additional computation on the final solution.  Note again that if there are nonlinear constraints, the last call to funcon will occur before the last call to funobj.

In general, the last call is made with nState = 2 + inform, where inform indicates the status of the final solution.  In particular, if nState = 2, the current x is optimal; if nState  = 3, the problem appears to be infeasible; if nState  = 4, the problem appears to be unbounded; and if nState  = 5, the iterations limit was reached.  In some cases, the solution may be nearly optimal if nState  = 11; this value occurs if the linesearch procedure was unable to find an improved point.

If the nonlinear functions are expensive to evaluate, it may be desirable to do nothing on the last call, by including a statement of the form

if (nState .ge. 2) return

at the start of the subroutine.

cu(lencu), iu(leniu), ru(lenru)

are the character, integer and real arrays of user work-space provided to snopt.  They may be used to pass information into the function routines and to preserve data between calls.

In special applications the functions may depend on some of the internal variables stored in snopt's work-space arrays cw, iw, rw.  For example, the 8-character problem name Prob is stored in cw(51), and the dual variables are stored in rw(lxMul) onward, where lxMul = iw(316). These will be accessible to both funobj and funcon if snopt is called with parameters cu, iu, ru the same  as cw, iw, rw.

If you still require user workspace, elements

rw(501:maxru)      and     rw(maxrw+1:lenru)

are set aside for this purpose, where maxru = rw(2).  Similarly for workspace in cw and rw. (See Total workspace and User workspace.)