Blocks

Summary

pyomo.core.kernel.block.block() A generalized container for defining hierarchical models by adding modeling components as attributes.
pyomo.core.kernel.block.block_tuple(*args, …) A tuple-style container for objects with category type IBlock
pyomo.core.kernel.block.block_list(*args, **kwds) A list-style container for objects with category type IBlock
pyomo.core.kernel.block.block_dict(*args, **kwds) A dict-style container for objects with category type IBlock

Member Documentation

class pyomo.core.kernel.block.block[source]

Bases: pyomo.core.kernel.block.IBlock

A generalized container for defining hierarchical models by adding modeling components as attributes.

Examples

>>> import pyomo.kernel as pmo
>>> model = pmo.block()
>>> model.x = pmo.variable()
>>> model.c = pmo.constraint(model.x >= 1)
>>> model.o = pmo.objective(model.x)
child_ctypes()[source]

Returns the set of child object category types stored in this container.

children(ctype=<class 'pyomo.core.kernel.base._no_ctype'>)[source]

Iterate over the children of this block.

Parameters:ctype – Indicates the category of children to include. The default value indicates that all categories should be included.
Returns:iterator of child objects
load_solution(solution, allow_consistent_values_for_fixed_vars=False, comparison_tolerance_for_fixed_vars=1e-05)[source]

Load a solution.

Parameters:
  • solution – A pyomo.opt.Solution object with a symbol map. Optionally, the solution can be tagged with a default variable value (e.g., 0) that will be applied to those variables in the symbol map that do not have a value in the solution.
  • allow_consistent_values_for_fixed_vars – Indicates whether a solution can specify consistent values for variables that are fixed.
  • comparison_tolerance_for_fixed_vars – The tolerance used to define whether or not a value in the solution is consistent with the value of a fixed variable.
write(filename, format=None, _solver_capability=None, _called_by_solver=False, **kwds)[source]

Write the model to a file, with a given format.

Parameters:
  • filename (str) – The name of the file to write.
  • format – The file format to use. If this is not specified, the file format will be inferred from the filename suffix.
  • **kwds – Additional keyword options passed to the model writer.
Returns:

a SymbolMap

class pyomo.core.kernel.block.block_tuple(*args, **kwds)

Bases: pyomo.core.kernel.tuple_container.TupleContainer

A tuple-style container for objects with category type IBlock

class pyomo.core.kernel.block.block_list(*args, **kwds)

Bases: pyomo.core.kernel.list_container.ListContainer

A list-style container for objects with category type IBlock

class pyomo.core.kernel.block.block_dict(*args, **kwds)

Bases: pyomo.core.kernel.dict_container.DictContainer

A dict-style container for objects with category type IBlock