NLWriter

(class from pyomo.repn.plugins.nl_writer)

class pyomo.repn.plugins.nl_writer.NLWriter[source]

Bases: object

__init__()[source]

Methods

__init__()

write(model, ostream[, rowstream, colstream])

Write a model in NL format.

Attributes

CONFIG

Member Documentation

write(model, ostream, rowstream=None, colstream=None, **options) NLWriterInfo[source]

Write a model in NL format.

Return type:

NLWriterInfo

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

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

  • rowstream (io.TextIOBase) – A text output stream to write the ASL “row file” (list of constraint / objective names). Ignored unless symbolic_solver_labels is True.

  • colstream (io.TextIOBase) – A text output stream to write the ASL “col file” (list of variable names). Ignored unless symbolic_solver_labels is True.

Keyword Arguments:
  • show_section_timing (bool, default=False) – Print timing after writing each section of the NL file

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

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

    How much effort do we want to put into ensuring the NL 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)

  • symbolic_solver_labels (bool, default=False) – Write the corresponding .row and .col files

  • scale_model (bool, default=True) – If True, then the writer will output the model constraints and variables in ‘scaled space’ using the scaling from the ‘scaling_factor’ Suffix, if provided.

  • export_nonlinear_variables (list, optional) – List of variables to ensure are in the NL file (even if they don’t appear in any constraints).

  • row_order (optional) – List of constraints in the order that they should appear in the NL file. Note that this is only a suggestion, as the NL writer will move all nonlinear constraints before linear ones (preserving row_order within each group).

  • column_order (optional) – List of variables in the order that they should appear in the NL file. Note that this is only a suggestion, as the NL writer will move all nonlinear variables before linear ones, and within nonlinear variables, variables appearing in both objectives and constraints before variables appearing only in constraints, which appear before variables appearing only in objectives. Within each group, continuous variables appear before discrete variables. In all cases, column_order is preserved within each group.

  • export_defined_variables (bool, default=True) – If True, export Expression objects to the NL file as ‘defined variables’.

  • linear_presolve (bool, default=True) – If True, we will perform a basic linear presolve by performing variable elimination (without fill-in).