AutoScaler Class#

Tools for automatically scaling models based on current state.

Author: Andrew Lee

class idaes.core.scaling.autoscaling.AutoScaler(**kwargs)[source]#

IDAES Autoscaling Toolbox

Contains a number of methods useful for automatically scaling models based on the current model state (i.e., variable values). Users should be aware of the limitations of autoscaling however, which only consider the current variable values and are thus heavily dependent on model initialization.

zero_tolerance

Value at which a variable will be considered equal to zero for scaling.

max_variable_scaling_factor

Maximum value for variable scaling factors.

min_variable_scaling_factor

Minimum value for variable scaling factors.

max_constraint_scaling_factor

Maximum value for constraint scaling factors.

min_constraint_scaling_factor

Minimum value for constraint scaling factors.

overwrite

Whether to overwrite existing scaling factors.

scale_constraints_by_jacobian_norm(blk_or_cons, norm=2, descend_into=True)[source]#

Calculate scaling factors for all constraints in a model based on the norm of the Jacobian matrix, accounting for any variable scaling factors.

Parameters:
  • blk_or_cons – block or constraint to calculate scaling factors for

  • norm (int) – type of norm to use for scaling. Must be a positive integer.

  • descend_into (bool) – if blk_or_cons is a Block, whether to descend into any sub-Blocks (default=True)

Returns:

None

Raises:
  • TypeError is blk_or_cons is not a Block or Constraint

  • ValueError if norm is not a positive integer

scale_model(model, norm=2, descend_into=True)[source]#

Apply auto-scaling routine to model.

Parameters:
  • model – model to be scaled

  • norm (int) – type of norm to use for scaling. Must be a positive integer.

  • descend_into (bool) – if sub-Blocks are present, whether to descend into any sub-Blocks

Returns:

None

scale_variables_by_magnitude(blk_or_var, descend_into=True)[source]#

Calculate scaling factors for all variables in a model based on their current magnitude. Variables with no value are assigned a scaling factor of 1.

Parameters:
  • blk_or_var – block or variable object to calculate scaling factors for

  • descend_into (bool) – if blk_or_var is a Block, whether to descend into any sub-Blocks (default=True)

Returns:

None

Raises:

TypeError is blk_or_var is not a Block or Var.