Dear Boss @RobPratt RobPratt 🙂 I need your help again in the below code. my issue is that i know the logical thinking of how to solve the issue so I know the how to solve it mathematically but since I'm not that godd in SAS programming I am asking for you kind help in programming. in the below code I want to add constraint that says that I need DC 1 and DC 2 are open by default , and I need the optimization to choose the best DC from 'Potential DC 3', 'Potential DC 4', 'Potential DC 5' in addition to DC 1 and 2 which are forced to be open as mentioned before. also I want to add a level of service constraint that says 75% of demand should be within 50 miles of a DC and the max average distance from a DC is <= 60 mile. Your help is always appreciated. Proc optmodel;
set Plants = {'Plant 1','Contractor'};
set CentralWH = {'DC 1', 'DC 2', 'Potential DC 3', 'Potential DC 4', 'Potential DC 5'};
set RegionalWH = {'SO 1','SO 2','SO 3','SO 4','SO 5','SO 6','SO 7','SO 8'};
number outbounddist {Plants,CentralWH} = [
77 48 41 57 94
54 33 21 94 44
];
number inbounddist {CentralWH,RegionalWH} = [
62 55 114 106 51 76 122 80
63 92 90 50 88 47 136 47
76 85 56 65 129 40 89 100
42 128 74 70 45 56 81 131
77 135 118 59 124 93 41 94
];
number fixedcostWH {CentralWH} = [100 100 80 70 60];
number varcostWH {CentralWH} = [10 10 25 30 50];
number varcostplant {Plants} = [10 50];
number Demand {RegionalWH} = [121 96 166 175 210 130 180 160];
number Supply {Plants} = [1250 200];
var X {Plants,CentralWH} integer >=0;
var Z {CentralWH,RegionalWH} integer >=0;
var Y {CentralWH} binary;
min totalcost = sum {p in Plants,c in CentralWH} X[p,c]*1.5*outbounddist[p,c]+
sum {p in Plants,c in CentralWH} X[p,c]*varcostplant[p]+
sum {c in CentralWH,r in RegionalWH} Z[c,r]*1*inbounddist[c,r]+
sum {c in CentralWH,r in RegionalWH} Z[c,r]*varcostWH[c]+
sum {c in CentralWH} Y[c]*fixedcostWH[c];
con supplycons {p in Plants}: sum {c in CentralWH} X[p,c]<=Supply[p];
/*con supplycons1{p in Plants}: sum {c in CentralWH} X[p,'DC 1']>=1;*/
/*con supplycons2{p in Plants}: sum {c in CentralWH} X[p,'DC 2']>=1;*/
con demandcons {r in RegionalWH}: sum {c in CentralWH} Z[c,r]>=Demand[r];
con nonstock {c in CentralWH}: sum {p in Plants}X[p,c]-sum {r in RegionalWH}Z[c,r]=0;
con conserva {p in Plants,c in CentralWH}:X[p,c]-Y[c]*Supply[p]<=0;
con numberofDC : sum {c in CentralWH} Y[c]>=1;
solve;
print X Y Z totalcost;
quit;
... View more