SOL NPSOL
This page is part of the SOL Manual. See SOL. |
Contents
Direct Solver Call
A direct solver call is not recommended unless the user is 100 % sure that no other solvers will be used for the problem. Please refer to #Using TOMLAB for information on how to use NPSOL with TOMLAB.
Purpose
npsol solves dense nonlinear optimization problems defined as
where , , ,
and .
Calling Syntax
The file 'funfdf.m' must be defined and contain: function [mode, f, g] = funfdf(x, Prob, mode, nstate) to compute the objective function f and the gradient g at the point x.
The file 'funcdc.m' must be defined and contain: function [mode, c ,dcS] = funcdc(x, Prob, mode, nstate) to compute the nonlinear constraint value c and the constraint Jacobian dcS for the nonlinear constraints at the point x.
[x, Inform, iState, cLamda, iwCount, fObj, gObj, fCon, gCon, H] = npsol( A, bl, bu, x, Prob, optPar, Warm, H, iState, cLamda, SpecsFile, PrintFile, SummFile, PriLev, ProbName );
Description of Inputs
The following fields are used: | |
---|---|
A | Constraint matrix, m x n. (DENSE). |
bl | Lower bounds on (x,Ax,c(x)). |
bu | Upper bounds on (x,Ax,c(x)). |
x | Initial x vector (n x 1). If Warm start x must correspond to values in H and iState. |
Prob | Must be a structure. No check is made in the MEX interface.
If TOMLAB calls npsol, then Prob is the standard TOMLAB problem struc- ture, otherwise the user should set: Prob.P = ProblemNumber, where ProblemNumber is some integer. Two user written routines must be written: funfdf, actual name stored in Prob.FUNCS.fg, with syntax [mode, f, g] = funfdf(x, Prob, mode, nstate). funcdc, actual name stored in Prob.FUNCS.cdc, with syntax [mode, c, dc] = funcdc(x, Prob, mode, nstate). NPSOL is calling the TOMLAB routines nlp fg.m and nlp cdc.m in the call- back, and they call funfdf and funcdc, respectively. If these fields in Prob are empty (Prob.FUNCS.fg, Prob.FUNCS.cdc), the TOMLAB callback routines calls the usual function routines. Then the Prob struct should be normally defined, and the fields Prob.FUNCS.f, Prob.FUNCS.g, Prob.FUNCS.c, Prob.FUNCS.dc be set in the normal way (e.g. by the routine mFiles.m, or one of the Assign-routines like conAssign.m). If the mode parameter is 0, funfdf should return f, otherwise both f and the gradient vector g. If the mode parameter is 0, funcdc should return c, otherwise both c and dc. Note that each row in dc corresponds to a constraint, and that dc should be a dense matrix. If the matrix dc is returned as a sparse Matlab matrix, nlp cdc will do full(dc) to get a dense matrix. The user could also write his own versions of the routines nlp fg.m and nlp cdc.m and put them before in the path. |
optPar | Vector with optimization parameters overriding defaults and the optionally specified SPECS file. Set empty if only using default parameters. |
Warm | Flag for Warm start (==1) or Cold Start (==0 ), i.e. normal mode. If 'WarmStart', iState, cLamda, H and x must supply correct values. |
H | Hessian matrix, only accessed if Warm start. Must select: Hessian = Yes in order to do a warm start. Hessian Yes is equivalent to optPar(50) = 1 (default is 0). |
iState | Working set (if Warm start) (nb = n+nclin+ncnln) x 1 (DENSE). If length(iState) < nb, setting iState(1:nb)=0;
iState(i)=0: Corresponding constraint not in the initial working set. iState(i)=1: Inequality constraint at its lower bound in working set. iState(i)=2: Inequality constraint at its upper bound in working set. iState(i)=3: Equality constraint in the initial working set, bl(i)==bu(i). |
cLamda | Lagrangian multipliers for the n + nclin + ncnln constraints. If Warm start, cLamda(n+nclin+1:n+nclin+ncnln), the nonlinear Lagrange multipliers, must correspond to values in iState. |
SpecsFile | Name of the input parameter file, see TOMLAB Guide. |
PrintFile | Name of the Print file. Name includes the path, maximal number of characters = 500. |
SummFile | Name of the Summary file. Name includes the path, maximal number of characters = 500. |
PriLev | Print level in the npsol MEX-interface.
= 0 Silent = 10 Dimensions are printed. |
ProbName | Name of the problem. ¡=100 characters are used in the MEX interface. (Not used by MEX-interface). |
Description of Outputs
The following fields are used: | |
---|---|
x | Solution vector (n by 1) with n decision variable values. |
Inform | Result of NPSOL run.
0 = Optimal solution found. 1 = Optimal solution found but not to requested accuracy. 2 = No feasible point for the linear constraints. 3 = No feasible point for the nonlinear constraints. 4 = Too many major iterations. 6 = The current point cannot be improved on. 7 = Large errors found in the derivatives. 9 = An input parameter is invalid. Other = User requested termination |
iState | Status of working set, se input description of iState. |
cLamda | Lagrangian multipliers (dual solution vector) (m x 1 vector). |
iwCount | Number of iterations (iwCount(1)), function evaluations (iwCount(2)) and constraint evaluations (iwCount(3)). |
fObj | Objective function value at optimum. gObj Gradient of the nonlinear objective. |
fCon | Nonlinear constraint vector. |
gCon | Gradient matrix of the nonlinear constraint vector. |
H | Cholesky factor of Hessian approximation. Hessian no-reordered variables. Hessian yes - natural order of variables, used for Warm start. |
Using TOMLAB
Purpose
npsolTL solves dense nonlinear optimization problems defined as
where , , , and .
Calling Syntax
Using the driver routine tomRun :
Prob = ''o''Assign( ... ); Result = tomRun('npsol', Prob ... );
Description of Inputs
Prob, The following fields are used: | |
---|---|
x_L, x_U | Bounds on variables. |
b_L, b_U | Bounds on linear constraints. |
c_L, c_U | Bounds on nonlinear constraints. A Linear constraint matrix. |
PriLevOpt | Print level. |
WarmStart | If true, use warm start, otherwise cold start. |
SOL.xs | Solution from previous run, elements xs[1:n]. |
SOL.iState | Working set (if Warm start) (n+m) x 1 (DENSE) If length(iState) ¡ n+m, setting iState(1:n+m)=0;
iState(i)=0: Corresponding constraint not in the initial QP working set. iState(i)=1: Inequality constraint at its lower bound in QP working set. iState(i)=2: Inequality constraint at its upper bound in QP working set. iState(i)=3: Equality constraint in the initial QP working set, bl(i)==bu(i). |
SOL.cLamda | Lagrangian multipliers (dual solution vector) (nb x 1 vector). |
SOL.H | Cholesky factor of Hessian approximation Hessian no - reordered variables. Hessian yes - natural order of variables, used for Warm start. |
SOL.SpecsFile | Name of user defined SPECS file, read BEFORE optPar() is used. |
SOL.PrintFile | Name of SOL Print file. Amount and type of printing determined by SPECS parameters or optPar parameters. |
SOL.SummFile | Name of SOL Summary File. |
SOL.optPar | Elements > -999 takes precedence over corresponding TOMLAB params. See Table 50. |
Description of Outputs
Result, The following fields are used: | |
---|---|
Result | The structure with results (see ResultDef.m). |
f_k | Function value at optimum. |
x_k | Solution vector. |
x_0 | Initial solution vector. |
g_k | Gradient of the function. |
c_k | Nonlinear constraint residuals. |
cJac | Nonlinear constraint gradients. |
xState | State of variables. Free == 0; On lower == 1; On upper == 2; Fixed == 3; |
bState | State of linear constraints. Free == 0; Lower == 1; Upper == 2; Equality == 3; |
cState | State of nonlinear constraints. Free == 0; Lower == 1; Upper == 2; Equality == 3; |
v_k | Lagrangian multipliers (for bounds + dual solution vector). |
ExitFlag | Exit status from npsol.m (similar to TOMLAB). |
Inform | NPSOL information parameter.
0 = Optimal solution found. 1 = Optimal solution found but not to requested accuracy. 2 = No feasible point for the linear constraints. 3 = No feasible point for the nonlinear constraints. 4 = Too many major iterations. 6 = The current point cannot be improved on. 7 = Large errors found in the derivatives. 9 = An input parameter is invalid. Other = User requested termination |
rc | Reduced costs. If ninf=0, last m == -v k. |
Iter | Number of iterations. |
FuncEv | Number of function evaluations. |
GradEv | Number of gradient evaluations. |
ConstrEv | Number of constraint evaluations. |
QP.B | Basis vector in TOMLAB QP standard. |
MinorIter | Number of minor iterations. |
Solver | Name of the solver (npsol). |
SolverAlgorithm | Description of the solver. |
SOL.x | Solution vector (n by 1) with n decision variable values. |
SOL.iState | basis status of constraints + variables, (m + n x 1 vector). State of variables:
0=nonbasic (on bl), 1=nonbasic (on bu), 2=superbasic (between bounds), 3=basic (between bounds). |
SOL.cLamda | Lagrangian multipliers (dual solution vector) (m x 1 vector). |
SOL.H | Cholesky factor of Hessian approximation. Hessian no - reordered variables. Hessian yes - natural order of variables, used for Warm start. |
optPar
Description
Use missing value (-999 or less), when no change of parameter setting is wanted. The default value will then be used by NPSOL, if not the value is altered in the SPECS file (input SpecsFile).
Description of Inputs
Table: The following fields are used:
# | SPECS keyword text | Lower | Default | Upper | Comment |
---|---|---|---|---|---|
Printing | |||||
1. | PRINT LEVEL
or MAJOR PRINT LEVEL |
0 | 10 | 0,1,5,10,20,30 | |
2. | MINOR PRINT LEVEL | 0 | 0 | 0,1,5,10,20,30 | |
Convergence Tolerances | |||||
9. | NONLINEAR FEASIBILITY TOLERANCE | > 0 | 1.1E-8 | sqrt(eps) | |
10. | OPTIMALITY TOLERANCE | > 0 | 3.0E-13 | eps^{0.8} | |
11. | LINEAR FEASIBILITY TOLERANCE | > 0 | 1.1E-8 | sqrt(eps) | |
Derivative checking | |||||
13. | VERIFY LEVEL | -1 | -1 | 3 | -1,0,1,2,3 |
14. | START OBJECTIVE CHECK AT COL | 0 | 1 | n | |
15. | STOP OBJECTIVE CHECK AT COL | 0 | n | n | |
16. | START CONSTRAINT CHECK AT COL | 0 | 1 | n | |
17. | STOP CONSTRAINT CHECK AT COL | 0 | n | n | |
Other Tolerances | |||||
21. | CRASH TOLERANCE
Note: Decision variables will be set to the closest bound to the starting point based on this tolerance before running the optimization. |
> 0 | 0.01 | < 1 | |
22. | LINESEARCH TOLERANCE | > 0 | 0.9 | < 1 | |
30. | ITERATIONS LIMIT | > 0 | max(50,3(n+m_L)+10*m_N) | ||
36. | MINOR ITERATIONS LIMIT | > 0 | max(50,3(n+m_L+m_N)) | ||
37. | STEP LIMIT | > 0 | 2 | ||
39. | DERIVATIVE LEVEL
Is set by npsolTL dependent on Prob.ConsDiff, Prob.NumDiff |
0 | 3 | 3 | 0,1,2,3 |
41. | FUNCTION PRECISION | > 0 | 3.0E-13 | eps^{0.8} = eps_{R} | |
42. | DIFFERENCE INTERVAL | > 0 | 5.48E-8 | eps^{0.4} | |
43. | CENTRAL DIFFERENCE INTERVAL | > 0 | 6.70E-5 | eps^{0.8/3} | |
45. | INFINITE STEP SIZE | > 0 | max(BIGBND,1E10) | ||
46. | INFINITE BOUND SIZE | > 0 | 1E10 | = BIGBND | |
50. | HESSIAN YES or NO | 0 | 0 | 1 = YES |