Rob Thanks for your support as always. I am learning a lot of stuff thanks to you. I am creating a new thread, based on this, (earlier thread), just to be clear. I think we are almost done, just left with 4 questions/help. I am trying to replicate the toy model to the full model by adding indices for T1 (days, T2(weeks) and Org, Des because rates and specs are function of org, des, box, mol, t1 and t2 as you know. Based on your earlier comment, I realized that we should go for the case where "vendor cooperates with each other to reduce overall network cost", in which case we can make the model simpler by not having the fix/unfix and the second solve. The $3,622 is what we need as it is the true optimum. When I remove those fix/unfixes , rational constraint and second solve, the model gives $3,622 which is what we want. I want the same $3,622 when I do the full model. That is my goal. Now I have 4 questions when we translate this to full model . My full model code is at the bottom of these 4 questions. (1) Without i in ISN: For the full model, I have no problems when I have i in ISN because it has Org, DES, T1 and T2 in it and I can cull out using [i], example Org[i]. But when it comes to CFS constraints, impvars, I am not able to do it correctly as there are no i in ISN. (2) Proportion: There is no proportion decision variable and a constraint related to it in the code. But I tested few different numbers of Volume in ISNs and the code seems to be doing it correctly. I just wanted to make sure that the proportion is accounted for, i.e., for a given ISN, the proportion in each box adds up to 1 for CYS. And for CFS, for a given week, the proportion of Total Volume adds up to 1. The following code is what we had earlier where there was no MOL, day and week, that was done a year ago. I tried in the full model but was not successful. If we do not need these proportion variables at all, it then it is fine. var Proportion {ISN,BOX} >= 0 <= 1; impvar VolumeInsideBox {i in ISN, b in BOX} = Volume_ISN[i] * Proportion[i,b];
con Volume_Constraint {i in ISN, b in BOX}: Volume_Capacity[Org_ISN[i],Des_ISN[i],b] * BoxesNeeded[i,b] >= VolumeInsideBox[i,b]; 3) Create Data step: For the output, I would like to have it in a format like the one that I have attached in this spreadsheet (adding on to the Toy.xlsx) from cells A25 to X29. Again, I tried (just for CYS) in the full model but was facing syntax issues. (4) Rational Vendor error: This is the last preference as we are not using the constraint anymore, now that we said we will let the vendor cooperate. This will be just for my understanding. Not an urgent one. 126 con RationalVendor {i in ISN}:
127 IsMol[i,'CFS'] = 1 implies
-------
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, !!, *, **, +, ',', -, .., /, <>, ><, BY, CROSS, DIFF, ELSE, INTER,
SUFFIXES, SYMDIFF, TO, UNION, ^, ||.
ERROR 76-322: Syntax error, statement will be ignored.
128 vol_ISN[i] * (BoxBasedCostCFS + sum {j in ISN} (volRate['CFS'] * vol_ISN[j] + shipmentRate['CFS']) * IsMol[j,'CFS'])
129 <= optCYSCost[i] * TotalVol['CFS']; My full code is here below. 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> MOL;
read data CASUSER.Unique_MOL into MOL = [MOL];
set <str> T1;
read data CASUSER.Unique_T1 into T1 = [T1];
set <str> T2;
read data CASUSER.Unique_T2 into T2 = [T2];
/*Read ISN Wt and Volume for a given ISN* - START */
set <str> ISN;
str Org_ISN {ISN};
str Des_ISN {ISN};
str T1_ISN {ISN};
str T2_ISN {ISN};
num Volume_ISN {ISN} init 0;
num Weight_ISN {ISN} init 0;
read data CASUSER.InputData_AssetMix into ISN=[ISN] Org_ISN=ORG Des_ISN=DES Volume_ISN=Volume Weight_ISN=Weight T1_ISN=T1 T2_ISN=T2;
num T2_Volume{T2} init 0;
read data CASUSER.Unique_T2 into [T2] T2_Volume=T2_Volume;
num T2_Weight{T2} init 0;
read data CASUSER.Unique_T2 into [T2] T2_Weight=T2_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,MOL,T1,T2} init 0; num Volume_Min {ORG,DES,BOX,MOL,T1,T2} init 0;
num Weight_Capacity {ORG,DES,BOX,MOL,T1,T2} init 0; num Weight_Min {ORG,DES,BOX,MOL,T1,T2} init 0;
read data CASUSER.BOXSPECS into [ORG DES BOX MOL T1 T2]
Volume_Capacity=Volume_Capacity
Weight_Capacity=Weight_Capacity
Volume_Min=Volume_Min
Weight_Min=Weight_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,MOL,T1,T2};
read data CASUSER.BOXSpecs into [ORG Des Box Mol T1 T2] Is_BoxAvalable_for_a_lane = BoxAvailability;
/* Decision Variable - START */
var BoxesNeeded_CYS {ISN,BOX,T1,T2} >= 0 integer;
var BoxesNeeded_CFS {BOX,T2} >= 0 integer;
var Is_ISN_MOL{ISN,MOL} binary;
/* Decision Variable and Associated Impvars - END */
/*Define Rates and ImplicitVariables START */
/*Box Based Costs START */
set <str,str,str,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 MOL T1 T2] PerBox_Based_Rate=Rate;
impvar PerBox_Based_Costs_CYS {i in ISN} = sum {b in BOX,m in {'CYS'},d in T1,w in T2: <Org_ISN[i],Des_ISN[i],b,m,d,w> in PerBox_Based_Rate_NoZeroes}
PerBox_Based_Rate[Org_ISN[i],Des_ISN[i],b,m,d,w] * BoxesNeeded_CYS[i,b,d,w];
impvar PerBox_Based_Costs_CFS {w in T2} = sum {b in BOX} PerBox_Based_Rate[b,w] * BoxesNeeded_CFS[b,w];
impvar TotalBoxBasedCost = sum {i in ISN} PerBox_Based_Costs_CYS[i] + sum {w in T2} PerBox_Based_Costs_CFS[w];
/*Box Based Costs END */
/*Vol Based Costs START*/
set <str,str,str,str,str,str> PerVol_Based_Rate_NoZeroes;
num PerVol_Based_Rate {PerVol_Based_Rate_NoZeroes};
read data CASUSER.BOXRATE (where=(RateBasis="PerVolUOM" and Ratetype='Carrier_BOL' and Rate>0))
into PerVol_Based_Rate_NoZeroes=[ORG DES MOL BOX T1 T2] PerVol_Based_Rate=Rate;
impvar VolBasedCost {i in ISN} = sum {b in BOX,m in MOL,d in T1,w in T2: <Org_ISN[i],Des_ISN[i],b,m,T1_ISN[i],T2_ISN[i]> in PerVol_Based_Rate_NoZeroes}
Volume_ISN[i] * PerVol_Based_Rate[Org_ISN[i],Des_ISN[i],b,m,T1_ISN[i],T2_ISN[i]] * Is_ISN_Mol[i,m];
impvar TotalVolBasedCost = sum {i in ISN} VolBasedCost[i];
/*Vol Based Costs END*/
/*Shipment Based Costs START*/
set <str,str,str,str,str,str> PerShp_Based_Rate_NoZeroes;
num PerShp_Based_Rate {PerShp_Based_Rate_NoZeroes};
read data CASUSER.BOXRATE (where=(RateBasis="PerShipment" and Ratetype='Export_Declaration' and Rate>0))
into PerShp_Based_Rate_NoZeroes=[ORG DES MOL BOX T1 T2] PerShp_Based_Rate=Rate;
impvar ShipmentBasedCost {i in ISN} = sum {b in BOX,m in MOL,d in T1,w in T2: <Org_ISN[i],Des_ISN[i],b,m,T1_ISN[i],T2_ISN[i]> in PerShp_Based_Rate_NoZeroes}
PerShp_Based_Rate[Org_ISN[i],Des_ISN[i],b,m,T1_ISN[i],T2_ISN[i]] * Is_ISN_Mol[i,m];
impvar TotalShipmentBasedCost = sum {i in ISN} ShipmentBasedCost[i];
/*Shipment Based Costs END*/
/*Define Rates and ImplicitVariables END*/
Min TotalCost = TotalBoxBasedCost + TotalVolBasedCost + TotalShipmentBasedCost;
/* Constraints START*/
for {i in ISN, b in BOX,m in MOL,d in T1,w in T2: Is_BoxAvalable_for_a_lane[Org_ISN[i],Des_ISN[i],b,m,d,w] = 0}
fix BoxesNeeded_CYS[i,b,d,w] = 0;
for {i in ISN, b in BOX,m in MOL,d in T1,w in T2: Is_BoxAvalable_for_a_lane[Org_ISN[i],Des_ISN[i],b,m,d,w] = 0}
fix BoxesNeeded_CFS[b,w] = 0;
con OneMOL{i in ISN}:
sum{M in MOL} Is_ISN_MOL[i,m] = 1; /* This is to make sure one ISN can go either CYS or CFS */
con BoxConCYS {i in ISN}:
sum {b in BOX} Volume_Capacity[Org_ISN[i],Des_ISN[i],b,'CYS',T1_ISN[i],T2_ISN[i]] * BoxesNeeded_CYS[i,b,T1_ISN[i],T2_ISN[i]] >= Volume_ISN[i] * Is_ISN_Mol[i,'CYS'];
impvar TotalVol {m in MOL} = sum {i in ISN} Volume_ISN[i] * Is_ISN_Mol[i,m];
con BoxConCFS: {i in ISN}:
sum {b in BOX} Volume_Capacity[Org_ISN[i],Des_ISN[i],b,'CYS',T1_ISN[i],T2_ISN[i]] * BoxesNeeded_CFS[b,T2_ISN[i]] >= TotalVol['CFS'];
solve with milp / decomp=(method=concomp);
num optCYSCost {ISN};
for {i in ISN} optCYSCost[i] = PerBox_Based_Costs_CYS[i] + VolBasedCost[i] + ShipmentBasedCost[i];
print BoxBasedCostCYS VolBasedCost ShipmentBasedCost optCYSCost;
num volShareCFS {i in ISN} = vol_ISN[i] * Is_ISN_Mol[i,'CFS'].sol / TotalVol['CFS'].sol;
print IsMol;
print NumBoxesCYS NumBoxesCFS;
print BoxBasedCostCYS BoxBasedCostCFS;
print volShareCFS VolBasedCost TotalVolBasedCost TotalVol;
print ShipmentBasedCost;
quit;
... View more