本文档是GAMS Python API 24.0版本的官方指南,详尽介绍了如何通过Python接口使用GAMS进行优化建模和数据分析。
The `gams` namespace provides objects for interacting with the General Algebraic Modeling System (GAMS). These objects facilitate convenient exchange of input data and model results through `GamsDatabase`, assist in creating and running GAMS models via `GamsJob`, which can be customized using GAMS options (`GamsOptions`). Additionally, they offer a method to efficiently solve a series of closely related model instances with `GamsModelInstance`.
A GAMS program may incorporate other source files (e.g., `$include`), import data from GDX files (e.g., `$GDXIN` or `execute_load`), and generate PUT files. Each file can be specified using a relative path, necessitating an anchor to the filesystem. The base class `GamsWorkspace` manages this anchor.
If external file communication is not necessary for a specific Python application, temporary directories and files will be handled by objects within the namespace. With the exception of `GamsWorkspace`, objects in the `gams` namespace cannot be accessed across different threads unless they are locked. The classes themselves are thread-safe, allowing multiple instances to operate from different threads (with some restrictions on solvers that may not be thread-safe within the `GamsModelInstance` class).