proc optmodel; set DC = {'BO','NA','PR','SP','WO'}; set City = {'BO','BR','CO','HA','MN','NA','NH','NL','PO','PR','SP','WO'}; number distance{DC,City}=[ 0 93 69 98 55 37 128 95 62 42 82 34 37 65 33 103 20 0 137 113 48 72 79 41 42 106 105 73 92 72 94 57 104 0 68 38 82 59 101 27 93 79 63 57 127 68 0 47 34 68 72 66 60 41 98 71 85 38 47 0 ]; number proximity{DC,City}=[ 1 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 1 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 1 1 1 ]; number transcost = 1; number fixcost{DC} = [10000 10000 10000 10000 10000]; number capacity{DC} = [2000 2000 2000 2000 2000]; number demand{City} = [425 12 43 125 110 86 129 28 66 320 220 182]; number Pmin = 1; number Pmax = 5; number totaldemand = sum{j in City}demand[j]; var open{DC} binary; var flow{DC, City} >= 0; minimize TotalCost = /*Fixed Costs*/ sum{i in DC}fixcost[i]*open[i] + /*Transportation Costs*/ transcost*sum{i in DC, j in City}flow[i,j]*distance[i,j] ; con capacitycon{i in DC}: sum{j in City}flow[i,j] <= capacity[i]; con demandcon{j in City}: sum{i in DC}flow[i,j] = demand[j]; con linkingcon{i in DC, j in City}: flow[i,j]-totaldemand*open[i] <= 0; con mincon: sum{i in DC}open[i] >= Pmin; con maxcon: sum{i in DC}open[i] <= Pmax; con maxavediscon: sum{i in DC, j in City}distance[i,j]*flow[i,j] <= 60*totaldemand; con minfiftycon: sum{i in DC, j in City}proximity[i,j]*flow[i,j] >= 0.8*totaldemand; solve; print TotalCost open flow ; expand; quit;