## Simple Integer Linear Program (optmilp1)

```/***************************************************************/
/*                                                             */
/*          S A S   S A M P L E   L I B R A R Y                */
/*                                                             */
/*    NAME: optmilp1                                           */
/*   TITLE: Simple Integer Linear Program (optmilp1)           */
/* PRODUCT: OR                                                 */
/*  SYSTEM: ALL                                                */
/*    KEYS: OR                                                 */
/*   PROCS: OPTMILP                                            */
/*    DATA:                                                    */
/*                                                             */
/* SUPPORT:                             UPDATE:                */
/*     REF:                                                    */
/*    MISC: Example 1 from the OPTMILP chapter of Mathematical */
/*          Programming.                                       */
/*                                                             */
/***************************************************************/

data ex1data;
input field1 \$ field2 \$ field3 \$ field4 field5 \$ field6;
datalines;
NAME       .             ex1data           .     .                 .
ROWS       .             .                 .     .                 .
MAX        z             .                 .     .                 .
L          volume_con    .                 .     .                 .
L          weight_con    .                 .     .                 .
COLUMNS    .             .                 .     .                 .
.          .MRK0         'MARKER'          .     'INTORG'          .
.          x[1]          z                 1     volume_con       10
.          x[1]          weight_con       12     .                 .
.          x[2]          z                 2     volume_con      300
.          x[2]          weight_con       15     .                 .
.          x[3]          z                 3     volume_con      250
.          x[3]          weight_con       72     .                 .
.          x[4]          z                 4     volume_con      610
.          x[4]          weight_con      100     .                 .
.          x[5]          z                 5     volume_con      500
.          x[5]          weight_con      223     .                 .
.          x[6]          z                 6     volume_con      120
.          x[6]          weight_con       16     .                 .
.          x[7]          z                 7     volume_con       45
.          x[7]          weight_con       73     .                 .
.          x[8]          z                 8     volume_con      100
.          x[8]          weight_con       12     .                 .
.          x[9]          z                 9     volume_con      200
.          x[9]          weight_con      200     .                 .
.          x[10]         z                10     volume_con       61
.          x[10]         weight_con      110     .                 .
.          .MRK1         'MARKER'          .     'INTEND'          .
RHS        .             .                 .     .                 .
.          .RHS.         volume_con     1000     .                 .
.          .RHS.         weight_con      500     .                 .
BOUNDS     .             .                 .     .                 .
UP         .BOUNDS.      x[1]              4     .                 .
UP         .BOUNDS.      x[2]              4     .                 .
UP         .BOUNDS.      x[3]              4     .                 .
UP         .BOUNDS.      x[4]              4     .                 .
UP         .BOUNDS.      x[5]              4     .                 .
UP         .BOUNDS.      x[6]              4     .                 .
UP         .BOUNDS.      x[7]              4     .                 .
UP         .BOUNDS.      x[8]              4     .                 .
UP         .BOUNDS.      x[9]              4     .                 .
UP         .BOUNDS.      x[10]             4     .                 .
ENDATA     .             .                 .     .                 .
;

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;
run;
proc optmilp data=ex1data primalout=ex1soln;
run;

title "Example 1 Solution Data";
proc print data=ex1soln noobs label;
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;
run;
proc optmilp data=ex1data primalout=ex1soln;
title ' ';
run;

```