Binary variable to count other variable within model

Problems with modeling
Post Reply
tingbhio
User
User
Posts: 1
Joined: 3 months ago

Binary variable to count other variable within model

Post by tingbhio »

Hi all,

In this code are 2 .gms files and 2 .lst files. Just as a quick clarification:

1. Final_V14.gms and Final_V14.lst
This code runs perfectly fine and does exactly what I want it to do.

The focus for my next version of the code is on the variable Mod__Nr(E). In this variable I count the amount of modules needed at position E... .

So for example at position E28, 39 modules are needed. However, for my next version I'd like to count the amount of positions there are in total. So is Mod__Nr =0 or >0. This brings me to Final_V15 as next version.

2. Final_V15.gms and Final_V15.lst
In this code I've added a new binary variable Alloc__Electrolyser that should count the amount of non-zero positions in Mod__Nr(E).


loop(E,
put fcpx 'indic ' eq_ELECTROLYSER_Trans1.tn(E) '$' Alloc__Electrolyser.tn(E) yes
/ 'indic ' eq_ELECTROLYSER_Trans0.tn(E) '$' Alloc__Electrolyser.tn(E) No / );
putclose fcpx
putclose fcpx

I try to loop it over the entire set of E with these as the corresponding equations:

*Constraints that will obtain binary values, depends on whether the model decides to transport syngas from electrolyser E to syngas demand location S

eq_ELECTROLYSER_Trans1(E).. Mod__Nr(E) =g= 0 ;

eq_ELECTROLYSER_Trans0(E) .. Mod__Nr(E) =e= 0 ;


However, my solution comes up as integer infeasible. Any idea based on the .gms and .lst file where my mistake is? Because I count the Alloc__Flow binary variables in a similar way.

This new binary variable should for example calculate in V14 that there are in total 11 positions in mod__Nr(E)


Let me know if you have any thoughts (: .
Attachments
Screenshot of variable Mod__Nr(E)
Screenshot of variable Mod__Nr(E)
Final_V14.log
Final_V14_Good
(1.44 MiB) Downloaded 132 times
Final_V14.gms
Final_V14_Good
(35.27 KiB) Downloaded 130 times
Final_V15.log
Final_V15_Error
(19.7 KiB) Downloaded 126 times
Final_V15.gms
Final_V15_Error_lst
(36.07 KiB) Downloaded 136 times
Fred
Posts: 373
Joined: 7 years ago

Re: Binary variable to count other variable within model

Post by Fred »

Hi,

It would be easier to help, if you could share the files requored to run your code. Just from looking at it, it is quite challenging to say why the model is integer infeasible without having access to the date that goes into the model.

On a side note, constraints like

Code: Select all

eq_ELECTROLYSER_Trans1(E)..                  Mod__Nr(E)                              =g=     0 
are superflous when the variable on the left hand side is nonnegative anyway.

I hope this helps!

Fred
Post Reply