Program 8.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.                                                                *
************************************************************************************/


* A SAS procedure for MCDM;
options nodate;
%let _data=’c:\sasor\MCDM.txt’;
%let _title=’Example 8.2: An example of MCDM’;
%let _dataMCDM=’c:/sasor/Data8_2.txt’;
%let _nWareh=4;
%let _nCustomer=7;
%let _TotalCost=425000;
%let _outprimal=outprimal;
%let _outdual=outdual;
%let _outtable=outtable;
%let _myLarge=100000;

* The data handling macro;
%macro data;
* Import text tab delimited data file to SAS data file;
proc import
datafile=&_dataMCDM
out=dataC
dbms=tab
replace;
getnames=yes;
run;
%mend data;

* The model building macro;
%macro model (_stage);
* Starting OPTMODEL Procedure;
proc optmodel;

* Define sets;
set WAREHOUSE=1..&_nWareh;
set CUSTOMER=1..&_nCustomer;
set WAREHOUSE_CUSTOMER_TWO= 1..&_nCustomer+2*&_nWareh+2;
set Priority = 1..&_nWareh+3;
set stage ;
stage = {&_stage};

* Define variables;
var X{WAREHOUSE, CUSTOMER} integer >=0;
var u {WAREHOUSE} binary ;
var v {WAREHOUSE} binary ;
var w {WAREHOUSE} binary ;
var dPlus {WAREHOUSE_CUSTOMER_TWO} >=0 ;
var dNeg {WAREHOUSE_CUSTOMER_TWO} >=0 ;
var z{Priority} ;

* Define parameters;
number dc{WAREHOUSE, CUSTOMER};
number demand{CUSTOMER};
number QQ{WAREHOUSE};
number q{WAREHOUSE};
number hc{WAREHOUSE};
number fc{WAREHOUSE};
number pc{WAREHOUSE};
number WarehPriority{WAREHOUSE};
number P{Priority,Priority};

for {i in Priority , j in Priority: i ne j} P[i,j]=0;
for {i in Priority , j in Priority: i eq j} P[i,j]=1;

* Load the Unit delivery cost matrix;
read data Datac (where =(Wareh ne “demand”))
into [_N_]
{j in CUSTOMER} <dc[_N_,j]=col(‘Cust’||j)>;

* Load the demand array;
read data Datac (where =(Wareh eq “demand”))
into
{j in CUSTOMER} <demand[j]=col(‘Cust’||j)>;

* Load the Maximum throughput of warehouse array;
read data Datac (where =(Wareh ne “demand”))
into [_N_]
QQ[_N_]=col(‘QQi’);

* Load the Minimum throughput of warehouse array;
read data Datac (where =(Wareh ne “demand”))
into [_N_]
q[_N_]=col(‘qi’);

* Load the Unit holding cost array;
read data Datac (where =(Wareh ne “demand”))
into [_N_]
hc[_N_]=col(‘hci’);

* Load the Fixed cost array;
read data Datac (where =(Wareh ne “demand”))
into [_N_]
fc[_N_]=col(‘fci’);

* Load the Penalty cost array;
read data Datac (where =(Wareh ne “demand”))
into [_N_]
pc[_N_]=col(‘pci’);

* Load the Warehouse Priority that is obtained from AHP;
read data Datac (where =(Wareh ne “demand”))
into [_N_]
WarehPriority[_N_]=col(‘WarehPriority’);

* Define system constrains;
con sumV: sum{i in WAREHOUSE} v[i] <= &_nWareh;
con Mu {i in WAREHOUSE}: sum{j in CUSTOMER} x[i,j] + &_myLarge * u[i] <= q[i];
con Mv {i in WAREHOUSE}: sum{j in CUSTOMER} x[i,j] – &_myLarge * v[i] <= 0;
con wuv {i in WAREHOUSE}: w[i] – u[i] – v[i] = -1;
* Define Resource constraints;

* Priority 1 (P1);
con P1_1{ s in Priority, i in WAREHOUSE: s >= 1}: sum{j in CUSTOMER} x[i,j] – dPlus[i] + dNeg[i] <= QQ[i]; con P1_2{ s in Priority, j in CUSTOMER : s >= 1}: sum{i in WAREHOUSE} x[i,j] – dPlus[j+&_nWareh] + dNeg[j+&_nWareh] <= demand[j];

* Priority 2 (P2);
con P2{s in Priority : s >= 2}: sum{i in WAREHOUSE,j in CUSTOMER} (hc[i]+dc[i,j])*x[i,j] + sum{i in WAREHOUSE} fc[i]*v[i] – dPlus[&_nCustomer+&_nWareh+1] + dNeg[&_nCustomer+&_nWareh+1] <= &_TotalCost;

* Priority 3 (P3);
con P3{s in Priority : s >= 3}: sum{i in WAREHOUSE} pc[i]*w[i] – dPlus[&_nCustomer+&_nWareh+2] + dNeg[&_nCustomer+&_nWareh+2] = 0;

* Define AHP (P4) priority constraints;
con P4{s in Priority, i in WAREHOUSE: s >= i+3}: v[WarehPriority[i]]- dPlus[&_nCustomer+&_nWareh+i+2] + dNeg[&_nCustomer+&_nWareh+i+2]=1;

con z [1] = (sum {k in 1..&_nWareh} dPlus[k] + sum {k in &_nWareh+1..&_nWareh+&_nCustomer} (dPlus[k]+dNeg[k]));
con z [2] = (dPlus[&_nWareh+&_nCustomer+1]);
con z [3] = (dPlus[&_nWareh+&_nCustomer+2]);
con z [4] = (dPlus[&_nWareh+&_nCustomer+3]+ dNeg[&_nWareh+&_nCustomer+3]);
con z [5] = (dPlus[&_nWareh+&_nCustomer+4]+ dNeg[&_nWareh+&_nCustomer+4]);
con z [6] = (dPlus[&_nWareh+&_nCustomer+5]+ dNeg[&_nWareh+&_nCustomer+5]);
con z [7] = (dPlus[&_nWareh+&_nCustomer+6]+ dNeg[&_nWareh+&_nCustomer+6]);
* Define objective function;

* objective function;
min obj = sum {s1 in Priority, s in stage} P[s1 , s ]* z[s1];

solve with MILP; %put &_OROPTMODEL_; expand;

create data _optimout
from [WAREHOUSE CUSTOMER]
={i in WAREHOUSE, j in CUSTOMER}
amount=X ;

quit;
%mend;

* The report writing macro;
%macro report (_stage);
* Report the results in a tabulated form;
title &_title ‘(P=’ &_stage ‘)’;
proc tabulate data=_optimout;
title &_title;
class WAREHOUSE CUSTOMER ;
var amount;
table WAREHOUSE =” WAREHOUSE”,
CUSTOMER*amount*sum
/ BOX=’x[WAREHOUSE& CUSTOMER] ‘ ;
run;
%mend report;

* A SAS macro for multiple criteria decision making problem ;
%macro ormcdm;
%data;
%do i=1 %to &_nWareh+3;
%model(&i);
%report(&i);
%end;
%mend ormcdm;

%ormcdm;


/****************************************************************************
******************************END of the program*****************************
****************************************************************************/
_nCustomer+

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

Leave a Reply