SOL NLSSOL

From TomWiki
Revision as of 11:18, 9 December 2011 by Elias (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Notice.png

This page is part of the SOL Manual. See SOL.

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 Section 3.7.2 for information on how to use NLSSOL with TOMLAB.

Purpose

nlssol solves constrained nonlinear least squares problems defined as


where , , , and .

nlssol uses a sequential quadratic programming algorithm, with a positive-definite quasi-Newton approximation to the transformed Hessian Q'HQ of the Lagrangian function (which will be stored in the array R).

Calling Syntax

The file 'funfdf.m' must be defined and contain: function [r, J] = funfdf(x, Prob, mode, nstate) to compute the residual vector r and the Jacobian matrix J at the point x.

The file 'funcdc.m' must be defined and contain: function [c, dc] = funcdc(x, Prob, mode, nstate) to compute the nonlinear constraint value c and the constraint Jacobian dc for the nonlinear constraints at the point x.

[x, Inform, iState, cLamda, iwCount, fObj, gObj, r, J, fCon, gCon, H] = nlssol( A, bl, bu, 
x, Prob, y, optPar, Warm, H, iState, cLamda, SpecsFile, PrintFile,  SummFile, PriLev, ProbName );

Description of Inputs

The following fields are used:
A Constraint matrix, nb 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 nlssol, 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, name stored in Prob.FUNCS.rJ, with syntax \[mode, r, J\] = funfdf(x, Prob, mode, nstate)

funcdc, name stored in Prob.FUNCS.cdc, with syntax \[mode, c, dc\] = funcdc(x, Prob, mode, nstate)

NLSOL is calling the TOMLAB routines nlp rJ.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.rJ, 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.r, Prob.FUNCS.J, 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 clsAssign.m).

If the mode parameter is 0, funfdf should return r, otherwise both r and the Jacobian matrix J. 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 rJ.m and nlp cdc.m and put them before in the path.

y Data vector of length. Number of residuals == length(y) == m.
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. 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 OPTIONS 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 char- acters = 500.
PriLev Print level in the nlssol MEX-interface.

= 0 Silent

= 10 Dimensions are printed if isempty(PriLev), set as 0.

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 NLSSOL 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.

5 = Problem is unbounded, or badly scaled.

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) (nb 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 objective, n x 1.
r Residual vector m x 1.
J Jacobian matrix m x n.
fCon Nonlinear constraint vector, ncnln x 1.
gCon Gradient matrix of the nonlinear constraint vector, ncnln x n.
H Cholesky factor of Hessian approximation. Hessian no - reordered variables. Hessian yes - natural order of variables, used for Warm start.

Using TOMLAB

Purpose

nlssolTL solves constrained nonlinear least squares problems defined as


where , , , and .

Calling Syntax

Using the driver routine tomRun :

Prob = clsAssign( ... );
Result = tomRun('nlssol', 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.
r_k Residual vector.
J_k Jacobian matrix.
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 nlssol.m (similar to TOMLAB).
Inform NLSSOL 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.

5 = Problem is unbounded, or badly scaled.

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 (nlssol).
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 NLSSOL, if not the value is altered in the SPECS file (input SpecsFile)

Description of Inputs

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 eps0.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 > 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 0 3 3 0,1,2,3
41. FUNCTION PRECISION > 0 3.0E-13 eps0.8 = epsR
42. DIFFERENCE INTERVAL > 0 5.48E-8 eps0.4
43. CENTRAL DIFFERENCE INTERVAL > 0 6.70E-5 eps0.8/3
45. INFINITE STEP SIZE > 0 max(BIGBND,1E10)
46. INFINITE BOUND SIZE > 0 1E10 = BIGBND
47. JTJ INITIAL HESSIAN 0 1 0 = UNIT
48. RESET FREQUENCY 0 2 Reset to (47)
50. HESSIAN YES or NO 0 0 1 = YES