Program 1.2


/****************************************************************************
* This program is taken from the following book. If using please cite it as:                            *
* Emrouznejad, A. and W. Ho (2012). Applied Operations Research with SAS, *
* CRC Press: Taylor Francis Ltd, ISBN: 9781439841303.*
* For details please visit: http://www.sas-or.com.                          *
****************************************************************************/

* Program 1.2: An example of PROC OPTMODEL, populating data,
* constructing linear programming and solving the model;

data d_trans;
input warehouse pub1-pub8 supply;
datalines;
1 10 15 12 13 15 10 20 15 1000
2 8 12 15 10 12 16 12 17 1500
3 12 12 16 14 12 15 10 12 2000
4 20 10 20 12 15 14 17 12 2000
;

data d_demand;
input pub demand;
datalines;
1 200
2 500
3 700
4 800
5 900
6 900
7 1000
8 1500
;

proc optmodel;

set WAREHOUSES;
set PUBS;

number demand{PUBS};
number cost{WAREHOUSES, PUBS};
number supply{WAREHOUSES};

var X{WAREHOUSES, PUBS} >= 0;

read data d_demand
into PUBS=[pub] demand[pub]=col(“demand”);

read data d_trans
into WAREHOUSES=[warehouse] supply[warehouse]=col(“supply”);

read data d_trans
into WAREHOUSES=[warehouse]
{p in PUBS} ;

min obj = sum{W in WAREHOUSES, P in PUBS} cost[w,p]*x[w,p];
con req_supply{w in WAREHOUSES}:

sum{p in PUBS} x[w,p] <= supply[w]; con req_demand{p in PUBS}: sum{w in WAREHOUSES} x[w,p] >= demand[p];

solve with lp/solver=primal;

create data optimout
from [warehouse pub]
={w in WAREHOUSES, p in PUBS: x[w,p]^=0}
amount=x;
quit;


/****************************************************************************
******************************END of the program*****************************
****************************************************************************/

Permanent link to this article: http://sas-or.com/book/program-1-2