Setting variable level in Python without using GamsModifier

In my previous post I’ve run into the problem of not being able to change the initial values of decision variables through GamsModifier when instantiating a ModelInstance.
Namely, GamsModifier(x, UpdateAction.Primal, x_ini) has resulted in errors.

Now I’m back to this issue and planning to directly change the variable levels in ModelInstance sync_db.
Namely I’m writing the following code to replace the functionality of GamsModifier(x, UpdateAction.Primal, x_ini):

for x0 in da.out_db[‘x_ini’]:
mai.sync_db[‘x’].find_record(x0.keys).level = x0.value

where da is a GamsDataBase containing the values of the parameter x_ini.

Will the changes above be valid to set x.L to the desired values (in x_ini) for the mai.solve() command? Or a GamsModifier is strictly required to make variables modifiable in Python?

I’m planning to initialize the model multiple times inside a loop, otherwise loading from a gdx-file inside of the model text definition could be viable.

It is a bug that the Python API does not recognize your Primal modifier. This has been fixed and will be available in the next maintenance release.

-Michael