AddSlackVariables

(class from pyomo.core.plugins.transform.add_slack_vars)

class pyomo.core.plugins.transform.add_slack_vars.AddSlackVariables(**kwds)[source]

Bases: NonIsomorphicTransformation

This plugin adds slack variables to every constraint or to the constraints specified in targets.

__init__(**kwds)[source]

Methods

__init__(**kwds)

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_relaxed_constraint(transformed_block, ...)

Return the constraint that 'slack_var' is used to relax.

get_slack_variables(transformed_block, ...)

Return the list of slack variables used to relax 'constraint.' Note that if 'constraint' is one-sided, there will be a single variable in the list, but if it is a ranged constraint (l <= expr <= u) or an equality, there will be two variables.

get_summed_slacks_expr(transformed_block)

Return an expression summing all the slacks added to the model during the transformation.

Attributes

CONFIG

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_relaxed_constraint(transformed_block, slack_var)[source]

Return the constraint that ‘slack_var’ is used to relax.

Return type:

Constraint

Parameters:
  • transformed_block (ConcreteModel or Block) – The model or block that had the ‘core.add_slack_variables’ transformation applied to it

  • slack_var (Var) – A variable created by the ‘core.add_slack_variables’ transformation to relax a constraint.

get_slack_variables(transformed_block, constraint)[source]

Return the list of slack variables used to relax ‘constraint.’ Note that if ‘constraint’ is one-sided, there will be a single variable in the list, but if it is a ranged constraint (l <= expr <= u) or an equality, there will be two variables.

Return type:

List of slack variables

Parameters:
  • transformed_block (ConcreteModel or Block) – The model or block that had the ‘core.add_slack_variables’ transformation applied to it

  • constraint (Constraint) – A constraint that was relaxed by the transformation (either because no targets were specified or because it was a target)

get_summed_slacks_expr(transformed_block)[source]

Return an expression summing all the slacks added to the model during the transformation. This would most commonly be used to add a penalty on non-zero slacks to an existing objective.

Return type:

Expression

Parameters:

transformed_block (ConcreteModel or Block) – The model or block that had the ‘core.add_slack_variables’ transformation applied to it