MLP Constraint

Module for formulating a sklearn.neural_network.MLPRegressor or sklearn.neural_network.MLPClassifier in a PySCIPOpt Model.

pyscipopt_ml.sklearn.add_mlp_regressor_constr(scip_model, mlp_regressor, input_vars, output_vars=None, unique_naming_prefix='', **kwargs)

Formulate mlp_regressor into scip_model.

The formulation predicts the values of output_vars using input_vars according to mlp_regressor.

Parameters:
  • scip_model (PySCIPOpt Model) – The SCIP model where the predictor should be inserted.

  • mlp_regressor (sklearn.neural_network.MLPRegressor) – The multi-layer perceptron regressor to insert as predictor.

  • input_vars (np.ndarray or list) – Decision variables used as input for regression in model.

  • output_vars (np.ndarray or list, optional) – Decision variables used as output for regression in model.

  • unique_naming_prefix (str, optional) – A unique naming prefix that is used before all variable and constraint names. This parameter is important if the SCIP model is later printed to file and many predictors are added to the same SCIP model.

Returns:

Object containing information about what was added to scip_model to formulate mlp_regressor.

Return type:

MLPRegressorConstr

Raises:

NoModel – If the translation to SCIP of the activation function for the network is not implemented.

Note

See add_predictor_constr for acceptable values for input_vars and output_vars

pyscipopt_ml.sklearn.add_mlp_classifier_constr(scip_model, mlp_classifier, input_vars, output_vars=None, unique_naming_prefix='', **kwargs)

Formulate mlp_classifier into scip_model.

The formulation predicts the values of output_vars using input_vars according to mlp_classifier.

Parameters:
  • scip_model (PySCIPOpt Model) – The SCIP model where the predictor should be inserted.

  • mlp_classifier (sklearn.neural_network.MLPClassifier) – The multi-layer perceptron classifier to insert as predictor.

  • input_vars (np.ndarray or list) – Decision variables used as input for regression in model.

  • output_vars (np.ndarray or list, optional) – Decision variables used as output for regression in model.

  • unique_naming_prefix (str, optional) – A unique naming prefix that is used before all variable and constraint names. This parameter is important if the SCIP model is later printed to file and many predictors are added to the same SCIP model.

Returns:

Object containing information about what was added to scip_model to formulate mlp_classifier.

Return type:

MLPConstr

Raises:

NoModel – If the translation to SCIP of the activation function for the network is not implemented.

Note

See add_predictor_constr for acceptable values for input_vars and output_vars

class pyscipopt_ml.sklearn.mlp.MLPConstr(scip_model, predictor, input_vars, output_vars=None, unique_naming_prefix='', classification=False, **kwargs)

Class to model trained sklearn.neural_network.MLPRegressor or sklearn.neural_network.MLPClassifier with PySCIPOpt.

Stores the changes to the SCIP Model for representing an instance into it. Inherits from AbstractPredictorConstr.