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

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 */

1 ACCEPTED SOLUTION

Accepted Solutions
Santha
Pyrite | Level 9

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 ?

 

View solution in original post

8 REPLIES 8
RobPratt
SAS Super FREQ

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.

Santha
Pyrite | Level 9

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 ?

 

RobPratt
SAS Super FREQ

Yes, that seems like a reasonable upper bound.  You can use <= in the VAR statement.

Santha
Pyrite | Level 9

Thank Rob. I think it worked. Let me do some more checks to make sure it is 100% good.

Thanks again

Santha
Pyrite | Level 9

yes. it is 100% perfect. thank you 

Santha
Pyrite | Level 9

can you confirm if this is correct way of declaring ?

var ContainersfromPortstoICtoDC {Ports,IC,DC} >=0 <=15000;

RobPratt
SAS Super FREQ

Yes, that syntax is correct, but it would be better to use a SUM expression instead of hard-coding 15000.

Santha
Pyrite | Level 9

ok got it. will do that. good practice. thanks

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 8 replies
  • 1188 views
  • 2 likes
  • 2 in conversation