Hi.
I have a set of Ports, IC and DCs. I want to enfore a new constraint. The constraint is that a given origin port can go to only 1 IC. I tried to do this by declaring an impvar called
impvar TotalNumberofICsfromEachPort {p in Ports, c in IC} = sum {d in DC} Build [c]*ContainersfromPortstoICtoDC [p,c,d]/ContainersfromPortstoICtoDC [p,c,d]; Is there a better way to achieve what I need?
I specified the constraint as follows but I am sure I am not doing it correctly.
con OneIConly:sum{p in Ports, c in IC} TotalNumberofICsfromEachPort=1;
As a background info, here are some relevant things:
var ContainersfromPortstoICtoDC {Ports,IC,DC}>=0;
set<str> Ports;/* this is a set of Ports*/
set<str> DC; /* this is a set of ICs*/
set<str> IC; /* this is a set of DCs*/
var Build {IC} binary; /* 1 if open and 0 if closed */
Thank you. I did not understand the upper bound part.
I am thinking that the upperbound on ContainersfromPortstoICtoDC [p,c,d] can be the total demand I see in the data. In which case, what is the syntax for declaring it as a variable ?
I would do it this way:
/* IsICPort[p,c] = 1 if port p goes to IC c, 0 otherwise */
var IsICPort{Ports, IC} binary;
/* given origin port can go to only 1 IC */
con OneIConly{p in Ports}:
sum{c in IC} IsICPort[p,c] = 1;
/* if ContainersfromPortstoICtoDC[p,c,d] > 0 then IsICPort[p,c] = 1, otherwise redundant */
con Link{p in Ports, c in IC, d in DC}:
ContainersfromPortstoICtoDC[p,c,d] <= ContainersfromPortstoICtoDC[p,c,d].ub * IsICPort[p,c];
For this to work, you need to define upper bounds on the ContainersfromPortstoICtoDC[p,c,d] variables, either in the VAR statement or by modifying the .ub variable suffix.
Thank you. I did not understand the upper bound part.
I am thinking that the upperbound on ContainersfromPortstoICtoDC [p,c,d] can be the total demand I see in the data. In which case, what is the syntax for declaring it as a variable ?
Yes, that seems like a reasonable upper bound. You can use <= in the VAR statement.
Thank Rob. I think it worked. Let me do some more checks to make sure it is 100% good.
Thanks again
yes. it is 100% perfect. thank you
can you confirm if this is correct way of declaring ?
var ContainersfromPortstoICtoDC {Ports,IC,DC} >=0 <=15000;
Yes, that syntax is correct, but it would be better to use a SUM expression instead of hard-coding 15000.
ok got it. will do that. good practice. thanks
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.