Pyrite | Level 9

## Forcing a supplier to one consolidator only

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
Pyrite | Level 9

## Re: Forcing a supplier to one consolidator only

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 ?

8 REPLIES 8
SAS Super FREQ

## Re: Forcing a supplier to one consolidator only

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.`

Pyrite | Level 9

## Re: Forcing a supplier to one consolidator only

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 ?

SAS Super FREQ

## Re: Forcing a supplier to one consolidator only

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

Pyrite | Level 9

## Re: Forcing a supplier to one consolidator only

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

Thanks again

Pyrite | Level 9

## Re: Forcing a supplier to one consolidator only

yes. it is 100% perfect. thank you

Pyrite | Level 9

## Re: Forcing a supplier to one consolidator only

can you confirm if this is correct way of declaring ?

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

SAS Super FREQ

## Re: Forcing a supplier to one consolidator only

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

Pyrite | Level 9

## Re: Forcing a supplier to one consolidator only

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

Discussion stats
• 8 replies
• 636 views
• 2 likes
• 2 in conversation