!!! note As of now, this package only works for optimization models that can be written either in convex conic form or convex quadratic form.
For QuadraticProgram
backend, the package supports following Function-in-Set
constraints:
MOI Function | MOI Set |
---|---|
VariableIndex |
GreaterThan |
VariableIndex |
LessThan |
VariableIndex |
EqualTo |
ScalarAffineFunction |
GreaterThan |
ScalarAffineFunction |
LessThan |
ScalarAffineFunction |
EqualTo |
and the following objective types:
MOI Function |
---|
VariableIndex |
ScalarAffineFunction |
ScalarQuadraticFunction |
For the ConicProgram
backend, the package supports following Function-in-Set
constraints:
MOI Function | MOI Set |
---|---|
VectorOfVariables |
Nonnegatives |
VectorOfVariables |
Nonpositives |
VectorOfVariables |
Zeros |
VectorOfVariables |
SecondOrderCone |
VectorOfVariables |
PositiveSemidefiniteConeTriangle |
VectorAffineFunction |
Nonnegatives |
VectorAffineFunction |
Nonpositives |
VectorAffineFunction |
Zeros |
VectorAffineFunction |
SecondOrderCone |
VectorAffineFunction |
PositiveSemidefiniteConeTriangle |
and the following objective types:
MOI Function |
---|
VariableIndex |
ScalarAffineFunction |
Other conic sets such as RotatedSecondOrderCone
and PositiveSemidefiniteConeSquare
are supported through bridges.
You can create a differentiable optimizer over an existing MOI solver by using the diff_optimizer
utility.
diff_optimizer
DiffOpt requires taking projections and finding projection gradients of vectors while computing the jacobians. For this purpose, we use MathOptSetDistances.jl, which is a dedicated package for computing set distances, projections and projection gradients.
!!! note
As of now, the package is using SCS
geometric form for affine expressions in cones.
Consider a convex conic optimization problem in its primal (P) and dual (D) forms:
where
x \in R^n
is the primal variable,y \in R^m
is the dual variable, ands \in R^m
is the primal slack variable\mathcal{K} \subseteq R^m
is a closed convex cone and\mathcal{K}^* \subseteq R^m
is the corresponding dual cone variableA \in R^{m \times n}
,b \in R^m
,c \in R^n
are problem data
In the light of above, DiffOpt differentiates program variables x
, s
, y
w.r.t pertubations/sensivities in problem data i.e. dA
, db
, dc
. This is achieved via implicit differentiation and matrix differential calculus.
Note that the primal (P) and dual (D) are self-duals of each other. Similarly, for the constraints we support,
\mathcal{K}
is same in format as\mathcal{K}^*
.
- Differentiating Through a Cone Program - Akshay Agrawal, Shane Barratt, Stephen Boyd, Enzo Busseti, Walaa M. Moursi, 2019
- A fast and differentiable QP solver for PyTorch. Crafted by Brandon Amos and J. Zico Kolter.
- OptNet: Differentiable Optimization as a Layer in Neural Networks
One possible point of confusion in finding Jacobians is the role of the backward pass vector - above eqn (7), OptNet: Differentiable Optimization as a Layer in Neural Networks. While differentiating convex programs, it is often the case that we don't want to find the actual derivatives, rather we might be interested in computing the product of Jacobians with a backward pass vector, often used in backpropagation in machine learning/automatic differentiation. This is what happens in DiffOpt
backends.