PortData

(class from pyomo.network.port)

class pyomo.network.port.PortData(component=None)[source]

Bases: ComponentData

This class defines the data for a single Port

vars

A dictionary mapping added names to variables

Type:

dict

__init__(component=None)[source]

Methods

__init__([component])

add(var[, name, rule])

Add var to this Port, casting it to a Pyomo numeric if necessary

arcs([active])

A list of Arcs in which this Port is a member

clear_suffix_value(suffix_or_name[, expand])

Set the suffix value for this component data

cname(*args, **kwds)

DEPRECATED.

dests([active])

A list of Arcs in which this Port is a source

fix()

Fix all variables in the port at their current values.

free()

Unfix all variables in the port.

get_split_fraction(arc)

Returns a tuple (val, fix) for the split fraction of this arc that was set via set_split_fraction if it exists, and otherwise None.

get_suffix_value(suffix_or_name[, default])

Get the suffix value for this component data

getname([fully_qualified, name_buffer, ...])

Return a string with the component name and index

index()

Returns the index of this ComponentData instance relative to the parent component index set.

is_binary()

Return True if all variables in the Port are binary

is_component_type()

Return True if this class is a Pyomo component

is_continuous()

Return True if all variables in the Port are continuous

is_equality(name)

Return True if the rule for this port member is Port.Equality

is_expression_type([expression_system])

Return True if this numeric value is an expression

is_extensive(name)

Return True if the rule for this port member is Port.Extensive

is_fixed()

Return True if all vars/expressions in the Port are fixed

is_indexed()

Return true if this component is indexed

is_integer()

Return True if all variables in the Port are integer

is_logical_type()

Return True if this class is a Pyomo Boolean object.

is_named_expression_type()

Return True if this numeric value is a named expression

is_numeric_type()

Return True if this class is a Pyomo numeric object

is_parameter_type()

Return False unless this class is a parameter object

is_potentially_variable()

Return True as ports may (should!) contain variables

is_reference()

Return True if this object is a reference.

is_variable_type()

Return False unless this class is a variable object

iter_vars([expr_vars, fixed, names])

Iterate through every member of the port, going through the indices of indexed members.

model()

Return the model of the component that owns this data.

parent_block()

Return the parent of the component that owns this data.

parent_component()

Returns the component associated with this object.

polynomial_degree()

Returns the maximum polynomial degree of all port members

pprint([ostream, verbose, prefix])

Print component information

remove(name)

Remove this member from the port

rule_for(name)

Return the rule associated with the given port member

set_split_fraction(arc, val[, fix])

Set the split fraction value to be used for an arc during arc expansion when using Port.Extensive.

set_suffix_value(suffix_or_name, value[, expand])

Set the suffix value for this component data

set_value(value)

Cannot specify the value of a port

sources([active])

A list of Arcs in which this Port is a destination

type()

DEPRECATED.

unfix()

Unfix all variables in the port.

Attributes

vars

active

Return the active attribute

ctype

Return the class type for this component

local_name

Get the component name only within the context of the immediate parent container.

name

Get the fully qualified component name.

Member Documentation

add(var, name=None, rule=None, **kwds)[source]

Add var to this Port, casting it to a Pyomo numeric if necessary

Parameters:
  • var – A variable or some NumericValue like an expression

  • name (str) – Name to associate with this member of the Port

  • rule (function) – Function implementing the desired expansion procedure for this member. Port.Equality by default, other options include Port.Extensive. Customs are allowed.

  • kwds – Keyword arguments that will be passed to rule

arcs(active=None)[source]

A list of Arcs in which this Port is a member

clear_suffix_value(suffix_or_name, expand=True)

Set the suffix value for this component data

cname(*args, **kwds)

DEPRECATED.

Deprecated since version 5.0: The cname() method has been renamed to getname(). The preferred method of obtaining a component name is to use the .name property, which returns the fully qualified component name. The .local_name property will return the component name only within the context of the immediate parent container.

dests(active=None)[source]

A list of Arcs in which this Port is a source

fix()[source]

Fix all variables in the port at their current values. For expressions, fix every variable in the expression.

free()

Unfix all variables in the port. For expressions, unfix every variable in the expression.

get_split_fraction(arc)[source]

Returns a tuple (val, fix) for the split fraction of this arc that was set via set_split_fraction if it exists, and otherwise None.

get_suffix_value(suffix_or_name, default=None)

Get the suffix value for this component data

getname(fully_qualified=False, name_buffer=None, relative_to=None)

Return a string with the component name and index

index()

Returns the index of this ComponentData instance relative to the parent component index set. None is returned if this instance does not have a parent component, or if - for some unknown reason - this instance does not belong to the parent component’s index set.

is_binary()[source]

Return True if all variables in the Port are binary

is_component_type()

Return True if this class is a Pyomo component

is_continuous()[source]

Return True if all variables in the Port are continuous

is_equality(name)[source]

Return True if the rule for this port member is Port.Equality

is_expression_type(expression_system=None)

Return True if this numeric value is an expression

is_extensive(name)[source]

Return True if the rule for this port member is Port.Extensive

is_fixed()[source]

Return True if all vars/expressions in the Port are fixed

is_indexed()

Return true if this component is indexed

is_integer()[source]

Return True if all variables in the Port are integer

is_logical_type()

Return True if this class is a Pyomo Boolean object.

Boolean objects include constants, variables, or logical expressions.

is_named_expression_type()

Return True if this numeric value is a named expression

is_numeric_type()

Return True if this class is a Pyomo numeric object

is_parameter_type()

Return False unless this class is a parameter object

is_potentially_variable()[source]

Return True as ports may (should!) contain variables

is_reference()

Return True if this object is a reference.

is_variable_type()

Return False unless this class is a variable object

iter_vars(expr_vars=False, fixed=None, names=False)[source]

Iterate through every member of the port, going through the indices of indexed members.

Parameters:
  • expr_vars (bool) – If True, call identify_variables on expression type members

  • fixed (bool) – Only include variables/expressions with this type of fixed

  • names (bool) – If True, yield (name, index, var/expr) tuples

model()

Return the model of the component that owns this data.

parent_block()

Return the parent of the component that owns this data.

parent_component()

Returns the component associated with this object.

polynomial_degree()[source]

Returns the maximum polynomial degree of all port members

pprint(ostream=None, verbose=False, prefix='')

Print component information

Note that this method is generally only reachable through ComponentData objects in an IndexedComponent container. Components, including unindexed Component derivatives and both scalar and indexed IndexedComponent derivatives will see Component.pprint()

remove(name)[source]

Remove this member from the port

rule_for(name)[source]

Return the rule associated with the given port member

set_split_fraction(arc, val, fix=True)[source]

Set the split fraction value to be used for an arc during arc expansion when using Port.Extensive.

set_suffix_value(suffix_or_name, value, expand=True)

Set the suffix value for this component data

set_value(value)[source]

Cannot specify the value of a port

sources(active=None)[source]

A list of Arcs in which this Port is a destination

type()

DEPRECATED.

Return the class type for this component

Deprecated since version 5.7: Component.type() method has been replaced by the .ctype property.

unfix()[source]

Unfix all variables in the port. For expressions, unfix every variable in the expression.

property active

Return the active attribute

property ctype

Return the class type for this component

property local_name

Get the component name only within the context of the immediate parent container.

property name

Get the fully qualified component name.