Resources

Reoptimizing After Adding a New Constraint (optlpe06)

/**********************************************************************/
/*                                                                    */
/*                  S A S   S A M P L E   L I B R A R Y               */
/*                                                                    */
/*    NAME: optlpe06                                                    */
/*   TITLE: Reoptimizing After Adding a New Constraint (optlpe06)       */
/* PRODUCT: OR                                                        */
/*  SYSTEM: ALL                                                       */
/*    KEYS: OR                                                        */
/*   PROCS: OPTLP                                                     */
/*    DATA:                                                           */
/*                                                                    */
/* SUPPORT:                             UPDATE:                       */
/*     REF:                                                           */
/*    MISC: Example 6 from the OPTLP chapter of Mathematical          */
/*          Programming.                                              */
/*                                                                    */
/**********************************************************************/


data ex3;
   input field1 $ field2 $ field3 $ field4 field5 $ field6;
   datalines;
NAME        .          EX3      .     .         .
ROWS        .          .        .     .         .
 N          diet       .        .     .         .
 G          calories   .        .     .         .
 L          protein    .        .     .         .
 G          fat        .        .     .         .
 G          carbs      .        .     .         .
COLUMNS     .          .        .     .         .
.           br         diet     2     calories  90
.           br         protein  4     fat       1
.           br         carbs    15    .         .
.           mi         diet     3.5   calories  120
.           mi         protein  8     fat       5
.           mi         carbs    11.7  .         .
.           ch         diet     8     calories  106
.           ch         protein  7     fat       9
.           ch         carbs    .4    .         .
.           po         diet     1.5   calories  97
.           po         protein  1.3   fat       .1
.           po         carbs    22.6  .         .
.           fi         diet     11    calories  130
.           fi         protein  8     fat       7
.           fi         carbs    0     .         .
.           yo         diet     1     calories  180
.           yo         protein  9.2   fat       1
.           yo         carbs    17    .         .
RHS         .          .        .     .         .
.           .          calories 300   protein   10
.           .          fat      8     carbs     10
BOUNDS      .          .        .     .         .
UP          .          mi       1     .         .
LO          .          fi       .5    .         .
ENDATA      .          .        .     .         .
;

proc optlp data=ex3
   presolver  = none
   algorithm  = ps
   primalout  = ex3pout
   dualout    = ex3dout
   logfreq    = 0
   printlevel = 0;
run;



/* added a new constraint to the diet problem */
data ex6;
   input field1 $ field2 $ field3 $ field4 field5 $ field6;
   datalines;
NAME        .          EX6      .     .         .
ROWS        .          .        .     .         .
 N          diet       .        .     .         .
 G          calories   .        .     .         .
 L          protein    .        .     .         .
 G          fat        .        .     .         .
 G          carbs      .        .     .         .
 L          sodium     .        .     .         .
COLUMNS     .          .        .     .         .
.           br         diet     2     calories  90
.           br         protein  4     fat       1
.           br         carbs    15    sodium    148
.           mi         diet     3.5   calories  120
.           mi         protein  8     fat       5
.           mi         carbs    11.7  sodium    122
.           ch         diet     8     calories  106
.           ch         protein  7     fat       9
.           ch         carbs    .4    sodium    337
.           po         diet     1.5   calories  97
.           po         protein  1.3   fat       .1
.           po         carbs    22.6  sodium    186
.           fi         diet     11    calories  130
.           fi         protein  8     fat       7
.           fi         carbs    0     sodium    56
.           yo         diet     1     calories  180
.           yo         protein  9.2   fat       1
.           yo         carbs    17    sodium    132
RHS         .          .        .     .         .
.           .          calories 300   protein   10
.           .          fat      8     carbs     10
.           .          sodium   550   .         .
BOUNDS      .          .        .     .         .
UP          .          mi       1     .         .
LO          .          fi       .5    .         .
ENDATA      .          .        .     .         .
;



data ex6newcon;
   _ROW_='sodium  '; _STATUS_='A';
   output;
run;

/* create a new DUALIN= data set to include the new constraint */
data ex6din;
   set ex3dout ex6newcon;
run;



/* display the DUALIN= data set */
proc print data=ex6din(keep= _ROW_ _STATUS_);
run;



proc optlp data=ex6
   objsense=min
   presolver=none
   algorithm=ds
   primalout=ex6pout
   dualout=ex6dout
   scale=none
   logfreq=1
   basis=warmstart
   primalin=ex3pout
   dualin=ex6din;
run;



title2 'Primal Solution';
proc print data=ex6pout label;
run;

title2 'Dual Solution';
proc print data=ex6dout label;
run;