Binary variable to count other variable within model
Posted: Tue Feb 27, 2024 2:23 pm
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 (: .
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 (: .