Connecting binary variables

Problems with modeling
Post Reply
0000
User
User
Posts: 1
Joined: 6 months ago

Connecting binary variables

Post by 0000 » 1 week ago

Hello everyone.
I had a query regarding connecting two binary variables.
I am modelling a transport system of biomass with different types of vehicles.


zfr(f,r,t,v) is a binary variable showing if a route is chosen using some specific vehicle that transfers biomass from farm f to RBPD r.
yR(r) is binary variable selecting the no. of RBPDs required out of 95.

I have formulated the code but the selection of 'r' in zfr(f,r,t,v) is different than what it shows to be in yR(r) which doesn't make sense because I think they are not related.
How can I do that?

Attaching the gams file.
TransCode.gms
(11.54 KiB) Downloaded 12 times

abhosekar
Moderator
Moderator
Posts: 265
Joined: 1 year ago

Re: Connecting binary variables

Post by abhosekar » 6 days ago

Hi,

I don't understand your question completely but some things look fishy to me.
You say yR(r) is a binary variable to choose one number out of 95. So this looks like you want to write binary expansion for integer variables. But you don't have a constraint saying only one yR(r) can be 1 and rest should be zero. For example, you cannot have yr('10') and yr('20') both 1.

Code: Select all

sum(r, yR(r)) =e= 1;
Also, the following constraint tells me that somehow you are interested in the value at which yR is 1.

Code: Select all

m2(r )..            yR(r )         =l=      r_capacity(r );
For example, if yR is true for 20, you want 20 =l= r_capacity(r)

But yR can only be 1 or 0. So you are essentially doing r_capacity =g= 1 when yr is 1. This does not make sense.

What I believe you need is an integer variable that takes the value.

integer variable yri;

You can then link integer variable yri and binary variable yr as follows.

Code: Select all

sum(r, ord(r)*yR(r)) =e= yri;
sum(r, yr(r)) =e= 1 ;
With the above two constrints, you make sure that if say yr('20') is 1, yri is 20 and rest of yr(r) are 0.

and then you can replace constraint m2(r) with the following

Code: Select all

m2(r).. yri =l= r_capacity(r);


Hopefully your original problem gets resolved once you resolve this.

- Atharv

Post Reply