Using Nonlinear Constraints (lsoe06)

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

%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..10} >= 0;
   x[10].lb = 1;
   x[10].ub = 3;
   x[1].ub = 100;
   x[2].ub = 200;
   con x[3] + x[4] = x[6] + x[7],
   x[6] + x[8] = x[1],
   x[7] + x[9] = x[2],
   x[8] + x[9] = x[5];
   max f = 9*x[1] + 15*x[2] - 6*x[3] - 16*x[4] - 10*x[5];
   save mps nlcexOld;
quit;

%lsompsmod(nlcexOld, nlcex);

proc fcmp outlib=sasuser.myfuncs.mypkg;
   function nlc1(x1,x6,x8,x10);
      return (2.5*x1 - x10*x6 - 2*x8);
   endsub;
   function nlc2(x2,x7,x9,x10);
      return (1.5*x2 - x10*x7 - 2*x9);
   endsub;
   function nlc3(x3,x4,x10);
      return (3*x3 + x4 - x10*(x3 + x4));
   endsub;
run;

data condata;
   input _id_ $ _lb_ _ub_;
   datalines;
nlc1 0 .
nlc2 0 .
nlc3 0 0
;

options cmplib = sasuser.myfuncs;
proc optlso
   primalout = solution
   mpsdata   = nlcex
   nlincon   = condata
   logfreq   = 10;
   performance nthreads=2;
run;

proc print data=solution;
run;