The OPTQP Procedure

Getting Started: OPTQP Procedure

Consider a small illustrative example. Suppose you want to minimize a two-variable quadratic function f left-parenthesis x 1 comma x 2 right-parenthesis on the nonnegative quadrant, subject to two constraints:

StartLayout 1st Row 1st Column min 2nd Column 2 x 1 3rd Column plus 4th Column 3 x 2 5th Column plus 6th Column x 1 squared 7th Column plus 8th Column 10 x 2 squared 9th Column plus 10th Column 2.5 x 1 x 2 2nd Row 1st Column subject to 2nd Column x 1 3rd Column minus 4th Column x 2 5th Column less-than-or-equal-to 6th Column 1 7th Column Blank 8th Column Blank 9th Column Blank 10th Column Blank 3rd Row 1st Column Blank 2nd Column x 1 3rd Column plus 4th Column 2 x 2 5th Column greater-than-or-equal-to 6th Column 100 7th Column Blank 8th Column Blank 9th Column Blank 10th Column Blank 4th Row 1st Column Blank 2nd Column x 1 3rd Column Blank 4th Column Blank 5th Column greater-than-or-equal-to 6th Column 0 7th Column Blank 8th Column Blank 9th Column Blank 10th Column Blank 5th Row 1st Column Blank 2nd Column Blank 3rd Column Blank 4th Column x 2 5th Column greater-than-or-equal-to 6th Column 0 7th Column Blank 8th Column Blank 9th Column Blank 10th Column Blank EndLayout

The linear objective function coefficients, vector of right-hand sides, and lower and upper bounds are identified immediately as

bold c equals StartBinomialOrMatrix 2 Choose 3 EndBinomialOrMatrix comma bold b equals StartBinomialOrMatrix 1 Choose 100 EndBinomialOrMatrix comma bold l equals StartBinomialOrMatrix 0 Choose 0 EndBinomialOrMatrix comma bold u equals StartBinomialOrMatrix plus normal infinity Choose plus normal infinity EndBinomialOrMatrix

Carefully construct the quadratic matrix bold upper Q. Observe that you can use symmetry to separate the main-diagonal and off-diagonal elements:

one-half bold x Superscript upper T Baseline bold upper Q bold x identical-to one-half sigma-summation Underscript i comma j equals 1 Overscript n Endscripts x Subscript i Baseline q Subscript i j Baseline x Subscript j Baseline equals one-half sigma-summation Underscript i equals 1 Overscript n Endscripts q Subscript i i Baseline x Subscript i Superscript 2 Baseline plus sigma-summation Underscript i greater-than j Endscripts x Subscript i Baseline q Subscript i j Baseline x Subscript j

The first expression

one-half sigma-summation Underscript i equals 1 Overscript n Endscripts q Subscript i i Baseline x Subscript i Superscript 2

sums the main-diagonal elements. Thus, in this case you have

q 11 equals 2 comma q 22 equals 20

Notice that the main-diagonal values are doubled in order to accommodate the 1/2 factor. Now the second term

sigma-summation Underscript i greater-than j Endscripts x Subscript i Baseline q Subscript i j Baseline x Subscript j

sums the off-diagonal elements in the strict lower triangular part of the matrix. The only off-diagonal (x Subscript i Baseline x Subscript j Baseline comma i not-equals j) term in the objective function is 2.5 x 1 x 2, so you have

q 21 equals 2.5

Notice that you do not need to specify the upper triangular part of the quadratic matrix.

Finally, the matrix of constraints is as follows:

bold upper A equals Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column negative 1 2nd Row 1st Column 1 2nd Column 2 EndMatrix

The input data table with a quadratic programming system (QPS) format for the preceding problem can be expressed in the following manner:

data gsdata;
   input field1 $ field2 $ field3 $ field4 field5 $ field6 @;
   datalines;
NAME     .      EXAMPLE    .             .         .
ROWS     .      .          .             .         .
N        OBJ    .          .             .         .
L        R1     .          .             .         .
G        R2     .          .             .         .
COLUMNS  .      .          .             .         .
.        X1     R1         1.0           R2        1.0
.        X1     OBJ        2.0           .         .
.        X2     R1        -1.0           R2        2.0
.        X2     OBJ        3.0           .         .
RHS      .      .          .             .         .
.        RHS    R1         1.0           .         .
.        RHS    R2         100           .         .
RANGES   .      .          .             .         .
BOUNDS   .      .          .             .         .
QUADOBJ  .      .          .             .         .
.        X1     X1         2.0           .         .
.        X1     X2         2.5           .         .
.        X2     X2         20            .         .
ENDATA   .      .          .             .         .
;

