The OPTQP Procedure

Example 7.1 Linear Least Squares Problem

The linear least squares problem arises in the context of determining a solution to an overdetermined set of linear equations. In practice, these equations could arise in data fitting and estimation problems. An overdetermined system of linear equations can be defined as

bold upper A bold x equals bold b

where bold upper A element-of double-struck upper R Superscript m times n, bold x element-of double-struck upper R Superscript n, bold b element-of double-struck upper R Superscript m, and m greater-than n. Since this system usually does not have a solution, you need to be satisfied with some sort of approximate solution. The most widely used approximation is the least squares solution, which minimizes double-vertical-bar bold upper A bold x minus bold b double-vertical-bar Subscript 2 Superscript 2.

This problem is called a least squares problem for the following reason. Let bold upper A, bold x, and bold b be defined as previously. Let k Subscript i Baseline left-parenthesis x right-parenthesis be the kth component of the vector bold upper A bold x minus bold b:

k Subscript i Baseline left-parenthesis x right-parenthesis equals a Subscript i Baseline 1 Baseline x 1 plus a Subscript i Baseline 2 Baseline x 2 plus midline-horizontal-ellipsis plus a Subscript i n Baseline x Subscript n Baseline minus b Subscript i Baseline comma i equals 1 comma 2 comma ellipsis comma m

By definition of the Euclidean norm, the objective function can be expressed as follows:

double-vertical-bar bold upper A bold x minus bold b double-vertical-bar Subscript 2 Superscript 2 Baseline equals sigma-summation Underscript i equals 1 Overscript m Endscripts k Subscript i Baseline left-parenthesis x right-parenthesis squared

Therefore, the function you minimize is the sum of squares of m terms k Subscript i Baseline left-parenthesis x right-parenthesis; hence the term least squares. The following example is an illustration of the linear least squares problem; that is, each of the terms k Subscript i is a linear function of x.function sigma-summation Underscript i j Endscripts a Subscript i j Baseline x Subscript j plus a constant, minus b Subscript i.

Consider the following least squares problem defined by

bold upper A equals Start 3 By 2 Matrix 1st Row 1st Column 4 2nd Column 0 2nd Row 1st Column negative 1 2nd Column 1 3rd Row 1st Column 3 2nd Column 2 EndMatrix comma bold b equals Start 3 By 1 Matrix 1st Row  1 2nd Row  0 3rd Row  1 EndMatrix

This translates to the following set of linear equations:

4 x 1 equals 1 comma minus x 1 plus x 2 equals 0 comma 3 x 1 plus 2 x 2 equals 1

The corresponding least squares problem is

minimize left-parenthesis 4 x 1 minus 1 right-parenthesis squared plus left-parenthesis minus x 1 plus x 2 right-parenthesis squared plus left-parenthesis 3 x 1 plus 2 x 2 minus 1 right-parenthesis squared

The preceding objective function can be expanded to

minimize 26 x 1 squared plus 5 x 2 squared plus 10 x 1 x 2 minus 14 x 1 minus 4 x 2 plus 2

In addition, you impose the following constraint so that the equation 3 x 1 plus 2 x 2 equals 1 is satisfied within a tolerance of 0.1:

0.9 less-than-or-equal-to 3 x 1 plus 2 x 2 less-than-or-equal-to 1.1

You can create the QPS-format input data set by using the following SAS statements:

data mycas.lsdata;
   input _id_ field1 $ field2 $ field3 $ field4 field5 $ field6 @;
   datalines;
1  NAME     .      LEASTSQ     .            .         .
2  ROWS     .      .           .            .         .
3  N        OBJ    .           .            .         .
4  G        EQ3    .           .            .         .
5  COLUMNS  .      .           .            .         .
6  .        X1     OBJ        -14           EQ3       3
7  .        X2     OBJ        -4            EQ3       2
8  RHS      .      .           .            .         .
9  .        RHS    OBJ        -2            EQ3       0.9
10 RANGES   .      .           .            .         .
11 .        RNG    EQ3         0.2          .         .
12 BOUNDS   .      .           .            .         .
13 FR       BND1   X1          .            .         .
14 FR       BND1   X2          .            .         .
15 QUADOBJ  .      .           .            .         .
16 .        X1     X1          52           .         .
17 .        X1     X2          10           .         .
18 .        X2     X2          10           .         .
19 ENDATA   .      .           .            .         .
;

The decision variables x 1 and x 2 are free, so they have bound type FR in the BOUNDS section of the QPS-format data set.

You can use the following SAS statements to solve the least squares problem:

proc optqp data = mycas.lsdata
   printlevel = 0
   primalout = mycas.lspout;
run;

The optimal solution is displayed in Output 7.1.1.

Output 7.1.1: Solution to the Least Squares Problem

Primal Solution

ObsObjective
Function ID
RHS IDVariable
Name
Variable
Type
Linear Objective
Coefficient
Lower BoundUpper BoundVariable ValueVariable
Status
1OBJRHSX1F-14-1.7977E3081.7977E3080.23810O
2OBJRHSX2F-4-1.7977E3081.7977E3080.16190O


The iteration log is shown in Output 7.1.2.

Output 7.1.2: Iteration Log

 
 
NOTE: The problem LEASTSQ has 2 variables (2 free, 0 fixed).                    
NOTE: The problem has 1 constraints (0 LE, 0 EQ, 0 GE, 1 range).                
NOTE: The problem has 2 constraint coefficients.                                
NOTE: The objective function has 2 Hessian diagonal elements and 1 Hessian      
      elements above the diagonal.                                              
NOTE: The QP presolver value AUTOMATIC is applied.                              
NOTE: The QP presolver removed 0 variables and 0 constraints.                   
NOTE: The QP presolver removed 0 constraint coefficients.                       
NOTE: The presolved problem has 2 variables, 1 constraints, and 2 constraint    
      coefficients.                                                             
NOTE: The QP solver is called.                                                  
NOTE: The Interior Point algorithm is used.                                     
NOTE: The deterministic parallel mode is enabled.                               
NOTE: The Interior Point algorithm is using up to 32 threads.                   
                                        Primal       Bound        Dual          
      Iter  Complement Duality Gap      Infeas      Infeas      Infeas   Time   
         0  4.4635E-02  7.3436E-03  1.2741E-12  1.1785E-01  4.8074E-14      0   
         1  6.0753E-03  2.0093E-03  1.1909E-11  1.1785E-03  6.0126E-16      0   
         2  2.0139E-04  6.7323E-05  1.1107E-10  2.4835E-05  3.9761E-18      0   
         3  2.0978E-06  7.0148E-07  1.3759E-11  2.4976E-07  1.8591E-17      0   
         4  1.8047E-06  5.5952E-07  1.3759E-11  2.1193E-07  1.3642E-07      0   
         5  0.0000E+00  9.4234E-08  2.7308E-13  2.1193E-09  6.2902E-08      0   
NOTE: Optimal.                                                                  
NOTE: Objective = 0.0095238095.                                                 
NOTE: The Interior Point solve time is 0.00 seconds.                            
NOTE: The Cloud Analytic Services server processed the request in 0.058246      
      seconds.                                                                  
NOTE: The data set MYCAS.LSPOUT has 2 observations and 9 variables.             
 
 


Last updated: October 07, 2021