Hi Rob I tried that but somehow I am not able to see the expected output. I have attached the dataset I used . I am looking for a ISN='SHA_SEA_722' that has 55 Vol and 30000 Wt. For SHA-SEA the LCL availability is there. However, the rate for LCL for SHA-SEA is not a PerBox Based one. It is a Per Vol based one that i have not even taken into the model yet. So, I would expect that the model does not pick LCL as the winner for SHA-SEA because there is no BoxBased Rate. We have culled out only those rates where Rate >0. But I am not sure how does the model pick LCL for SHA-SEA. We have not even initialized the costs to 0. Here is my code below. Once I am done with this , I want to add couple of more constraints, that are like if a particular Box is selected for a given ISN, the volume is atleast 'x". I will let you know on that if i face issues but i want to understand / solve this LCL thing first. 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];
/*Read ISN Wt and Volume for a given ISN* - START */
set <str> ISN;
str Org_ISN {ISN};
str Des_ISN {ISN};
num Vol_ISN {ISN} init 0;
num Wt_ISN {ISN} init 0;
read data CASUSER.InputData_AssetMix into ISN=[ISN] Org_ISN=ORG Des_ISN=DES Vol_ISN=Volume Wt_ISN=Weight;
/*Read ISN Wt and Volume for a given ISN* - END*/
/*Read Wt and Volume Capacity for a given ORG, DES, BOX - START */
num Volume_Capacity {ORG,DES,BOX} init 0; num Volume_Min {ORG,DES,BOX} init 0;
num Wt_Capacity {ORG,DES,BOX} init 0;
read data CASUSER.BOXSPECS into [ORG DES BOX]
Volume_Capacity=Volume_Capacity
Wt_Capacity=Weight_Capacity
Volume_Min=Volume_Min;
/*Read Wt and Volume Capacity for a given ORG, DES, BOX - END */
/* A Binary variable that is 0 or 1 for a given asset for a given lane, 0 indicated not available, 1- available */
num Is_BoxAvalable_for_a_lane {ORG,DES,Box};
read data CASUSER.BOXSpecs into [ORG Des Box] Is_BoxAvalable_for_a_lane = BoxAvailability;
/* Decision Variable - START */
var BoxesNeeded {ISN,BOX}>=0 integer;
/* Decision Variable - END */
/*Define Rates and Implicit Variables - START */
set <str,str,str> PerBox_Based_Rate_NoZeroes;
num PerBox_Based_Rate {PerBox_Based_Rate_NoZeroes};
read data CASUSER.BOXRATE
(where=(RateBasis="PerBox" and Ratetype='Linehaul' and Rate>0))
into PerBox_Based_Rate_NoZeroes=[ORG DES BOX] PerBox_Based_Rate=Rate;
impvar PerBox_Based_Costs = sum {i in ISN, b in BOX: <Org_ISN[i],Des_ISN[i],b> in PerBox_Based_Rate_NoZeroes}
PerBox_Based_Rate[Org_ISN[i],Des_ISN[i],b] * BoxesNeeded[i,b];
/*Define Implicit Variables - END */
print PerBox_Based_Rate;
Min TotalCost = PerBox_Based_Costs;
/* Constraints - START */
for {i in ISN, b in BOX: Is_BoxAvalable_for_a_lane[Org_ISN[i],Des_ISN[i],b] = 0}
fix BoxesNeeded[i,b] = 0;
con Vol_Constraint {i in ISN}:
sum {b in BOX} Volume_Capacity[Org_ISN[i],Des_ISN[i],b] * BoxesNeeded[i,b] >= Vol_ISN[i];
con Wt_Constraint {i in ISN}:
sum {b in BOX} Wt_Capacity[Org_ISN[i],Des_ISN[i],b] * BoxesNeeded[i,b] >= Wt_ISN[i];
/* Constraints - END */
solve with milp / decomp=(method=concomp);
print BoxesNeeded;
expand; Here are my results of expand: I just focussed on this one ISN for test purposes. Var BoxesNeeded[SHA_SEA_722,'40F'] INTEGER >= 0
Fix BoxesNeeded[SHA_SEA_722,'20F'] BINARY = 0
Var BoxesNeeded[SHA_SEA_722,'40H'] INTEGER >= 0
Var BoxesNeeded[SHA_SEA_722,'45F'] INTEGER >= 0
Var BoxesNeeded[SHA_SEA_722,LCL] INTEGER >= 0
Impvar PerBox_Based_Costs = 880*BoxesNeeded[SHA_SEA_722,'20F'] + 1100*BoxesNeeded[SHA_SEA_722,'40F'] + 1210*
BoxesNeeded[SHA_SEA_722,'40H'] + 1320*BoxesNeeded[SHA_SEA_722,'45F']
Minimize TotalCost=PerBox_Based_Costs
Constraint Vol_Constraint[SHA_SEA_722]: 60*BoxesNeeded[SHA_SEA_722,'40F'] + 29*BoxesNeeded[SHA_SEA_722,'20F'] + 69*
BoxesNeeded[SHA_SEA_722,'40H'] + 75*BoxesNeeded[SHA_SEA_722,'45F'] + 17*BoxesNeeded[SHA_SEA_722,LCL] >= 55
Constraint Wt_Constraint[SHA_SEA_722]: 29000*BoxesNeeded[SHA_SEA_722,'40F'] + 14000*BoxesNeeded[SHA_SEA_722,'20F'] + 35000*
BoxesNeeded[SHA_SEA_722,'40H'] + 55000*BoxesNeeded[SHA_SEA_722,'45F'] + 10000*BoxesNeeded[SHA_SEA_722,LCL] >= 30000
... View more