Using DNOPT¶
This section serves as a reference guide to DNOPT. We recommend the user read the DNOPT User’s Guide for detailed information on using DNOPT.
Initializing/Finalizing¶
dnBegin¶
subroutine dnBegin
& ( iPrint, iSumm, cw, lencw, iw, leniw, rw, lenrw )
integer
& iPrint, iSumm, lencw, leniw, lenrw, iw(leniw)
character
& cw(lencw)*8
double precision
& rw(lenrw)
dnBegin is the initialization routine for DNOPT. The user must define
the Fortran file unit numbers iPrint and iSumm for the print and
summary output files. To turn off output on either of these streams, set
the unit number to 0. The user must open the files for writing and
associate them with the assigned unit numbers.
On exit, the workspace arrays are initialized to undefined or default values.
dnBeginF¶
subroutine dnBeginF
& ( printfile, summaryfile, iPrint, iSumm,
& cw, lencw, iw, leniw, rw, lenrw )
character*(*)
& printfile, summaryfile
integer
& iPrint, iSumm, lencw, leniw, lenrw, iw(leniw)
character
& cw(lencw)*8
double precision
& rw(lenrw)
dnBeginF is an alternative initialization routine for DNOPT. The user
passes the filenames of the print and summary output files. To turn off
output on either stream, set the filename to ''. To send the summary
output to standard output, set summaryfile to screen.
On exit, the assigned Fortran file unit numbers iPrint and iSumm
for the print and summary files are returned. The workspace arrays are
also initialized to undefined or default values.
dnEndF¶
subroutine dnEndF
& ( cw, lencw, iw, leniw, rw, lenrw )
integer
& lencw, leniw, lenrw, iw(leniw)
character
& cw(lencw)*8
double precision
& rw(lenrw)
dnEndF should be called if the user uses dnBeginF or dnSpecF.
This routine closes any opened files.
Solving with DNOPT¶
subroutine dnopt
& ( start, n, mLCon, mNCon, nnJac, nnObj,
& problemName, Names, nNames, iObj, objAdd,
& funcon, funobj,
& state, A, ldA, bl, bu,
& fObj, gObj, fCon, JCon, ldJ, H, ldH,
& objAll, nInf, sInf, x, y,
& INFO, mincw, miniw, minrw,
& cu, lencu, iu, leniu, ru, lenru,
& cw, lencw, iw, leniw, rw, lenrw )
implicit
& none
external
& funcon, funobj
integer
& iObj, INFO,
& ldA, ldJ, ldH,
& lencw, leniw, lenrw, lencu, leniu, lenru,
& n, mLCon, mNCon, nnJac, nnObj, nNames, nInf,
& mincw, miniw, minrw, start,
& state(n+mNCon+mLCon),
& iu(leniu), iw(leniw)
double precision
& objAdd, objAll, fObj, sInf, A(ldA,*),
& bl(n+mNCon+mLCon), bu(n+mNCon+mLCon), gObj(n),
& fCon(ldJ), JCon(ldJ,*), H(ldH,*),
& x(n+mNCon+mLCon), y(n+mNCon+mLCon),
& ru(lenru), rw(lenrw)
character
& problemName*8, Names(nNames)*8, cu(lencu)*8, cw(lencw)*8
The DNOPT interface accepts a format that allows the constraints and variables to be defined in any order. The optimization problem is assumed to be in the form
where the upper and lower bounds are constant, \(f_0(x)\) is the smooth
scalar objective function, \(f(x)\) defines the nonlinear constraint
functions, and \(A\) is the linear constraint matrix. (The option
Maximize specifies that \(f_0(x)\) should be maximized instead of
minimized.)
Ideally, the first derivatives (gradients) of \(f_0\) and \(f(x)\) should be known and coded by the user. If only some gradients are known, DNOPT estimates the missing ones by finite differences. See the option ‘Derivative level’ for more information.
The user-defined subroutines funcon and funobj define the
nonlinear constraint and nonlinear component of the objective functions
and ideally their gradients.
subroutine funcon
& ( mode, mNCon, nnJac,
& x, fCon, JCon, ldJ, status,
& cu, lencu, iu, leniu, ru, lenru )
integer
& lencu, leniu, lenru, mode, mNCon, nnJac, ldJ, nState,
& iu(leniu)
double precision
& fCon(mNCon), ru(lenru), x(nnJac)
character
& cu(lencu)*8
double precision JCon(nnJac,ldJ)
subroutine funobj
& ( mode, nnObj, x, fObj, gObj, status,
& cu, lencu, iu, leniu, ru, lenru )
integer
& lencu, leniu, lenru, mode, nnObj, status, iu(leniu)
double precision
& fObj, gObj(nnObj), ru(lenru), x(nnObj)
character
& cu(lencu)*8
We refer the user to Section 4 of the DNOPT User’s Guide for detailed information on how the problem should be structured for DNOPT.
Setting and Getting Options¶
dnSpec¶
subroutine dnSpec
& ( iSpecs, INFO, cw, lencw, iw, leniw, rw, lenrw )
integer
& iSpecs, INFO, lencw, leniw, lenrw, iw(leniw)
double precision
& rw(lenrw)
character
& cw(lencw)*8
dnSpec reads options from a file. iSpecs should be set by the user to
the Fortran file unit number associated with the specifications file. The
file should also be opened for reading. If options are successfully read,
the routine returns an iExit value of 101 or 107. The workspace arrays
will be appropriately updated with the options.
dnSpecF¶
subroutine dnSpecF
& ( specsfile, INFO, cw, lencw, iw, leniw, rw, lenrw )
character*(*)
& specsfile
integer
& INFO, lencw, leniw, lenrw, iw(leniw)
double precision
& rw(lenrw)
character
& cw(lencw)*8
dnSpecF is an alternative routine for reading options from a file.
specsfile should be set to the specifications filename. If options are
successfully read, the routine returns an iExit value of 101 or 107.
The workspace arrays will be appropriately updated with the options.
dnSet¶
subroutine dnSet
& ( option, iPrint, iSumm, Errors,
& cw, lencw, iw, leniw, rw, lenrw )
character*(*)
& option
integer
& Errors, iPrint, iSumm, lencw, leniw, lenrw, iw(leniw)
double precision
& rw(lenrw)
character
& cw(lencw)*8
dnSet is called to set an option. The input argument option should be
a character string containing the keyword of the option to modify and the
desired value (in character format).
dnSetInt¶
subroutine dnSetInt
& ( option, ivalue, iPrint, iSumm, Errors,
& cw, lencw, iw, leniw, rw, lenrw )
character*(*)
& option
integer
& Errors, ivalue, iPrint, iSumm, lencw, leniw, lenrw, iw(leniw)
double precision
& rw(lenrw)
character
& cw(lencw)*8
dnSetI is called to set an integer-valued option. The input argument
option should be a character string containing the keyword of the option
to modify. ivalue is the desired integer value.
dnSetReal¶
subroutine dnSetReal
& ( option, rvalue, iPrint, iSumm, Errors,
& cw, lencw, iw, leniw, rw, lenrw )
character*(*)
& option
integer
& Errors, iPrint, iSumm, lencw, leniw, lenrw, iw(leniw)
double precision
& rvalue, rw(lenrw)
character
& cw(lencw)*8
dnSetR is called to set an real-valued option. The input argument
option should be a character string containing the keyword of the option
to modify. rvalue is the desired real value.
dnGetChar¶
subroutine dnGetChar
& ( option, cvalue, Errors, cw, lencw, iw, leniw, rw, lenrw )
character*(*)
& option
integer
& Errors, lencw, leniw, lenrw, iw(leniw)
character
& cvalue*8, cw(lencw)*8
double precision
& rw(lenrw)
dnGetChar is called to retrieve an option value. The input argument
option should be a character string containing the keyword of the option
to modify. cvalue is a character string containing the value of the
option in character format. Errors indicates the number of errors
encountered while retrieving the option value.
dnGetInt¶
subroutine dnGetInt
& ( option, ivalue, Errors, cw, lencw, iw, leniw, rw, lenrw )
character*(*)
& option
integer
& Errors, ivalue, lencw, leniw, lenrw, iw(leniw)
character
& cw(lencw)*8
double precision
& rw(lenrw)
dnGetInt is called to retrieve an integer-valued option. The input argument
option should be a character string containing the keyword of the option
to modify. ivalue will contain the value of the option. Errors
indicates the number of errors encountered while retrieving the option
value.
dnGetReal¶
subroutine dnGetReal
& ( option, rvalue, Errors, cw, lencw, iw, leniw, rw, lenrw )
character*(*)
& option
integer
& Errors, lencw, leniw, lenrw, iw(leniw)
character
& cw(lencw)*8
double precision
& rvalue, rw(lenrw)
dnGetReal is called to retrieve a real-valued option. The input argument
option should be a character string containing the keyword of the
option to modify. rvalue will contain the value of the option.
Errors indicates the number of errors encountered while retrieving the
option value.