Centroid Based Clustering Constraint

Module for formulating a sklearn.cluster.KMeans into a PySCIPOpt Model.

pyscipopt_ml.sklearn.add_centroid_cluster_constr(scip_model, centroid_clusteror, input_vars, output_vars=None, unique_naming_prefix='', formulation='l2', **kwargs)

Formulate centroid_clusteror in scip_model.

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

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

  • centroid_clusteror (sklearn.cluster.KMeans) – The centroid clusteror to insert as predictor.

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

  • output_vars (list or np.ndarray, optional) – Decision variables used as output for centroid clustering 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.

  • formulation (str, optional) – The formulation type used when embedding the centroid clustering predictor. Valid types are “l2” (standard norm, same as the predictor), and “l1” for a linearised version. Warning: The linearised version will incorrectly label some points.

Returns:

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

Return type:

CentroidClusterConstr

Note

See add_predictor_constr for acceptable values for input_vars and output_vars

class pyscipopt_ml.sklearn.centroid_cluster.CentroidClusterConstr(scip_model, predictor, input_vars, output_vars, unique_naming_prefix, formulation, **kwargs)
Class to model trained sklearn.cluster.KMeans

with SCIP

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