SOS1 variables using Python Topic is solved

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
Ilya
User
User
Posts: 6
Joined: 2 months ago

SOS1 variables using Python

Post by Ilya » 2 months ago

I am writing a Benders decomposition model, and to avoid repeated model assembly inside the loop, I'm using Pythonic GamsModelInstances based on the GAMS model formulations (very similar to the example in SPBENDERS3.gms).

I also have some important SOS1 variables in the master problem. And when the GamsModelInstance of the master problem is attempted to be solved, I get the following error:

mai.solve(SymbolUpdateType.BaseCase)
File "gams\execution.py", line 577, in gams.execution.GamsModelInstance.solve (execution.c:11577)
File "gams\database.py", line 1248, in gams.database.GamsDatabase._check_for_gmd_error (database.c:29764)
gams.workspace.GamsException: readyapi failed


The above is obtained from a Python IDE, as I've also attempted to call GAMS from Python code, but when initially calling Python from GAMS (using EmbeddedCode), the error was exactly the same.
The error disappears when I redefine the SOS1 variables to be Binary. This, however, noticeably worsens the convergence, and the model style, as these variables are meant to be SOS1.

It is not clear for me what is going on and why SOS1 variables appear to be problematic with Python, but I'd like to use them.
The used solver is CPLEX on GAMS 25.1.1

User avatar
bussieck
Moderator
Moderator
Posts: 198
Joined: 2 years ago

Re: SOS1 variables using Python

Post by bussieck » 2 months ago

Are you sure that you use Cplex and not CplexD? CplexD does not understand SOS variables. See http://support.gams.com/solver:the_d_so ... gams_cplex. This is not a limitation of the underlying Cplex library but a limitation of the GAMS link to Cplex.

As long as you don't do multi-threaded use of model instances you should be okay with Cplex (which understands SOS variables).

-Michael

Ilya
User
User
Posts: 6
Joined: 2 months ago

Re: SOS1 variables using Python

Post by Ilya » 2 months ago

Yes, I have to say you are right!
I've never thought that the D letter in the solver name changes so much. Thank you.

Post Reply