ConstraintData

(class from pyomo.core.base.constraint)

class pyomo.core.base.constraint.ConstraintData(expr=None, component=None)[source]

Bases: ActiveComponentData

This class defines the data for a single algebraic constraint.

Parameters:
  • expr (ExpressionBase) – The Pyomo expression stored in this constraint.

  • component (Constraint) – The Constraint object that owns this data.

__init__(expr=None, component=None)[source]

Methods

__init__([expr, component])

activate()

Set the active attribute to True

clear_suffix_value(suffix_or_name[, expand])

Set the suffix value for this component data

cname(*args, **kwds)

DEPRECATED.

deactivate()

Set the active attribute to False

get_suffix_value(suffix_or_name[, default])

Get the suffix value for this component data

get_value()

Get the expression on this constraint.

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

Return a string with the component name and index

has_lb()

Returns False when the lower bound is None or negative infinity

has_ub()

Returns False when the upper bound is None or positive infinity

index()

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

is_component_type()

Return True if this class is a Pyomo component

is_expression_type([expression_system])

Return True if this numeric value is an expression

is_indexed()

Return true if this component is indexed

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_reference()

Return True if this object is a reference.

is_variable_type()

Return False unless this class is a variable object

lslack()

Returns the value of f(x)-L for constraints of the form:

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.

pprint([ostream, verbose, prefix])

Print component information

set_suffix_value(suffix_or_name, value[, expand])

Set the suffix value for this component data

set_value(expr)

Set the expression on this constraint.

slack()

Returns the smaller of lslack and uslack values

to_bounded_expression([evaluate_bounds])

Convert this constraint to a tuple of 3 expressions (lb, body, ub)

type()

DEPRECATED.

uslack()

Returns the value of U-f(x) for constraints of the form:

Attributes

active

Return the active attribute

body

The body (variable portion) of a constraint expression.

ctype

Return the class type for this component

equality

True if this is an equality constraint.

expr

Return the expression associated with this constraint.

lb

the value of the lower bound of a constraint expression.

local_name

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

lower

The lower bound of a constraint expression.

name

Get the fully qualified component name.

strict_lower

True if this constraint has a strict lower bound.

strict_upper

True if this constraint has a strict upper bound.

ub

the value of the upper bound of a constraint expression.

upper

Access the upper bound of a constraint expression.

Member Documentation

activate()

Set the active attribute to True

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.

deactivate()

Set the active attribute to False

get_suffix_value(suffix_or_name, default=None)

Get the suffix value for this component data

get_value()[source]

Get the expression on this constraint.

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

Return a string with the component name and index

has_lb()[source]

Returns False when the lower bound is None or negative infinity

has_ub()[source]

Returns False when the upper bound is None or positive infinity

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_component_type()

Return True if this class is a Pyomo component

is_expression_type(expression_system=None)

Return True if this numeric value is an expression

is_indexed()

Return true if this component is indexed

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_reference()

Return True if this object is a reference.

is_variable_type()

Return False unless this class is a variable object

lslack()[source]
Returns the value of f(x)-L for constraints of the form:

L <= f(x) (<= U) (U >=) f(x) >= L

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.

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()

set_suffix_value(suffix_or_name, value, expand=True)

Set the suffix value for this component data

set_value(expr)[source]

Set the expression on this constraint.

slack()[source]

Returns the smaller of lslack and uslack values

to_bounded_expression(evaluate_bounds=False)[source]

Convert this constraint to a tuple of 3 expressions (lb, body, ub)

This method “standardizes” the expression into a 3-tuple of expressions: (lower_bound, body, upper_bound). Upon conversion, lower_bound and upper_bound are guaranteed to be None, numeric constants, or fixed (not necessarily constant) expressions.

Note

As this method operates on the current state of the expression, any required expression manipulations (and by extension, the result) can change after fixing / unfixing Var objects.

Parameters:

evaluate_bounds (bool) – If True, then the lower and upper bounds will be evaluated to a finite numeric constant or None.

Raises:

ValueError – Raised if the expression cannot be mapped to this: form (i.e., RangedExpression constraints with variable lower or upper bounds.

type()

DEPRECATED.

Return the class type for this component

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

uslack()[source]
Returns the value of U-f(x) for constraints of the form:

(L <=) f(x) <= U U >= f(x) (>= L)

property active

Return the active attribute

property body

The body (variable portion) of a constraint expression.

property ctype

Return the class type for this component

property equality

True if this is an equality constraint.

Type:

bool

property expr

Return the expression associated with this constraint.

property lb

the value of the lower bound of a constraint expression.

Type:

float

property local_name

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

property lower

The lower bound of a constraint expression.

This is the fixed lower bound of a Constraint as a Pyomo expression. This may contain potentially variable terms that are currently fixed. If there is no lower bound, this will return None.

property name

Get the fully qualified component name.

property strict_lower

True if this constraint has a strict lower bound.

Type:

bool

property strict_upper

True if this constraint has a strict upper bound.

Type:

bool

property ub

the value of the upper bound of a constraint expression.

Type:

float

property upper

Access the upper bound of a constraint expression.

This is the fixed upper bound of a Constraint as a Pyomo expression. This may contain potentially variable terms that are currently fixed. If there is no upper bound, this will return None.