Hi. am trying to solve this problem below I have a bunch of origins (O) , bunch of destinations (D) , bunch of shipments between them (i) . Have few box types to transport stuff for a given shipment from O to D. Each box has a cost and wt and vol restrictions. want the model to choose the optimum mix of box type and how many of them for each box type, based on cheapest cost. here is my attempted code. Tried and failed. Would appreciate if this can be mended to make it work. I need to find the optimum asset mix for a given shipment based on cheapest cost and also satisfying volume and weight capacities. proc optmodel;
set <str> ORG;
read data CASUSER.Unique_ORG into ORG = [ORG];
set <str> DES;
read data CASUSER.Unique_DES into DES = [DES];
set <str> BOX;
read data CASUSER.Unique_BOX into BOX = [BOX];
set <str> ISN;
read data CASUSER.Unique_ISN into ISN= [ISN];
/* A Binary variable that is 0 or 1 for a given asset for a given lane, 0 indicated not available, 1- available */
var Is_BoxAvalable_for_a_lane {ORG,DES,Box} binary;
read data CASUSER.BOXSpecs into [ORG Des Box] Is_BoxAvalable_for_a_lane = BoxAvailability;
/*RATES*/
num PerBox_Based_Rate {ORG,DES,BOX} init 0;
read data CASUSER.BOXRATE (where= (RateBasis="PerBox" and Ratetype='Linehaul')) into [ORG DES BOX] PerBox_Based_Rate=Rate;
/* End of Rates */
/* Input Dims */
num Vol_Org_Des_ISN {ORG,DES,ISN} init 0;
read data CASUSER.InputData_AssetMix into [ORG DES ISN] Vol_Org_Des_ISN=Volume;
num Wt_Org_Des_ISN {ORG,DES,ISN} init 0;
read data CASUSER.InputData_AssetMix into [ORG DES ISN] Wt_Org_Des_ISN=Weight;
/* End of Input Dims */
*/ Start Vol and Wt Capacity for Boxes */
num Vol_Capacity {ORG,DES,BOX};
read data CASUSER.BOXSPECS into [ORG DES BOX] Vol_Capacity=Volume_Capacity;
print Vol_Capacity;
num Wt_Capacity {ORG,DES,BOX};
read data CASUSER.BOXSPECS into [ORG DES BOX] Wt_Capacity=Wt_Capacity;
*/ End of Vol and Wt Capacity for Boxes */
/* Decision Variable */
var BoxesNeeded {ORG,DES,ISN} >= 0;
/*Define Implicit Variables */
impvar PerBox_Based_Costs = sum {o in ORG, d in DES,b in BOX, i in ISN} PerBox_Based_Rate [o,d,b] * BoxesNeeded [o,d,i];
impvar Boxes{i in ISN}=sum{o in ORG, d in DES, b in BOX} BoxesNeeded [o,d,i];
Min TotalCost = PerBox_Based_Costs;
/* Constraints */
/*Make sure the Volume of a given ISN across boxes adds up the input */
con Check {i in ISN}:Boxes[i] = sum{o in ORG, d in DES, b in BOX} Is_BoxAvalable_for_a_lane[o,d,b]*Vol_Org_Des_ISN[o, d, i];
expand Check;
con Ensure_Unavailable_Asset_Not_Chosen {o in ORG, d in DES, i in ISN}:
sum {b in BOX} BoxesNeeded[o,d,i]<= sum {b in BOX} BoxesNeeded [o,d,i]*Is_BoxAvalable_for_a_lane[o,d,b];
expand EnSure_Unavailable_Asset_Not_Chosen;
con Vol_Constraint {i in ISN} :
sum {o in ORG, d in DES} Vol_Org_Des_ISN [o,d,i] <= sum {o in ORG, d in DES,b in BOX} Is_BoxAvalable_for_a_lane[o,d,b]*Vol_Capacity[o,d,b];
expand Vol_Constraint;
solve with milp;
... View more