Using MPS Format (lsoe02)

/**********************************************************************/
/*                                                                    */
/*               S A S   S A M P L E   L I B R A R Y                  */
/*                                                                    */
/*    NAME: lsoe02                                                    */
/*   TITLE: Using MPS Format (lsoe02)                                 */
/* PRODUCT: OR                                                        */
/*  SYSTEM: ALL                                                       */
/*    KEYS: OR                                                        */
/*   PROCS: OPTLSO, FCMP, OPTMODEL                                    */
/*    DATA:                                                           */
/*                                                                    */
/* SUPPORT:                             UPDATE:                       */
/*     REF:                                                           */
/*    MISC: Example 2 from the OPTLSO chapter of the                  */
/*          Local Search Optimization book.                           */
/*                                                                    */
/**********************************************************************/

proc fcmp outlib=sasuser.myfuncs.mypkg;
   function quadobj(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13);
      sum1 = 5*(x1 + x2 + x3 + x4);
      sum2 = 5*(x1**2 + x2**2 + x3**2 + x4**2);
      sum3 = (x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13);
      return (sum1 - sum2 - sum3);
   endsub;
run;

data objdata;
   input _id_ $ _function_ $ _sense_ $;
   datalines;
f   quadobj   min
;

options cmplib = sasuser.myfuncs;


%macro lsompsmod(setold,setnew);
   data &setnew(drop=i);
      set &setold;
      array FC{*} _CHARACTER_;
      do i=1 to dim(FC);
         FC[i] = compress(FC[i], "[]");
      end;
   run;
%mend;

proc optmodel;
   var x{1..13} >= 0 <= 1;
   for {i in 10..12} x[i].ub = 100;
   min z = 0;
   con a1: 2*x[1] + 2*x[2] + x[10] + x[11] <= 10;
   con a2: 2*x[1] + 2*x[3] + x[10] + x[12] <= 10;
   con a3: 2*x[1] + 2*x[3] + x[11] + x[12] <= 10;
   con a4: -8*x[1] + x[10] <= 0;
   con a5: -8*x[2] + x[11] <= 0;
   con a6: -8*x[3] + x[12] <= 0;
   con a7: -2*x[4] - x[5] + x[10] <= 0;
   con a8: -2*x[6] - x[7] + x[11] <= 0;
   con a9: -2*x[8] - x[9] + x[12] <= 0;
   save mps lindataOld;
quit;

%lsompsmod(lindataOld, lindata);

proc optlso
   primalout = solution
   mpsdata   = lindata
   objective = objdata;
   performance nthreads=2;
run;

proc print data=solution;
run;