Resources

Getting Started Example (optmig01)

/***************************************************************/
/*                                                             */
/*          S A S   S A M P L E   L I B R A R Y                */
/*                                                             */
/*    NAME: optmig01                                           */
/*   TITLE: Getting Started Example (optmig01)                 */
/* PRODUCT: OR                                                 */
/*  SYSTEM: ALL                                                */
/*    KEYS: OR                                                 */
/*   PROCS: OPTMILP                                            */
/*    DATA:                                                    */
/*                                                             */
/* SUPPORT:                             UPDATE:                */
/*     REF:                                                    */
/*    MISC: Example from the Getting Started section of the    */
/*          OPTMILP chapter of Mathematical Programming.       */
/*                                                             */
/***************************************************************/

data ex_mip;
   input field1 $ field2 $ field3 $ field4 field5 $ field6;
   datalines;
NAME        .      EX_MIP      .   .        .
ROWS        .        .         .   .        .
N           COST     .         .   .        .
G           R1       .         .   .        .
L           R2       .         .   .        .
L           R3       .         .   .        .
COLUMNS     .        .         .   .        .
.           MARK00 'MARKER'    .   'INTORG' .
.           X1     COST        2   R2       1
.           X1     R3          1   .        .
.           X2     COST       -3   R1      -2
.           X2     R2          1   R3       2
.           X3     COST       -4   R1      -3
.           X3     R2          2   R3       3
.           MARK01 'MARKER'    .   'INTEND' .
RHS         .      .           .   .        .
.           RHS    R1         -5   R2       4
.           RHS    R3          7   .        .
ENDATA      .      .           .   .        .
;

proc optmilp data = ex_mip
   objsense   = min
   primalout  = primal_out
   dualout    = dual_out
   presolver  = automatic
   heuristics = automatic;
run;





proc optmodel;
    num nItems          = 10;
    num volume_capacity = 1000;
    num weight_capacity = 500;
    set<num> Items = {1..nItems};
    num value{Items}  = [1,2,3,4,5,6,7,8,9,10];
    num volume{Items} = [10, 300, 250, 610, 500, 120, 45, 100, 200, 61 ];
    num weight{Items} = [12,  15,  72, 100, 223,  16, 73,  12, 200, 110];
    var x{Items} integer >= 0 <= 4;
    max z = sum{i in Items} value[i] * x[i];
    con volume_con: sum{i in Items} volume[i] * x[i] <= volume_capacity;
    con weight_con: sum{i in Items} weight[i] * x[i] <= weight_capacity;
    save mps ex1data;
quit;
proc optmilp data=ex1data primalout=ex1soln;run;
run;