BigM_Transformation
(class from pyomo.gdp.plugins.bigm
)
- class pyomo.gdp.plugins.bigm.BigM_Transformation[source]
Bases:
GDP_to_MIP_Transformation
,_BigM_MixIn
Relax disjunctive model using big-M terms.
Relaxes a disjunctive model into an algebraic model by adding Big-M terms to all disjunctive constraints.
- This transformation accepts the following keyword arguments:
bigM: A user-specified value (or dict) of M values to use (see below) targets: the targets to transform [default: the instance]
- M values are determined as follows:
if the constraint appears in the bigM argument dict
if the constraint parent_component appears in the bigM argument dict
if any block which is an ancestor to the constraint appears in the bigM argument dict
if ‘None’ is in the bigM argument dict
if the constraint or the constraint parent_component appear in a BigM Suffix attached to any parent_block() beginning with the constraint’s parent_block and moving up to the root model.
if None appears in a BigM Suffix attached to any parent_block() between the constraint and the root model.
if the constraint is linear, estimate M using the variable bounds
M values may be a single value or a 2-tuple specifying the M for the lower bound and the upper bound of the constraint body.
Specifying “bigM=N” is automatically mapped to “bigM={None: N}”.
The transformation will create a new Block with a unique name beginning “_pyomo_gdp_bigm_reformulation”. That Block will contain an indexed Block named “relaxedDisjuncts”, which will hold the relaxed disjuncts. This block is indexed by an integer indicating the order in which the disjuncts were relaxed. All transformed Disjuncts will have a pointer to the block their transformed constraints are on, and all transformed Disjunctions will have a pointer to the corresponding ‘Or’ or ‘ExactlyOne’ constraint.
Methods
__init__
()Initialize transformation object.
apply
(model, **kwds)DEPRECATED.
apply_to
(model, **kwds)Apply the transformation to the given model.
create_using
(model, **kwds)Create a new model with this transformation
get_M_value
(constraint)Returns the M values used to transform constraint.
get_M_value_src
(constraint)Return a tuple indicating how the M value used to transform constraint was specified.
Returns a dictionary mapping each constraint to a tuple: (lower_M_value, upper_M_value), where either can be None if the constraint does not have a lower or upper bound (respectively).
get_largest_M_value
(model)Returns the largest M value for any constraint on the model.
get_m_value_src
(constraint)DEPRECATED.
Return the original Constraint whose transformed counterpart is transformedConstraint
Return the Disjunct object whose transformed components are on transBlock.
Return the Disjunction corresponding to xor_constraint
Return the transformed version of srcConstraint
Attributes
CONFIG
transformation_name
Member Documentation
- apply(model, **kwds)
DEPRECATED.
Deprecated since version 4.3.11323: Transformation.apply() has been deprecated. Please use either Transformation.apply_to() for in-place transformations or Transformation.create_using() for transformations that create a new, independent transformed model instance.
- apply_to(model, **kwds)
Apply the transformation to the given model.
- create_using(model, **kwds)
Create a new model with this transformation
- get_M_value(constraint)[source]
Returns the M values used to transform constraint. Return is a tuple: (lower_M_value, upper_M_value). Either can be None if constraint does not have a lower or upper bound, respectively.
- Parameters:
constraint (Constraint, which must be in the subtree of a transformed) – Disjunct
- get_M_value_src(constraint)[source]
Return a tuple indicating how the M value used to transform constraint was specified. (In particular, this can be used to verify which BigM Suffixes were actually necessary to the transformation.)
- Return is of the form: ((lower_M_val, lower_M_source, lower_M_key),
(upper_M_val, upper_M_source, upper_M_key))
If the constraint does not have a lower bound (or an upper bound), the first (second) element will be (None, None, None). Note that if a constraint is of the form a <= expr <= b or is an equality constraint, it is not necessarily true that the source of lower_M and upper_M are the same.
If the M value came from an arg, source is the dictionary itself and key is the key in that dictionary which gave us the M value.
If the M value came from a Suffix, source is the BigM suffix used and key is the key in that Suffix.
If the transformation calculated the value, both source and key are None.
- Parameters:
constraint (Constraint, which must be in the subtree of a transformed) – Disjunct
- get_all_M_values_by_constraint(model)[source]
Returns a dictionary mapping each constraint to a tuple: (lower_M_value, upper_M_value), where either can be None if the constraint does not have a lower or upper bound (respectively).
- Parameters:
model (A GDP model that has been transformed with BigM)
- get_largest_M_value(model)[source]
Returns the largest M value for any constraint on the model.
- Parameters:
model (A GDP model that has been transformed with BigM)
- get_m_value_src(constraint)[source]
DEPRECATED.
Deprecated since version 5.7.1: The get_m_value_src function is deprecated. Use the get_M_value_src function if you need source information or the get_M_value function if you only need values.
- get_src_constraint()
Return the original Constraint whose transformed counterpart is transformedConstraint
- Parameters:
transformedConstraint (Constraint, which must be a component on one of)
of (the BlockDatas in the relaxedDisjuncts Block)
block (a transformation)
- get_src_disjunct()
Return the Disjunct object whose transformed components are on transBlock.
- Parameters:
transBlock (BlockData which is in the relaxedDisjuncts IndexedBlock) – on a transformation block.
- get_src_disjunction()
Return the Disjunction corresponding to xor_constraint
- Parameters:
xor_constraint (Constraint, which must be the logical constraint) – (located on the transformation block) of some Disjunction
- get_transformed_constraints()
Return the transformed version of srcConstraint
- Parameters:
srcConstraint (ScalarConstraint or ConstraintData, which must be in)
Disjunct (the subtree of a transformed)