BaseNNConstr¶
- class gurobi_ml.modeling.neuralnet.neural_net.BaseNNConstr(gp_model, predictor, input_vars, output_vars, **kwargs)¶
Bases:
AbstractPredictorConstrBase class for inserting a regressor based on a neural-network/tensor into Gurobi.
This only supports sequential neural networks.
The bracket operator can be used to iterate over the layers of the layers of the network. It will give access to the modeling object of the corresponding layer.
- Attributes:
constrsList of linear constraints added.
default_nameDefault base name base used for automatic name generation.
genconstrsList of general constraints added.
gp_modelAccess gurobipy model this is a part of.
inputInput variables of embedded predictor.
input_valuesValues for the input variables if a solution is known.
layersAccess models for successive layers of the network
outputOutput variables of embedded predictor.
output_valuesValues for the output variables if a solution is known.
qconstrsList of quadratic constraints added.
sosList of SOS constraints added.
varsList of variables added.
Methods
get_error(eps)Returns error in Gurobi's solution with respect to prediction from input.
print_stats([abbrev, file])Print statistics about submodel created.
remove()Remove from gp_model everything that was added to embed predictor.
- abstractmethod get_error(eps)¶
Returns error in Gurobi’s solution with respect to prediction from input.
- Returns:
error – Assuming that we have a solution for the input and output variables x, y. Returns the absolute value of the differences between predictor.predict(x) and y. Where predictor is the regression model represented by this object.
- Return type:
ndarray of same shape as
gurobi_ml.modeling.base_predictor_constr.AbstractPredictorConstr.output- Raises:
NoSolution – If the Gurobi model has no solution (either was not optimized or is infeasible).
- print_stats(abbrev=False, file=None)¶
Print statistics about submodel created.
- Parameters:
file (None, optional) – Text stream to which output should be redirected. By default sys.stdout.
- remove()¶
Remove from gp_model everything that was added to embed predictor.
- property constrs¶
List of linear constraints added.
- property default_name¶
Default base name base used for automatic name generation.
- property genconstrs¶
List of general constraints added.
- property gp_model¶
Access gurobipy model this is a part of.
- property input_values¶
Values for the input variables if a solution is known.
- Returns:
output_value
- Return type:
ndarray or pandas dataframe with values
- Raises:
NoSolution – If the Gurobi model has no solution (either was not optimized or is infeasible).
- property layers¶
Access models for successive layers of the network
- property output_values¶
Values for the output variables if a solution is known.
- Returns:
output_value
- Return type:
ndarray or pandas dataframe with values
- Raises:
NoSolution – If the Gurobi model has no solution (either was not optimized or is infeasible).
- property qconstrs¶
List of quadratic constraints added.
- property sos¶
List of SOS constraints added.
- property vars¶
List of variables added.