Linear Least-Squares Problem (qpsole01)

/***************************************************************/
/*                                                             */
/*          S A S   S A M P L E   L I B R A R Y                */
/*                                                             */
/*    NAME: qpsole01                                           */
/*   TITLE: Linear Least-Squares Problem (qpsole01)            */
/* PRODUCT: OR                                                 */
/*  SYSTEM: ALL                                                */
/*    KEYS: OR                                                 */
/*   PROCS: OPTMODEL                                           */
/*    DATA:                                                    */
/*                                                             */
/* SUPPORT:                             UPDATE:                */
/*     REF:                                                    */
/*    MISC: Example 1 from the Quadratic Programming Solver    */
/*          chapter of Mathematical Programming.               */
/*                                                             */
/***************************************************************/

/* example 1: linear least squares problem */
proc optmodel;
   /* declare free (no explicit bounds) variables x[1] and x[2] */
   var x {1..2};

   /* objective function: minimize the sum of squares */
   minimize f = 26*x[1]^2 + 5*x[2]^2 + 10*x[1]*x[2] - 14*x[1] - 4*x[2] + 2;

   /* subject to the following constraint */
   con R: 0.9 <= 3*x[1] + 2*x[2] <= 1.1;

   /* call the QP solver */
   solve;

   /* print the optimal solution */
   print x;
quit;