本人写了一个SAS程序,内容如题,请问我的程序哪里错了。谢谢大家。
title 'An assignment problem';
data object;
input machine customer grade1-grade6;
cards;
1 1 102 140 105 105 125 148
1 2 115 133 118 118 143 166
1 3 70 108 83 83 88 86
1 4 79 117 87 87 107 105
1 5 77 115 90 90 105 148
2 1 123 150 125 124 154 .
2 2 130 157 132 131 166 .
2 3 103 130 115 114 129 .
2 4 101 128 108 107 137 .
2 5 118 145 130 129 154 .
3 1 83 . . 97 122 147
3 2 119 . . 133 163 180
3 3 67 . . 91 101 101
3 4 85 . . 104 129 129
3 5 90 . . 114 134 179
4 1 108 121 79 . 112 132
4 2 121 132 92 . 130 150
4 3 78 91 59 . 77 72
4 4 100 113 76 . 109 104
4 5 96 109 77 . 105 145
;
run;
data demand;
input customer grade1-grade6;
cards;
1 100 100 150 150 175 250
2 300 125 300 275 310 325
3 400 0 400 500 340 0
4 250 0 750 750 0 0
5 0 600 300 0 210 360
;
run;
data resource;
input machine grade1-grade6 avail;
cards;
1 0.25 0.275 0.3 0.35 0.31 0.295 744
2 0.3 0.3 0.305 0.315 0.32 . 244
3 0.35 . . 0.32 0.315 0.3 790
4 0.28 0.275 0.26 . 0.25 0.295 672
;
/*build the linear programming model*/
data model;
array grade{6} grade1-grade6;/*变量名与3个数据集要对应哦*/
length _type_ $ 8 _row_ $ 8 _col_ $ 8;
keep _type_ _row_ _col_ _coef_;/*这句话表示只保留这么多个变量*/
ncust=5;nmach=4;ngrade=6;_col_=1;
_type_='max';
_row_='obj';
do k=1 to nmach;
do i=1 to ncust;
link readobj;
do j=1 to ngrade;
if grade{j}^=. then do;
_col_='x'||put(i,1.)||put(j,1.)||put(k,1.);
_coef_=grade{j};
output;
end;
end;
end;
end;
/*generate the demand constraints*/
do i=1 to ncust;
link readdemand;
do j=1 to ngrade;
if grade{j}^=. then do;
_type_='EQ';
_row_='demand'||put(i,1.)||put(j,1.);
_col_='_RHS_';
_coef_=grade{j};
output;
_type_='';
do k=1 to nmach;
_col_='x'||put(i,1.)||put(j,1.)||put(k,1.);
_coef_=1.0;
output;
end;
end;
end;
end;
do k=1 to nmach;
link readresource;
_type_='LE';
_row_='manchine'||put(k,1.);
_col_='RHS';
_coef_=avail;
output;
_type_='';
do i=1 to ncust;
do j=1 to ngrade;
if grade{j}^=. then do;
_col_='x'||put(i,1.)||put(j,1.)||put(k,1.);
_coef_=grade{j};
output;
end;
end;
end;
end;
/*generate the machine constraints*/
readobj: set object; return;
readdemand: set demand; return;
readresource: set resource; return;
run;
proc lp data=model;
run;