add_onnx_constr

gurobi_ml.onnx.onnx_model.add_onnx_constr(gp_model, onnx_model, input_vars, output_vars=None, **kwargs)

Formulate an ONNX MLP model into gp_model.

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

Parameters:
  • gp_model (Model) – Target Gurobi model where the predictor submodel is added.

  • onnx_model (onnx.ModelProto) – ONNX model, expected to represent a sequential MLP with Gemm nodes (or MatMul`+`Add sequences) and Relu activations.

  • input_vars (mvar_array_like) – Decision variables used as input for the model in gp_model.

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

Warning

Only networks composed of Gemm (or MatMul`+`Add) and Relu nodes are supported. Gemm nodes must use default alpha=1, beta=1. Attribute transB is supported.