BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Pyrite | Level 9


Thank you very much I will use the updated code and let you know. I will also add the proportion. Will work on the full fledged model and let you know of any issues. The one question i have is on how my point (c) in my earlier comment. How do I write the impvar and constraints correctly? Example : impvar like "PerBox_Based_Costs_CFS" and constraints like "BoxConCFS" in my code, because in your code there is no need of i in ISN, but in the full fledged model, capacity or rate is a function of Org, Des, MOL, Box , T1 and T2. Without i in ISN, i would like to learn how to write the constraints and impvar correctly. 

Thanks a ton for all your support as always. 


I made one more correction to RationalVendor in the toy code, and the new optimal solution has objective value $4304, with both V1 and V2 using CYS.  Note that for the $3622 solution in your spreadsheet, vendor V2 does not behave rationally because the CYS cost is $1050 < $1145, so V2 would instead choose CYS.  On the other hand, $3622 is still the correct optimal objective value if the vendors cooperate.


Regarding your question (c), I think this is what you want:

impvar PerBox_Based_Costs_CFS {w in T2} = sum {b in BOX} PerBox_Based_Rate_CFS[b,w] * BoxesNeeded_CFS[b,w];

impvar TotalVol {m in MOL, w in T2} = sum {i in ISN} Volume_ISN[i] * Is_ISN_Mol[i,m,w];

con BoxConCFS {w in T2}: sum {b in BOX} Volume_Capacity_CFS[b,w] * BoxesNeeded_CFS[b,w] >= TotalVol['CFS',w];


Pyrite | Level 9


This is a very quick syntax question. To your toy code, I have this one. There is a minimum charge to volbased cost. If Volbased cost >Min then Volbased cost else Min . I get syntax errors. Can you tell me what is the correct way?


num volRate_Min{MOL} = [0 75];

for {i in ISN,m in MOL} do;
if VolBasedCost[i] > volRate_Min[m] then fix VolBasedCost[i]=VolBasedCost[i];
else fix VolBasedCost[i] = volRate_Min[m];

You cannot fix an implicit variable, and you can fix a variable only to a constant.  Instead you can modify the IMPVAR statement as follows:

/*   impvar VolBasedCost {i in ISN} = Volume_ISN[i] * sum {m in MOL} volRate[m] * IsMol[i,m];*/

   impvar VolBasedCost {i in ISN} = sum {m in MOL} max(Volume_ISN[i] * volRate[m], volRate_Min[m]) * IsMol[i,m];

 Because of the OneMol constraint, each i will have IsMol[i,m] = 1 for exactly one m.  The new IMPVAR declaration will enforce VolBasedCost[i] to be the larger of Volume_ISN[i] * volRate[m] and volRate_Min[m] for that m.

Pyrite | Level 9


Thank you. This is perfect.




The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.


Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 


Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 19 replies
  • 1 like
  • 2 in conversation