GAMSWriter

(class from pyomo.repn.plugins.gams_writer_v2)

class pyomo.repn.plugins.gams_writer_v2.GAMSWriter[source]

Bases: object

Class configuration

This class leverages the Pyomo Configuration System for managing configuration options. See the discussion on configuring class hierarchies for more information on how configuration class attributes, instance attributes, and method keyword arguments interact.

CONFIG:
  • warmstart (bool, default=True) – Warmstart by initializing model’s variables to their values.

  • symbolic_solver_labels (bool, default=False) – Export variables and constraints to the gms file using human-readable text names derived from the corresponding Pyomo component names.

  • labeler (optional) – Callable to use to generate symbol names in gms file

  • solver (str, optional) – If None, GAMS will use default solver for model type.

  • mtype (str, optional) – If None, will chose from lp, mip. nlp and minlp will be implemented in a future release.

  • gams_commands (ListOf[str], default=[]) – List of additional GAMS commands to write directly into the GAMS model file before the solve statement. Specifically for solvers.

  • skip_trivial_constraints (bool, default=False) – Skip writing constraints whose body is constant

  • output_fixed_variables (bool, default=False) – If True, output fixed variables as variables; otherwise, output numeric value

  • file_determinism (InEnum[FileDeterminism], default=<FileDeterminism.ORDERED: 10>) –

    How much effort do we want to put into ensuring the GAMS file is written deterministically for a Pyomo model:

    • NONE (0) : None

    • ORDERED (10): rely on underlying component ordering (default)

    • SORT_INDICES (20) : sort keys of indexed components

    • SORT_SYMBOLS (30) : sort keys AND sort names (not declaration order)

  • put_results (str, default='results') – Filename for optionally writing solution values and marginals. If put_results_format is ‘gdx’, then GAMS will write solution values and marginals to GAMS_MODEL_p.gdx and solver statuses to {put_results}_s.gdx. If put_results_format is ‘dat’, then solution values and marginals are written to (put_results).dat, and solver statuses to (put_results + ‘stat’).dat.

  • put_results_format (In['gdx', 'dat'], optional) – Format used for put_results, one of ‘gdx’, ‘dat’. If not set, the format will default to ‘gdx’ if the gdx/gdxcc python module is available and ‘dat’ otherwise.

  • row_order (optional) – To use with ordered_active_constraints function.

__init__()[source]

Methods

__init__()

write(model, ostream, **options)

Write a model in GMS format.

Attributes

CONFIG

config

Instance configuration; see CONFIG.

Member Documentation

write(model, ostream, **options) GAMSWriterInfo[source]

Write a model in GMS format.

Return type:

GAMSWriterInfo

Parameters:
  • model (ConcreteModel) – The concrete Pyomo model to write out.

  • ostream (io.TextIOBase) – The text output stream where the GMS “file” will be written. Could be an opened file or a io.StringIO.

Keyword Arguments:
  • warmstart (bool, default=True) – Warmstart by initializing model’s variables to their values.

  • symbolic_solver_labels (bool, default=False) – Export variables and constraints to the gms file using human-readable text names derived from the corresponding Pyomo component names.

  • labeler (optional) – Callable to use to generate symbol names in gms file

  • solver (str, optional) – If None, GAMS will use default solver for model type.

  • mtype (str, optional) – If None, will chose from lp, mip. nlp and minlp will be implemented in a future release.

  • gams_commands (ListOf[str], default=[]) – List of additional GAMS commands to write directly into the GAMS model file before the solve statement. Specifically for solvers.

  • skip_trivial_constraints (bool, default=False) – Skip writing constraints whose body is constant

  • output_fixed_variables (bool, default=False) – If True, output fixed variables as variables; otherwise, output numeric value

  • file_determinism (InEnum[FileDeterminism], default=<FileDeterminism.ORDERED: 10>) –

    How much effort do we want to put into ensuring the GAMS file is written deterministically for a Pyomo model:

    • NONE (0) : None

    • ORDERED (10): rely on underlying component ordering (default)

    • SORT_INDICES (20) : sort keys of indexed components

    • SORT_SYMBOLS (30) : sort keys AND sort names (not declaration order)

  • put_results (str, default='results') – Filename for optionally writing solution values and marginals. If put_results_format is ‘gdx’, then GAMS will write solution values and marginals to GAMS_MODEL_p.gdx and solver statuses to {put_results}_s.gdx. If put_results_format is ‘dat’, then solution values and marginals are written to (put_results).dat, and solver statuses to (put_results + ‘stat’).dat.

  • put_results_format (In['gdx', 'dat'], optional) – Format used for put_results, one of ‘gdx’, ‘dat’. If not set, the format will default to ‘gdx’ if the gdx/gdxcc python module is available and ‘dat’ otherwise.

  • row_order (optional) – To use with ordered_active_constraints function.

config

Instance configuration; see CONFIG.