error 796 in python api Topic is solved

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
silence
User
User
Posts: 19
Joined: 4 years ago

error 796 in python api

Post by silence »

Hello everybody,

I want to instantiate a MIP model with modifiers in the objective function. Follow the example transport7.py to GamsModifier a parameter im my model ,but encountered an error 796. The code and error list are uploaded. When directly called the code, it ran normally. I don't know where is the problem
list.txt
(2.03 KiB) Downloaded 296 times
code.txt
(7.6 KiB) Downloaded 290 times
Furthermore, if you can proviede detailed examples of how to modify a few multidimensional parameters with a GamsModifier? I have a look at the transport7.py, but still not understand.


Thanks
Silvia
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: error 796 in python api

Post by bussieck »

You need to understand how model instances and updaters work. Read the GUSS manual (https://www.gams.com/latest/docs/S_GUSS.html) that is based on the same techniques. You update Par_g. Par_g never shows up up the model generated by GAMS, it is only used in some loop statements to calculate other parameters (Qtable) which is then used in the model algebra. That's not how it works. Moreover, why in the world do you want to use model instances? GAMS takes no time to execute and generate the model and the mip you solve takes a long time. There is absolutely do advantage (for you) using model instances compared to just running the entire GAMS job with varying Par_g multiple times. You can pass different values for Par_g via a double dash parameter (see opt.defines["incname"] = "tdata" in trnsport2.py) and you can create a GAMSDatabase with indexed parameters and read them via $gdxIn/$load in your model (again trnsport2.py). GAMSModelInstance is useful when the ratio of solving and generating is very small and you need to do thousands of such solves.

Hope this helps,
Michael
Post Reply