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, f left-parenthesis x right-parenthesis, (Moré, Garbow, and Hillstrom 1981) is a least squares problem that has n equals 3 parameters and m equals 15 functions f Subscript i,

f left-parenthesis x right-parenthesis equals one-half sigma-summation Underscript i equals 1 Overscript 15 Endscripts f Subscript i Superscript 2 Baseline left-parenthesis x right-parenthesis comma x equals left-parenthesis x 1 comma x 2 comma x 3 right-parenthesis

where the functions are defined as

f Subscript i Baseline left-parenthesis x right-parenthesis equals y Subscript i Baseline minus left-parenthesis x 1 plus StartFraction u Subscript i Baseline Over v Subscript i Baseline x 2 plus w Subscript i Baseline x 3 EndFraction right-parenthesis

with u Subscript i Baseline equals i, v Subscript i Baseline equals 16 minus i, w Subscript i Baseline equals min left-parenthesis u Subscript i Baseline comma v Subscript i Baseline right-parenthesis, and

y equals left-parenthesis 0.14 comma 0.18 comma 0.22 comma 0.25 comma 0.29 comma 0.32 comma 0.35 comma 0.39 comma 0.37 comma 0.58 comma 0.73 comma 0.96 comma 1.34 comma 2.10 comma 4.39 right-parenthesis

Starting from x Superscript 0 Baseline equals left-parenthesis 1 comma 1 comma 1 right-parenthesis, you can reach the minimum at the point left-parenthesis 0.08 comma 1.13 comma 2.34 right-parenthesis, with corresponding objective value f left-parenthesis x Superscript asterisk Baseline right-parenthesis = 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

The OPTMODEL Procedure

Problem Summary
Objective SenseMinimization
Objective Functionf
Objective TypeNonlinear
  
Number of Variables3
Bounded Above0
Bounded Below0
Bounded Below and Above0
Free3
Fixed0
  
Number of Constraints0

Solution Summary
SolverNLP
AlgorithmInterior Point
Objective Functionf
Solution StatusOptimal
Objective Value0.0041074387
  
Optimality Error1.1287133E-7
Infeasibility0
  
Iterations12
Presolve Time0.00
Solution Time0.00

[1]x
10.08241
21.13303
32.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.                                                 


Last updated: September 09, 2026