For more information about the QPS-format data table, see Chapter 8, The MPS-Format Data Table.

Alternatively, if you have a QPS-format flat file named gs.qps, then the following call to the SAS macro %MPS2SASD translates that file into a SAS data set named gsdata:

%mps2sasd(mpsfile =gs.qps, outdata = gsdata);

Note: The SAS macro %MPS2SASD is provided in SAS optimization software. For more information, see the section Converting an MPS/QPS-Format File: %MPS2SASD.

To make the created data set available in the CAS server, you need to upload it as in the following statements. At the same time, you also need to add an _id_ column to ensure that the MPS reader can read the file in the correct order even if it is distributed across several machines and hence loses its original ordering. For more information about the MPS format, see Chapter 8, The MPS-Format Data Table.

data mylib.gsdata;
   set gsdata;
   _id_ = _n_;
run;

Alternatively, you can create the MPS data table directly in CAS and include the _id_ column in the datalines input.

You can use the following call to PROC OPTQP:

proc optqp data = mylib.gsdata
   primalout = mylib.gspout
   dualout   = mylib.gsdout;
run;

The procedure output is displayed in Figure 2.

Figure 2: Procedure Output

The OPTQP Procedure

Problem Summary
Problem NameEXAMPLE
Objective SenseMinimization
Objective FunctionOBJ
RHSRHS
  
Number of Variables2
Bounded Above0
Bounded Below2
Bounded Above and Below0
Free0
Fixed0
  
Number of Constraints2
LE (<=)1
EQ (=)0
GE (>=)1
Range0
  
Constraint Coefficients4
  
Hessian Diagonal Elements2
Hessian Elements Below Diagonal1

Solution Summary
SolverQP
AlgorithmInterior Point
Objective FunctionOBJ
Solution StatusOptimal
Objective Value15018.000046
  
Primal Infeasibility0
Dual Infeasibility0
Bound Infeasibility0
Duality Gap7.8497853E-9
Complementarity0
  
Iterations4
Presolve Time0.00
Solution Time0.00

Output CAS Tables
CAS LibraryNameNumber
of Rows
Number
of Columns
CASUSERHDFS(amnari)GSPOUT29
CASUSERHDFS(amnari)GSDOUT210


The optimal primal solution is stored in the data table gspout and is displayed in Figure 3.

proc print data = mylib.gspout label;
run;

Figure 3: Optimal Solution

ObsObjective
Function ID
RHS IDVariable
Name
Variable
Type
Linear
Objective
Coefficient
Lower
Bound
Upper BoundVariable ValueVariable
Status
1OBJRHSX1N201.7977E30834.0000O
2OBJRHSX2N301.7977E30833.0000O


The SAS log shown in Figure 4 provides information about the problem, convergence information after each iteration, and the optimal objective value.

Figure 4: Iteration Log

 
 
NOTE: The problem EXAMPLE has 2 variables (0 free, 0 fixed).                    
NOTE: The problem has 2 constraints (1 LE, 0 EQ, 1 GE, 0 range).                
NOTE: The problem has 4 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, 2 constraints, and 4 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.4604E+03  2.6380E-01  1.7962E-02  1.8143E+00  2.7770E-14      0   
         1  1.2367E+02  7.8255E-03  1.7962E-04  1.8143E-02  1.9285E-14      0   
         2  1.2365E+00  7.8496E-05  1.7973E-06  1.8154E-04  4.6816E-14      0   
         3  1.2364E-02  7.8498E-07  1.7973E-08  1.8154E-06  1.9865E-14      0   
         4  0.0000E+00  7.8498E-09  1.7861E-09  1.8154E-08  3.4973E-07      0   
NOTE: Optimal.                                                                  
NOTE: Objective = 15018.000046.                                                 
NOTE: The Interior Point solve time is 0.00 seconds.                            
NOTE: The Cloud Analytic Services server processed the request in 0.337157      
      seconds.                                                                  
NOTE: The data set MYLIB.GSPOUT has 2 observations and 9 variables.             
NOTE: The data set MYLIB.GSDOUT has 2 observations and 10 variables.            
 
 


See the section Interior Point Algorithm: Overview and the section Iteration Log for more details about convergence information given by the iteration log.

Last updated: June 22, 2026