reactorModel_v6.gms (5.87 KB)

I am currently struggling with the definition of initial conditions when using the Python API. As far as I understand, when running a model from GAMS IDE the level value is considered as the initial point of the search. Therefore, if I call the same solve statement twice without changing any of the level values, the initial point of the second call is the optimal solution of the previous one, and then the solution of both problems is exactly the same.

However, with the Python API it seems to be harder to access the level values of variables. My intention with the attached code was to manually define initial values for ALL variables in the model and then solve it multiple times. My rationale was that if the initial point was always the same, the solution would also be the same. However, there are some small changes in the objective function. For the present example, the results of 4 runs are:

Obj: 110.47759190140623,

Obj: 110.47759190141258

Obj: 110.47759190457893

Obj: 110.47759190358889

For this particular minimal example the change is almost negligible, but for my actual complete model it could be as much as 3 orders of magnitude.

Any help in how to change my code to be able to achieve exactly the same result while manually defining the initial conditions will be much appreciated. I am using Gams 31 and its Python Interface, with Python 3.8, but the same problem happens with different versions too.

PS: I apologize for this not-so-minimal MWE. I tried to reproduce this issue with smaller models but when a GamsModifier was used to define the Primal of all variables, the optimization results turned out to be consistently the same.

py_NMPC_Caller.gms (3.72 KB)