add_sequential_constr#

gurobi_ml.torch.sequential.add_sequential_constr(gp_model, sequential_model, input_vars, output_vars=None, **kwargs)#

Formulate sequential_model into gp_model.

The formulation predicts the values of output_vars using input_vars according to sequential_model. See our Users Guide for details on the mip formulation used.

Parameters:
  • gp_model (gurobipy model) – The gurobipy model where the sequential model should be inserted.

  • sequential_model (torch.nn.Sequential) – The sequential model to insert as predictor.

  • input_vars (mvar_array_like) – Decision variables used as input for logistic regression in model.

  • output_vars (mvar_array_like, optional) – Decision variables used as output for logistic regression in model.

Returns:

Object containing information about what was added to model to insert the predictor in it

Return type:

SequentialConstr

Raises:

NoModel – If the translation for some of the Pytorch model structure (layer or activation) is not implemented.

Warning

Only torch.nn.Linear layers and torch.nn.ReLU layers are supported.

Notes

See add_predictor_constr for acceptable values for input_vars and output_vars