Mutual Exclusive Choice Variables

Problems with modeling
Post Reply
doriengard
User
User
Posts: 1
Joined: 1 year ago

Mutual Exclusive Choice Variables

Post by doriengard »

Assume I have the following example code in a larger model

##
SET INDEX /A, B, C, D, E/;
ALIAS (INDEX,INDEX2);

POSITIVE VARIABLE PFLOW(INDEX,INDEX2);
##

This set of code implements a 5x5 matrix of values zero or greater in the name PFLOW indexed A..E by A..E
Assume that the variable PFLOW is a choice variable in a model.

My problem is that I need to have PFLOW(INDEX,INDEX2) to be mutual exclusive with PFLOW(INDEX2,INDEX)
For example if PFLOW(A,B) is >0 then PFLOW(B,A) = 0.
This rule does not apply when INDEX=INDEX2

I have tried the following:
1) add a binary variable corresponding to the PFLOW array
BINARY VARIABLE bPFLOW(INDEX,INDEX2);

2) add the following equation to set the BPFLOW value to zero if the value is zero and 1 if not zero
eqn(INDEX,INDEX2)..
PFLOW(INDEX,INDEX2) - 1e8 * bPFLOW(INDEX,INDEX2) =L= 0.0;

3) constraint to limit one of the pair to have a value >0
eqn2(INDEX,INDEX2)..
bPFLOW(INDEX,INDEX2) + bPFLOW(INDEX2,INDEX) =L= 1.0;

The problem is that equation 2 can assign 0 or 1 to bPFLOW if the value of PFLOW is zero.

I am willing to change the structure of the model so the PFLOW become SOS1 variables, but I'm not sure how to do that. The real model is 11x11 with only 15 pairs (and their inverse) active in the model.

In short, I need an algorithm with choice positive variable A and choice positive variable B to not both be > zero using indexes and not defining pairs of SOS1 variables

Thanks
Michael Reed
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: Mutual Exclusive Choice Variables

Post by bussieck »

Michael,

I think it is good to see the binary variable bFlow(A,B) as the direction in which you allow flow. So if bFlow(A,B) = 1, then you allow flow on A->B (i.e. Flow(B,A)=0) and bFlow(A,B)=0, then you allow flow on B->A (i.e. Flow(A,B)=0). So you only see the bFlow variable for pairs A,B with ord(A)<ord(B). So with the following constraints you should be good:

Code: Select all

scalar maxFlow;
Binary variable bFlow(i,i2);
Positive variable Flow(i,i2);
equation e1(i,i2); e1(i,i2)$(ord(i)<ord(i2)).. Flow(i2,i1) =l= maxFlow*(1-bFlow(i,i2));
equation e2(i,i2); e2(i,i2)$(ord(i)<ord(i2)).. Flow(i,i2) =l= maxFlow*(bFlow(i,i2));
You have maxFlow=1e8. Solvers don't like big numbers. Try to estimate how big a flow can be on any arc. This can often be calculated from some other data (demand or supply data).

Hope this helps,
-Michael
Post Reply