matrix_constraint

(class from pyomo.core.kernel.matrix_constraint)

class pyomo.core.kernel.matrix_constraint.matrix_constraint(A, lb=None, ub=None, rhs=None, x=None, sparse=True)[source]

Bases: constraint_tuple

A container for constraints of the form lb <= Ax <= ub.

Parameters:
  • A – A scipy sparse matrix or 2D numpy array (always copied)

  • lb – A scalar or array with the same number of rows as A that defines the lower bound of the constraints

  • ub – A scalar or array with the same number of rows as A that defines the upper bound of the constraints

  • rhs – A scalar or array with the same number of rows as A that defines the right-hand side of the constraints (implies equality constraints)

  • x – A list with the same number of columns as A that stores the variable associated with each column

  • sparse – Indicates whether or not sparse storage (CSR format) should be used to store A. Default is True.

__init__(A, lb=None, ub=None, rhs=None, x=None, sparse=True)[source]

Methods

__init__(A[, lb, ub, rhs, x, sparse])

activate([shallow])

Activate this container.

child(key)

Get the child object associated with a given storage key for this container.

children()

A generator over the children of this container.

clone()

Returns a copy of this object with the parent pointer set to None.

components([active])

Generates an efficient traversal of all components stored under this container.

count(value)

deactivate([shallow])

Deactivate this container.

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

Dynamically generates a name for this object.

index(value, [start, [stop]])

Raises ValueError if the value is not present.

Attributes

A

A read-only view of the constraint matrix

active

The active status of this object.

ctype

The object's category type.

equality

The array of boolean entries indicating the indices that are equality constraints

lb

The array of constraint lower bounds

local_name

The object's local name within the context of its parent.

lslack

Lower slack (body - lb)

name

The object's fully qualified name.

parent

The object's parent (possibly None).

rhs

The array of constraint right-hand sides.

slack

min(lslack, uslack)

sparse

Boolean indicating whether or not the underlying matrix uses sparse storage

storage_key

The object's storage key within its parent

ub

The array of constraint upper bounds

uslack

Upper slack (ub - body)

x

The list of variables associated with the columns of the constraint matrix

Member Documentation

activate(shallow=True)

Activate this container.

child(key)

Get the child object associated with a given storage key for this container.

Raises:

KeyError – if the argument is not a storage key for any children of this container

children()

A generator over the children of this container.

clone()

Returns a copy of this object with the parent pointer set to None.

A clone is almost equivalent to deepcopy except that any categorized objects encountered that are not descendents of this object will reference the same object on the clone.

components(active=True)

Generates an efficient traversal of all components stored under this container. Components are categorized objects that are either (1) not containers, or (2) are heterogeneous containers.

Parameters:

active (True/None) – Controls whether or not to filter the iteration to include only the active part of the storage tree. The default is True. Setting this keyword to None causes the active status of objects to be ignored.

Returns:

iterator of components in the storage tree

count(value) integer -- return number of occurrences of value
deactivate(shallow=True)

Deactivate this container.

getname(fully_qualified=False, name_buffer={}, convert=<class 'str'>, relative_to=None)

Dynamically generates a name for this object.

Parameters:
  • fully_qualified (bool) – Generate a full name by iterating through all ancestor containers. Default is False.

  • convert (function) – A function that converts a storage key into a string representation. Default is the built-in function str.

  • relative_to (object) – When generating a fully qualified name, generate the name relative to this block.

Returns:

If a parent exists, this method returns a string representing the name of the object in the context of its parent; otherwise (if no parent exists), this method returns None.

index(value[, start[, stop]]) integer -- return first index of value.

Raises ValueError if the value is not present.

property A

A read-only view of the constraint matrix

property active

The active status of this object.

property ctype

The object’s category type.

property equality

The array of boolean entries indicating the indices that are equality constraints

property lb

The array of constraint lower bounds

property local_name

The object’s local name within the context of its parent. Alias for obj.getname(fully_qualified=False).

property lslack

Lower slack (body - lb)

property name

The object’s fully qualified name. Alias for obj.getname(fully_qualified=True).

property parent

The object’s parent (possibly None).

property rhs

The array of constraint right-hand sides. Can be set to a scalar or a numpy array of the same dimension. This property can only be read when the equality property is True on every index. Assigning to this property implicitly sets the equality property to True on every index.

property slack

min(lslack, uslack)

property sparse

Boolean indicating whether or not the underlying matrix uses sparse storage

property storage_key

The object’s storage key within its parent

property ub

The array of constraint upper bounds

property uslack

Upper slack (ub - body)

property x

The list of variables associated with the columns of the constraint matrix