Mathematical optimization is a declarative approach where you describe the properties of a solution to your problem. As such, it's not possible to incorporate black-box functions, such as user-defined functions or those available in popular packages like NumPy or scikit-learn, into optimization models. Instead, you need to explicitly describe the mathematical expressions used to compute the desired output by employing decision variables and constraints.

Nevertheless, Gurobi's programming interfaces allow you to incorporate general constraints into your model. General constraints are used to represent relationships between decision variables that are frequently used by math modelers, such as:

- Absolute value
- Piecewise-linear (PWL) functions
- Univariate non-linear functions, modeled via PWL approximation
- Exponential and logarithmic functions
- Power functions
- Logistic functions
- Trigonometric functions: \(\sin\), \(\cos\), and \(\tan\)

- \(\max\) and \(\min\)
- Polynomial functions
- \(L^0\), \(L^1\), \(L^2\), and \(L^\infty\) norm constraints
- Predicate logic

These could be considered as convenience features, as the modeler could model these relationships using linear/quadratic constraints and integer variables. However, Gurobi can sometimes exploit information contained in the rest of the model constraints to build a more efficient formulation than what a user might create. Moreover, using Gurobi’s general constraints typically result in simpler code that is easier to read and maintain.

Finally, it's worth mentioning the Github package Gurobi Machine Learning, an open-source Python project sponsored by Gurobi that allows users to embed directly into Gurobi a trained machine learning model that estimates a real-world system, allowing users to optimize controls on that system.

## Comments

0 comments

Article is closed for comments.