Neural Network Formulations

Base Formulation

class omlt.formulation._PyomoFormulation[source]

Bases: _PyomoFormulationInterface

Pyomo Formulation.

This is a base class for different Pyomo formulations. To create a new formulation, inherit from this class and implement the abstract methods and properties.

property block

Block.

The underlying block containing the constraints / variables for this formulation.

abstract property input_indexes

Input indexes.

Return the indices corresponding to the inputs of the ML model. This is a list of entries (which may be tuples for higher dimensional inputs).

abstract property output_indexes

Output indexes.

Return the indices corresponding to the outputs of the ML model. This is a list of entries (which may be tuples for higher dimensional outputs).

Provided Formulations

class omlt.neuralnet.nn_formulation.FullSpaceNNFormulation(network_structure, layer_constraints=None, activation_constraints=None)[source]

Bases: _PyomoFormulation

This class is the entry-point to build neural network formulations.

This class iterates over all nodes in the neural network and for each one them, generates the constraints to represent the layer and its activation function.

Parameters:
  • network_structure (NetworkDefinition) – the neural network definition

  • layer_constraints (dict-like or None) – overrides the constraints generated for the specified layer types

  • activation_constraints (dict-like or None) – overrides the constraints generated for the specified activation functions

property block

Block.

The underlying block containing the constraints / variables for this formulation.

property input_indexes

The indexes of the formulation inputs.

property output_indexes

The indexes of the formulation output.

class omlt.neuralnet.nn_formulation.ReducedSpaceNNFormulation(network_structure, activation_functions=None)[source]

Bases: _PyomoFormulation

Reduced Space Neural Network Formulation.

This class is used to build reduced-space formulations of neural networks.

Parameters:
  • network_structure (NetworkDefinition) – the neural network definition

  • activation_functions (dict-like or None) – overrides the actual functions used for particular activations

property block

Block.

The underlying block containing the constraints / variables for this formulation.

property input_indexes

The indexes of the formulation inputs.

property output_indexes

The indexes of the formulation output.

class omlt.neuralnet.nn_formulation.FullSpaceSmoothNNFormulation(network_structure)[source]

Bases: FullSpaceNNFormulation

property block

Block.

The underlying block containing the constraints / variables for this formulation.

property input_indexes

The indexes of the formulation inputs.

property output_indexes

The indexes of the formulation output.

class omlt.neuralnet.nn_formulation.ReducedSpaceSmoothNNFormulation(network_structure)[source]

Bases: ReducedSpaceNNFormulation

Reduced Space Smooth Neural Network Formulation.

This class is used to build reduced-space formulations of neural networks with smooth activation functions.

Parameters:

network_structure (NetworkDefinition) – the neural network definition

property block

Block.

The underlying block containing the constraints / variables for this formulation.

property input_indexes

The indexes of the formulation inputs.

property output_indexes

The indexes of the formulation output.

class omlt.neuralnet.nn_formulation.ReluBigMFormulation(network_structure)[source]

Bases: FullSpaceNNFormulation

property block

Block.

The underlying block containing the constraints / variables for this formulation.

property input_indexes

The indexes of the formulation inputs.

property output_indexes

The indexes of the formulation output.

class omlt.neuralnet.nn_formulation.ReluComplementarityFormulation(network_structure)[source]

Bases: FullSpaceNNFormulation

property block

Block.

The underlying block containing the constraints / variables for this formulation.

property input_indexes

The indexes of the formulation inputs.

property output_indexes

The indexes of the formulation output.

class omlt.neuralnet.nn_formulation.ReluPartitionFormulation(network_structure, split_func=None)[source]

Bases: _PyomoFormulation

ReLU Partition Formulation.

This class is used to build partition-based formulations of neural networks.

Parameters:
  • network_structure (NetworkDefinition) – the neural network definition

  • split_func (callable) – the function used to compute the splits

property block

Block.

The underlying block containing the constraints / variables for this formulation.

property input_indexes

The indexes of the formulation inputs.

property output_indexes

The indexes of the formulation output.