Dear GAMS community,

I am encountering some difficulties trying to run an MCP model through GAMSModelInstance.

In the model, among other things, I have two equations of the type:

EQ1… X =E= x0 + flag*X_SLACK

EQ2… Y =E= y0 + (1-flag)*Y_SLACK

where flag is a parameter that take 0 or 1 values, and x0 and y0 are parameters with some default values for the X and Y variables.

As you can see, the two equations are related. When flag is 0, X is basically fixed to X_SLACK, while Y will have a Y_SLACK associated variable. When flag is 1, the opposite applies.

In GAMS, this model works well, with and without holdFixed set to 1.

However, through Python, I will get an error of ncols not equal to nrows. I get this error at the instantiate() stage after adding “flag” as a Modifier.

I presume this may come from a default initialisation of “flag” to some value that will allow both X_SLACK and Y_SLACK to be activated in the model and thus determining the model to be non-square.

Interestingly, if I were to turn flag into a fixed variable, the model would be non-square even in GAMS. I attempted this thinking that as a fixed variable I could attribute a value to it in Python by adding a data_symbol element in the Modifier definition.

Would you have any suggestions on how to get around this?

Many thanks.