/***********************************************************************************
* 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. *
************************************************************************************/
* Using PROC OPTMODEL for Printed Circuit Board (PCB) Assembly Line Assignment Problem;
option nodate ;
%let _title=’Example 7.2: SMT placement machines or the component allocation problem using PROC OPTMODEL’;
%let _data=’c:/sasor/Data7_2.txt’;
%let _nMachine=3;
%let _nCompon=7;
%let _optimout=mysolution;
* The data handling macro;
%macro data;
* Import text tab delimited data file to SAS data file;
proc import
datafile=&_data
out=data12
dbms=tab
replace;
getnames=yes;
run;
%mend data;
%macro model;
* Starting OPTMODEL Procedure;
proc optmodel;
* Define sets;
set MACHINES=1..&_nMachine;
set COMPONENTS=1..&_nCompon;
* Define variables;
var X{MACHINES, COMPONENTS} integer >=0;
var T;
* Define parameters;
number time{MACHINES, COMPONENTS};
number s{MACHINES};
number c{COMPONENTS};
* Load the time matrix;
read data data12 (where =(machine ne “demand”))
into [_N_]
{j in COMPONENTS} ;
* Load the component array;
read data data12 (where =(machine eq “demand”))
into
{j in COMPONENTS} ;
print c;
* Load the setup-time array;
read data data12 (where= (machine ne “demand”))
into [_N_] s[_N_]=col(“setup”);
* Define objective function;
min obj = T;
* Define constrains;
con Total{i in MACHINES}:
T- s[i] – sum{j in COMPONENTS: time[i,j] ne 1E10} time[i,j]*X[i,j] >=0;
con compon{j in COMPONENTS: j ne 0}: sum{i in MACHINES} X[i,j] =c[j];
con zero{i in MACHINES, j in COMPONENTS : time[i,j]=1E10}: x[i,j]=0;
* Solve the model;
solve with milp;
%put &_OROPTMODEL_;
expand;
* Create optimum values in a SAS dataset ‘optimout’;
create data &_optimout
from [MACHINES COMPONENTS]
={i in MACHINES, j in COMPONENTS: x[i,j]^=0}
amount=x ;
* End of OPTMODEL Procedure;
quit;
%mend model;
%macro report;
* Report the results in a tabulated form;
proc tabulate data=&_optimout;
title &_title;
class MACHINES COMPONENTS ;
var amount;
table MACHINES =” Machine”,
COMPONENTS*amount*sum
/ BOX=’Machines or the Component Allocation Problem’;
run;
%mend report;
%macro orcap;
%data;
%model;
%report;
%mend orcap;
%orcap;
/****************************************************************************
******************************END of the program*****************************
****************************************************************************/