The Nonlinear Programming Solver
A Least Squares Problem
Although the NLP solver does not implement techniques that are specialized for least squares problems, this example illustrates how the NLP solver can use general nonlinear optimization techniques to solve least squares problems.
The Bard function, , (Moré, Garbow, and Hillstrom 1981) is a least squares problem that has
parameters and
functions
,
where the functions are defined as
Starting from , you can reach the minimum at the point
, with corresponding objective value
= 4.107E–3. You can use the following SAS code to formulate and solve this problem:
proc optmodel;
set S = 1..15;
number u{i in S} = i;
number v{i in S} = 16 - i;
number w{i in S} = min(u[i], v[i]);
number y{S} = [ .14 .18 .22 .25 .29 .32 .35 .39 .37 .58
.73 .96 1.34 2.10 4.39 ];
var x{1..3} init 1;
min f = 0.5 * sum{i in S} ( y[i] -
( x[1] + u[i]/(v[i] * x[2] + w[i] * x[3]) )
)^2;
solve with nlp / algorithm=interiorpoint;
print x;
quit;
The output that summarizes the problem characteristics and the solution that the INTERIORPOINT solver obtains are displayed in Figure 3.
Figure 3: Problem Summary, Solution Summary, and Returned Solution
| Problem Summary | |
|---|---|
| Objective Sense | Minimization |
| Objective Function | f |
| Objective Type | Nonlinear |
| Number of Variables | 3 |
| Bounded Above | 0 |
| Bounded Below | 0 |
| Bounded Below and Above | 0 |
| Free | 3 |
| Fixed | 0 |
| Number of Constraints | 0 |
| Solution Summary | |
|---|---|
| Solver | NLP |
| Algorithm | Interior Point |
| Objective Function | f |
| Solution Status | Optimal |
| Objective Value | 0.0041074387 |
| Optimality Error | 1.1287133E-7 |
| Infeasibility | 0 |
| Iterations | 12 |
| Presolve Time | 0.00 |
| Solution Time | 0.00 |
| [1] | x |
|---|---|
| 1 | 0.08241 |
| 2 | 1.13303 |
| 3 | 2.34370 |
The SAS log shown in Figure 4 displays a brief summary of the problem being solved, followed by the iterations that are generated by the solver.
Figure 4: Progress of the Algorithm as Shown in the Log
| NOTE: Problem generation will use 12 threads. |
| NOTE: The problem has 3 variables (3 free, 0 fixed). |
| NOTE: The problem has 0 linear constraints (0 LE, 0 EQ, 0 GE, 0 range). |
| NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range). |
| NOTE: The OPTMODEL presolver removed 0 variables, 0 linear constraints, and 0 |
| nonlinear constraints. |
| NOTE: Using analytic derivatives for objective. |
| NOTE: The NLP solver is called. |
| NOTE: The Interior Point algorithm is used. |
| Objective Optimality |
| Iter Value Infeasibility Error |
| 0 20.84084793 0 12.96780938 |
| 1 13.15512458 0 8.28509025 |
| 2 3.55996018 0 3.65091384 |
| 3 0.40842764 0 0.60542870 |
| 4 0.17751290 0 0.27719412 |
| 5 0.02966229 0 0.07110366 |
| 6 0.01094468 0 0.01524637 |
| 7 0.00673822 0 0.00787377 |
| 8 0.00483931 0 0.00562081 |
| 9 0.00421528 0 0.00294758 |
| 10 0.00411181 0 0.00075047 |
| 11 0.00410745 0 0.00004204 |
| 12 0.00410744 0 0.0000001128713 |
| NOTE: Optimal. |
| NOTE: Objective = 0.0041074387. |