Scaling

The omlt.scaling module describes the interface for providing different scaling expressions to the Pyomo model for the inputs and outputs of an ML model. An implementation of a common scaling approach is included with OffsetScaling.

class omlt.scaling.ScalingInterface[source]

Bases: ABC

abstract get_scaled_input_expressions(input_vars)[source]

This method returns a list of expressions for the scaled inputs from the unscaled inputs

abstract get_unscaled_output_expressions(scaled_output_vars)[source]

This method returns a list of expressions for the unscaled outputs from the scaled outputs

class omlt.scaling.OffsetScaling(offset_inputs, factor_inputs, offset_outputs, factor_outputs)[source]

Bases: ScalingInterface

This scaling object represents the following scaling equations for inputs (x) and outputs (y)

\[\begin{split}\begin{align*} x_i^{scaled} = \frac{(x_i-x_i^{offset})}{x_i^{factor}} \\ y_i^{scaled} = \frac{(y_i-y_i^{offset})}{y_i^{factor}} \end{align*}\end{split}\]
Parameters:
  • offset_inputs (array-like) – Array of the values of the offsets for each input to the network

  • factor_inputs (array-like) – Array of the scaling factors (division) for each input to the network

  • offset_outputs (array-like) – Array of the values of the offsets for each output from the network

  • factor_outputs (array-like) – Array of the scaling factors (division) for each output from the network

get_scaled_input_expressions(input_vars)[source]

Get the scaled input expressions of the input variables.

get_scaled_output_expressions(output_vars)[source]

Get the scaled output expressions of the output variables.

get_unscaled_input_expressions(scaled_input_vars)[source]

Get the unscaled input expressions of the scaled input variables.

get_unscaled_output_expressions(scaled_output_vars)[source]

Get the unscaled output expressions of the scaled output variables.