List of bridges
This section describes the Bridges.AbstractBridges that are implemented in MathOptInterface.
Constraint bridges
These bridges are subtypes of Bridges.Constraint.AbstractBridge.
MathOptInterface.Bridges.Constraint.AbstractFunctionConversionBridge — Typeabstract type AbstractFunctionConversionBridge{F,S} <: AbstractBridge endAbstract type to support writing bridges in which the function changes but the set does not.
By convention, the transformed function is stored in the .constraint field.
MathOptInterface.Bridges.Constraint.AbstractToIntervalBridge — TypeAbstractToIntervalBridge{T<:AbstractFloat,S,F}An abstract type that simplifies the creation of other bridges.
T must be a AbstractFloat type because otherwise typemin and typemax would either be not implemented (for example, BigInt), or would not give infinite value (for example, Int). For this reason, this bridge is only added to MOI.Bridges.full_bridge_optimizer when T is a subtype of AbstractFloat.
MathOptInterface.Bridges.Constraint.AllDifferentToCountDistinctBridge — TypeAllDifferentToCountDistinctBridge{T,F} <: Bridges.Constraint.AbstractBridgeAllDifferentToCountDistinctBridge implements the following reformulations:
- $x \in \textsf{AllDifferent}(d)$ to $(n, x) \in \textsf{CountDistinct}(1+d)$ and $n = d$
- $f(x) \in \textsf{AllDifferent}(d)$ to $(d, f(x)) \in \textsf{CountDistinct}(1+d)$
Source node
AllDifferentToCountDistinctBridge supports:
FinMOI.AllDifferent
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
AllDifferentToCountDistinctBridge creates:
MathOptInterface.Bridges.Constraint.BinPackingToMILPBridge — TypeBinPackingToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeBinPackingToMILPBridge implements the following reformulation:
- $x \in BinPacking(c, w)$ into a mixed-integer linear program.
Reformulation
The reformulation is non-trivial, and it depends on the finite domain of each variable $x_i$, which we as define $S_i = \{l_i,\ldots,u_i\}$.
First, we introduce new binary variables $z_{ij}$, which are $1$ if variable $x_i$ takes the value $j$ in the optimal solution and $0$ otherwise:
\[\begin{aligned} z_{ij} \in \{0, 1\} & \;\; \forall i \in 1\ldots d, j \in S_i \\ x_i - \sum\limits_{j\in S_i} j \cdot z_{ij} = 0 & \;\; \forall i \in 1\ldots d \\ \sum\limits_{j\in S_i} z_{ij} = 1 & \;\; \forall i \in 1\ldots d \\ \end{aligned}\]
Then, we add the capacity constraint for all possible bins $j$:
\[\sum\limits_{i} w_i z_{ij} \le c \forall j \in \bigcup_{i=1,\ldots,d} S_i\]
Source node
BinPackingToMILPBridge supports:
FinMOI.BinPacking{T}
Target nodes
BinPackingToMILPBridge creates:
MathOptInterface.Bridges.Constraint.CircuitToMILPBridge — TypeCircuitToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeCircuitToMILPBridge implements the following reformulation:
- $x \in \textsf{Circuit}(d)$ to the Miller-Tucker-Zemlin formulation of the Traveling Salesperson Problem.
Source node
CircuitToMILPBridge supports:
FinMOI.Circuit
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
CircuitToMILPBridge creates:
MathOptInterface.Bridges.Constraint.ComplexNormInfinityToSecondOrderConeBridge — TypeComplexNormInfinityToSecondOrderConeBridge{T} <: Bridges.Constraint.AbstractBridgeComplexNormInfinityToSecondOrderConeBridge implements the following reformulation:
- $(t, x) \in NormInfinity(1+d)$ into $(t, real(x_i), imag(x_i)) \in SecondOrderCone()$ for all $i$.
Source node
ComplexNormInfinityToSecondOrderConeBridge supports:
Target nodes
ComplexNormInfinityToSecondOrderConeBridge creates:
MathOptInterface.Bridges.Constraint.CountAtLeastToCountBelongsBridge — TypeCountAtLeastToCountBelongsBridge{T,F} <: Bridges.Constraint.AbstractBridgeCountAtLeastToCountBelongsBridge implements the following reformulation:
- $x \in \textsf{CountAtLeast}(n, d, \mathcal{S})$ to $(n_i, x_{d_i}) \in \textsf{CountBelongs}(1+d, \mathcal{S})$ and $n_i \ge n$ for all $i$.
Source node
CountAtLeastToCountBelongsBridge supports:
FinMOI.CountAtLeast
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
CountAtLeastToCountBelongsBridge creates:
MathOptInterface.Bridges.Constraint.CountBelongsToMILPBridge — TypeCountBelongsToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeCountBelongsToMILPBridge implements the following reformulation:
- $(n, x) \in \textsf{CountBelongs}(1+d, \mathcal{S})$ into a mixed-integer linear program.
Reformulation
The reformulation is non-trivial, and it depends on the finite domain of each variable $x_i$, which we as define $S_i = \{l_i,\ldots,u_i\}$.
First, we introduce new binary variables $z_{ij}$, which are $1$ if variable $x_i$ takes the value $j$ in the optimal solution and $0$ otherwise:
\[\begin{aligned} z_{ij} \in \{0, 1\} & \;\; \forall i \in 1\ldots d, j \in S_i \\ x_i - \sum\limits_{j\in S_i} j \cdot z_{ij} = 0 & \;\; \forall i \in 1\ldots d \\ \sum\limits_{j\in S_i} z_{ij} = 1 & \;\; \forall i \in 1\ldots d \\ \end{aligned}\]
Finally, $n$ is constrained to be the number of $z_{ij}$ elements that are in $\mathcal{S}$:
\[n - \sum\limits_{i\in 1\ldots d, j \in \mathcal{S}} z_{ij} = 0\]
Source node
CountBelongsToMILPBridge supports:
FinMOI.CountBelongs
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
CountBelongsToMILPBridge creates:
MathOptInterface.Bridges.Constraint.CountDistinctToMILPBridge — TypeCountDistinctToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeCountDistinctToMILPBridge implements the following reformulation:
- $(n, x) \in \textsf{CountDistinct}(1+d)$ into a mixed-integer linear program.
Reformulation
The reformulation is non-trivial, and it depends on the finite domain of each variable $x_i$, which we as define $S_i = \{l_i,\ldots,u_i\}$.
First, we introduce new binary variables $z_{ij}$, which are $1$ if variable $x_i$ takes the value $j$ in the optimal solution and $0$ otherwise:
\[\begin{aligned} z_{ij} \in \{0, 1\} & \;\; \forall i \in 1\ldots d, j \in S_i \\ x_i - \sum\limits_{j\in S_i} j \cdot z_{ij} = 0 & \;\; \forall i \in 1\ldots d \\ \sum\limits_{j\in S_i} z_{ij} = 1 & \;\; \forall i \in 1\ldots d \\ \end{aligned}\]
Then, we introduce new binary variables $y_j$, which are $1$ if a variable takes the value $j$ in the optimal solution and $0$ otherwise.
\[\begin{aligned} y_{j} \in \{0, 1\} & \;\; \forall j \in \bigcup_{i=1,\ldots,d} S_i \\ y_j \le \sum\limits_{i \in 1\ldots d: j \in S_i} z_{ij} \le M y_j & \;\; \forall j \in \bigcup_{i=1,\ldots,d} S_i\\ \end{aligned}\]
Finally, $n$ is constrained to be the number of $y_j$ elements that are non-zero:
\[n - \sum\limits_{j \in \bigcup_{i=1,\ldots,d} S_i} y_{j} = 0\]
Formulation (special case)
In the special case that the constraint is [2, x, y] in CountDistinct(3), then the constraint is equivalent to [x, y] in AllDifferent(2), which is equivalent to x != y.
\[(x - y \le -1) \vee (y - x \le -1)\]
which is equivalent to (for suitable M):
\[\begin{aligned} z \in \{0, 1\} \\ x - y - M z \le -1 \\ y - x - M (1 - z) \le -1 \end{aligned}\]
Source node
CountDistinctToMILPBridge supports:
FinMOI.CountDistinct
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
CountDistinctToMILPBridge creates:
MathOptInterface.Bridges.Constraint.CountGreaterThanToMILPBridge — TypeCountGreaterThanToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeCountGreaterThanToMILPBridge implements the following reformulation:
- $(c, y, x) \in CountGreaterThan()$ into a mixed-integer linear program.
Source node
CountGreaterThanToMILPBridge supports:
FinMOI.CountGreaterThan
Target nodes
CountGreaterThanToMILPBridge creates:
MathOptInterface.Bridges.Constraint.ExponentialConeToScalarNonlinearFunctionBridge — TypeExponentialConeToScalarNonlinearFunctionBridge{T,F} <:
Bridges.Constraint.AbstractBridgeExponentialConeToScalarNonlinearFunctionBridge implements the following reformulation:
- $(x, y, z) \in \textsf{ExponentialCone}()$ to $y \cdot exp(x / y)) - z \le 0$, $y \ge 0$.
Source node
ExponentialConeToScalarNonlinearFunctionBridge supports:
FinMOI.ExponentialCone
Target nodes
ExponentialConeToScalarNonlinearFunctionBridge creates:
MathOptInterface.Bridges.Constraint.FlipSignBridge — TypeFlipSignBridge{T,S1,S2,F,G}An abstract type that simplifies the creation of other bridges.
MathOptInterface.Bridges.Constraint.FunctionConversionBridge — TypeFunctionConversionBridge{T,F,G,S} <: AbstractFunctionConversionBridge{G,S}FunctionConversionBridge implements the following reformulations:
- $g(x) \in S$ into $f(x) \in S$
for these pairs of functions:
MOI.ScalarAffineFunctionto [MOI.ScalarQuadraticFunction`](@ref)MOI.ScalarQuadraticFunctiontoMOI.ScalarNonlinearFunctionMOI.VectorAffineFunctiontoMOI.VectorQuadraticFunction
See also SetConversionBridge.
Source node
FunctionConversionBridge supports:
GinS
Target nodes
FunctionConversionBridge creates:
FinS
MathOptInterface.Bridges.Constraint.GeoMeanBridge — TypeGeoMeanBridge{T,F,G,H} <: Bridges.Constraint.AbstractBridgeGeoMeanBridge implements a reformulation from MOI.GeometricMeanCone into MOI.RotatedSecondOrderCone.
The reformulation is best described in an example.
Consider the cone of dimension 4:
\[t \le \sqrt[3]{x_1 x_2 x_3}\]
This can be rewritten as $\exists y \ge 0$ such that:
\[\begin{align*} t & \le y,\\ y^4 & \le x_1 x_2 x_3 y. \end{align*}\]
Note that we need to create $y$ and not use $t^4$ directly because $t$ is not allowed to be negative.
This is equivalent to:
\[\begin{align*} t & \le \frac{y_1}{\sqrt{4}},\\ y_1^2 & \le 2y_2 y_3,\\ y_2^2 & \le 2x_1 x_2, \\ y_3^2 & \le 2x_3(y_1/\sqrt{4}) \\ y & \ge 0. \end{align*}\]
More generally, you can show how the geometric mean code is recursively expanded into a set of new variables $y$ in MOI.Nonnegatives, a set of MOI.RotatedSecondOrderCone constraints, and a MOI.LessThan constraint between $t$ and $y_1$.
Source node
GeoMeanBridge supports:
Target nodes
GeoMeanBridge creates:
FinMOI.LessThan{T}GinMOI.RotatedSecondOrderConeGinMOI.Nonnegatives
MathOptInterface.Bridges.Constraint.GeoMeanToPowerBridge — TypeGeoMeanToPowerBridge{T,F} <: Bridges.Constraint.AbstractBridgeGeoMeanToPowerBridge implements the following reformulation:
- $(y, x...) \in GeometricMeanCone(1+d)$ into $(x_1, t, y) \in PowerCone(1/d)$ and $(t, x_2, ..., x_d) in GeometricMeanCone(d)$, which is then recursively expanded into more
PowerConeconstraints.
Source node
GeoMeanToPowerBridge supports:
Target nodes
GeoMeanToPowerBridge creates:
MathOptInterface.Bridges.Constraint.GeoMeantoRelEntrBridge — TypeGeoMeantoRelEntrBridge{T,F,G,H} <: Bridges.Constraint.AbstractBridgeGeoMeantoRelEntrBridge implements the following reformulation:
- $(u, w) \in GeometricMeanCone$ into $(0, w, (u + y)\mathbf{1})\in RelativeEntropyCone$ and $y \ge 0$
Source node
GeoMeantoRelEntrBridge supports:
Target nodes
GeoMeantoRelEntrBridge creates:
GinMOI.RelativeEntropyConeFinMOI.Nonnegatives
Derivation
The derivation of the bridge is as follows:
\[\begin{aligned} (u, w) \in GeometricMeanCone \iff & u \le \left(\prod_{i=1}^n w_i\right)^{1/n} \\ \iff & 0 \le u + y \le \left(\prod_{i=1}^n w_i\right)^{1/n}, y \ge 0 \\ \iff & 1 \le \frac{\left(\prod_{i=1}^n w_i\right)^{1/n}}{u + y}, y \ge 0 \\ \iff & 1 \le \left(\prod_{i=1}^n \frac{w_i}{u + y}\right)^{1/n}, y \ge 0 \\ \iff & 0 \le \sum_{i=1}^n \log\left(\frac{w_i}{u + y}\right), y \ge 0 \\ \iff & 0 \ge \sum_{i=1}^n \log\left(\frac{u + y}{w_i}\right), y \ge 0 \\ \iff & 0 \ge \sum_{i=1}^n (u + y) \log\left(\frac{u + y}{w_i}\right), y \ge 0 \\ \iff & (0, w, (u + y)\mathbf{1}) \in RelativeEntropyCone, y \ge 0 \\ \end{aligned}\]
This derivation assumes that $u + y > 0$, which is enforced by the relative entropy cone.
MathOptInterface.Bridges.Constraint.GreaterToIntervalBridge — TypeGreaterToIntervalBridge{T,F} <: Bridges.Constraint.AbstractBridgeGreaterToIntervalBridge implements the following reformulations:
- $f(x) \ge l$ into $f(x) \in [l, \infty)$
Source node
GreaterToIntervalBridge supports:
FinMOI.GreaterThan{T}
Target nodes
GreaterToIntervalBridge creates:
FinMOI.Interval{T}
MathOptInterface.Bridges.Constraint.GreaterToLessBridge — TypeGreaterToLessBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeGreaterToLessBridge implements the following reformulation:
- $f(x) \ge l$ into $-f(x) \le -l$
Source node
GreaterToLessBridge supports:
GinMOI.GreaterThan{T}
Target nodes
GreaterToLessBridge creates:
FinMOI.LessThan{T}
MathOptInterface.Bridges.Constraint.HermitianToComplexSymmetricBridge — TypeHermitianToComplexSymmetricBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeHermitianToSymmetricBridge implements the following reformulation:
- Hermitian positive semidefinite
n x nrepresented as a vector of real entries with real and imaginary parts on different entries to a vector of complex entries.
See also MOI.Bridges.Constraint.HermitianToSymmetricPSDBridge.
Source node
HermitianToComplexSymmetricBridge supports:
Target node
HermitianToComplexSymmetricBridge creates:
Note that if G is MOI.VectorAffineFunction{T} then F will be MOI.VectorAffineFunction{Complex{T}}
MathOptInterface.Bridges.Constraint.HermitianToSymmetricPSDBridge — TypeHermitianToSymmetricPSDBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeHermitianToSymmetricPSDBridge implements the following reformulation:
- Hermitian positive semidefinite
n x ncomplex matrix to a symmetric positive semidefinite2n x 2nreal matrix.
See also MOI.Bridges.Variable.HermitianToSymmetricPSDBridge.
Source node
HermitianToSymmetricPSDBridge supports:
Target node
HermitianToSymmetricPSDBridge creates:
Reformulation
The reformulation is best described by example.
The Hermitian matrix:
\[\begin{bmatrix} x_{11} & x_{12} + y_{12}im & x_{13} + y_{13}im\\ x_{12} - y_{12}im & x_{22} & x_{23} + y_{23}im\\ x_{13} - y_{13}im & x_{23} - y_{23}im & x_{33} \end{bmatrix}\]
is positive semidefinite if and only if the symmetric matrix:
\[\begin{bmatrix} x_{11} & x_{12} & x_{13} & 0 & y_{12} & y_{13} \\ & x_{22} & x_{23} & -y_{12} & 0 & y_{23} \\ & & x_{33} & -y_{13} & -y_{23} & 0 \\ & & & x_{11} & x_{12} & x_{13} \\ & & & & x_{22} & x_{23} \\ & & & & & x_{33} \end{bmatrix}\]
is positive semidefinite.
The bridge achieves this reformulation by constraining the above matrix to belong to the MOI.PositiveSemidefiniteConeTriangle(6).
MathOptInterface.Bridges.Constraint.IndicatorActiveOnFalseBridge — TypeIndicatorActiveOnFalseBridge{T,F,S} <: Bridges.Constraint.AbstractBridgeIndicatorActiveOnFalseBridge implements the following reformulation:
- $\neg z \implies {f(x) \in S}$ into $y \implies {f(x) \in S}$, $z + y = 1$, and $y \in \{0, 1\}$
Source node
IndicatorActiveOnFalseBridge supports:
Target nodes
IndicatorActiveOnFalseBridge creates:
MathOptInterface.Bridges.Constraint.IndicatorGreaterToLessThanBridge — TypeIndicatorGreaterToLessThanBridge{T,A} <: Bridges.Constraint.AbstractBridgeIndicatorGreaterToLessThanBridge implements the following reformulation:
- $z \implies {f(x) \ge l}$ into $z \implies {-f(x) \le -l}$
Source node
IndicatorGreaterToLessThanBridge supports:
Target nodes
IndicatorGreaterToLessThanBridge creates:
MathOptInterface.Bridges.Constraint.IndicatorLessToGreaterThanBridge — TypeIndicatorLessToGreaterThanBridge{T,A} <: Bridges.Constraint.AbstractBridgeIndicatorLessToGreaterThanBridge implements the following reformulations:
- $z \implies {f(x) \le u}$ into $z \implies {-f(x) \ge -u}$
Source node
IndicatorLessToGreaterThanBridge supports:
Target nodes
IndicatorLessToGreaterThanBridge creates:
MathOptInterface.Bridges.Constraint.IndicatorSOS1Bridge — TypeIndicatorSOS1Bridge{T,S} <: Bridges.Constraint.AbstractBridgeIndicatorSOS1Bridge implements the following reformulation:
- $z \implies {f(x) \in S}$ into $f(x) + y \in S$, $SOS1(y, z)$
This bridge assumes that the solver supports MOI.SOS1{T} constraints in which one of the variables ($y$) is continuous.
Source node
IndicatorSOS1Bridge supports:
Target nodes
IndicatorSOS1Bridge creates:
MathOptInterface.Bridges.Constraint.IndicatorSetMapBridge — TypeIndicatorSetMapBridge{T,A,S1,S2} <: Bridges.Constraint.AbstractBridgeIndicatorSetMapBridge implements the following reformulations:
- $z \implies {f(x) \ge l}$ into $z \implies {-f(x) \le -l}$
- $z \implies {f(x) \le u}$ into $z \implies {-f(x) \ge -u}$
Source node
IndicatorSetMapBridge supports:
Target nodes
IndicatorSetMapBridge creates:
MathOptInterface.Bridges.Constraint.IndicatorToMILPBridge — TypeIndicatorToMILPBridge{T,F,A,S} <: Bridges.Constraint.AbstractBridgeIndicatorToMILPBridge implements the following reformulation:
- $x \in \textsf{Indicator}(s)$ into a mixed-integer linear program.
Source node
IndicatorToMILPBridge supports:
FinMOI.Indicator{A,S}
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
IndicatorToMILPBridge creates:
MathOptInterface.Bridges.Constraint.InequalityToComplementsBridge — TypeInequalityToComplementsBridge{T,F,S,G} <: Bridges.Constraint.AbstractBridgeInequalityToComplementsBridge implements the following reformulations:
- $f(x) \ge b$ into $\exists y$ such that $f(x) - b \perp y \ge 0$
- $f(x) \le b$ into $f(x) - b \perp y \le 0$
- $f(x) = b$ into $f(x) - b \perp y$
Source node
InequalityToComplementsBridge supports:
FinMOI.GreaterThan{T}FinMOI.LessThan{T}FinMOI.EqualTo
Target nodes
InequalityToComplementsBridge creates:
MathOptInterface.Bridges.Constraint.IntegerToZeroOneBridge — TypeIntegerToZeroOneBridge{T} <: Bridges.Constraint.AbstractBridgeIntegerToZeroOneBridge implements the following reformulation:
- $x \in \mathbf{Z}$ into $y_i \in \{0, 1\}$, $x == lb + \sum 2^{i-1} y_i$.
Source node
IntegerToZeroOneBridge supports:
VariableIndexinMOI.Integer
Target nodes
IntegerToZeroOneBridge creates:
Developer note
This bridge is implemented as a constraint bridge instead of a variable bridge because we don't want to substitute the linear combination of y for every instance of x. Doing so would be expensive and greatly reduce the sparsity of the constraints.
MathOptInterface.Bridges.Constraint.IntervalToHyperRectangleBridge — TypeIntervalToHyperRectangleBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeIntervalToHyperRectangleBridge implements the following reformulations:
- $l \le g(x) \le u$ into $[g(x)] \in$
MOI.HyperRectangle([l], [u])
where T is the coefficient type of g(x) and the type of l and u.
See also VectorizeBridge for equality and single-sided bound constraints.
Source node
IntervalToHyperRectangleBridge supports:
GinMOI.Interval{T}
Target nodes
IntervalToHyperRectangleBridge creates:
FinMOI.HyperRectangle{T}.
MathOptInterface.Bridges.Constraint.LessToGreaterBridge — TypeLessToGreaterBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeLessToGreaterBridge implements the following reformulation:
- $f(x) \le u$ into $-f(x) \ge -u$
Source node
LessToGreaterBridge supports:
GinMOI.LessThan{T}
Target nodes
LessToGreaterBridge creates:
FinMOI.GreaterThan{T}
MathOptInterface.Bridges.Constraint.LessToIntervalBridge — TypeLessToIntervalBridge{T,F} <: Bridges.Constraint.AbstractBridgeLessToIntervalBridge implements the following reformulations:
- $f(x) \le u$ into $f(x) \in (-\infty, u]$
Source node
LessToIntervalBridge supports:
FinMOI.LessThan{T}
Target nodes
LessToIntervalBridge creates:
FinMOI.Interval{T}
MathOptInterface.Bridges.Constraint.LogDetBridge — TypeLogDetBridge{T,F,G,H,I} <: Bridges.Constraint.AbstractBridgeThe MOI.LogDetConeTriangle is representable by MOI.PositiveSemidefiniteConeTriangle and MOI.ExponentialCone constraints.
Indeed, $\log\det(X) = \sum\limits_{i=1}^n \log(\delta_i)$ where $\delta_i$ are the eigenvalues of $X$.
Adapting the method from [1, p. 149], we see that $t \le u \log(\det(X/u))$ for $u > 0$ if and only if there exists a lower triangular matrix $Δ$ such that
\[\begin{align*} \begin{pmatrix} X & Δ\\ Δ^\top & \mathrm{Diag}(Δ) \end{pmatrix} & \succeq 0\\ t - \sum_{i=1}^n u \log\left(\frac{Δ_{ii}}{u}\right) & \le 0 \end{align*}\]
Which we reformulate further into
\[\begin{align*} \begin{pmatrix} X & Δ\\ Δ^\top & \mathrm{Diag}(Δ) \end{pmatrix} & \succeq 0\\ (l_i, u , Δ_{ii}) & \in ExponentialCone\quad \forall i \\ t - \sum_{i=1}^n l_i & \le 0 \end{align*}\]
Source node
LogDetBridge supports:
Target nodes
LogDetBridge creates:
[1] Ben-Tal, Aharon, and Arkadi Nemirovski. Lectures on modern convex optimization: analysis, algorithms, and engineering applications. Society for Industrial and Applied Mathematics, 2001.
MathOptInterface.Bridges.Constraint.MultiSetMapBridge — Typeabstract type MultiSetMapBridge{T,S1,G} <: AbstractBridge endSame as SetMapBridge but the output constraint type does not only depend on the input constraint type.
When subtyping MultiSetMapBridge, added_constraint_types and supports should additionally be implemented by the bridge.
For example, if a bridge BridgeType may create either a constraint of type F2-in-S2 or F3-in-S3, these methods should be implemented as follows:
function MOI.Bridges.added_constraint_types(
::Type{<:BridgeType{T,F2,F3}},
) where {T,F2,F3}
return Tuple{Type,Type}[(F2, S2), (F3, S3)]
end
function MOI.supports(
model::MOI.ModelLike,
attr::Union{MOI.ConstraintPrimalStart,MOI.ConstraintDualStart},
::Type{<:BridgeType{T,F2,F3}},
) where {T,F2,F3}
return MOI.supports(model, attr, MOI.ConstraintIndex{F2,S2}) ||
MOI.supports(model, attr, MOI.ConstraintIndex{F3,S3})
endMathOptInterface.Bridges.Constraint.NonnegToNonposBridge — TypeNonnegToNonposBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeNonnegToNonposBridge implements the following reformulation:
- $f(x) \in \mathbb{R}_+$ into $-f(x) \in \mathbb{R}_-$
Source node
NonnegToNonposBridge supports:
GinMOI.Nonnegatives
Target nodes
NonnegToNonposBridge creates:
FinMOI.Nonpositives
MathOptInterface.Bridges.Constraint.NonposToNonnegBridge — TypeNonposToNonnegBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeNonposToNonnegBridge implements the following reformulation:
- $f(x) \in \mathbb{R}_-$ into $-f(x) \in \mathbb{R}_+$
Source node
NonposToNonnegBridge supports:
GinMOI.Nonpositives
Target nodes
NonposToNonnegBridge creates:
FinMOI.Nonnegatives
MathOptInterface.Bridges.Constraint.NormInfinityBridge — TypeNormInfinityBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeNormInfinityBridge implements the following reformulation:
- $|x|_\infty \le t$ into $[t - x_i, t + x_i] \in \mathbb{R}_+$.
Source node
NormInfinityBridge supports:
Target nodes
NormInfinityBridge creates:
FinMOI.Nonnegatives
MathOptInterface.Bridges.Constraint.NormInfinityConeToNormConeBridge — TypeNormInfinityConeToNormConeBridge{T,F} <: Bridges.Constraint.AbstractBridgeNormInfinityConeToNormConeBridge implements the following reformulations:
- $(t, x) in NormInfinityCone(d)$ into $(t, x) in NormCone(Inf, d)$
Source node
NormInfinityConeToNormConeBridge supports:
FinMOI.NormInfinityCone
Target nodes
NormInfinityConeToNormConeBridge creates:
FinMOI.NormCone
MathOptInterface.Bridges.Constraint.NormNuclearBridge — TypeNormNuclearBridge{T,F,G,H} <: Bridges.Constraint.AbstractBridgeNormNuclearBridge implements the following reformulation:
- $t \ge \sum_i \sigma_i (X)$ into $\left[\begin{array}{c c}U & X^\top \\ X & V\end{array}\right] \succeq 0$ and $2t \ge tr(U) + tr(V)$.
Source node
NormNuclearBridge supports:
HinMOI.NormNuclearCone
Target nodes
NormNuclearBridge creates:
MathOptInterface.Bridges.Constraint.NormOneBridge — TypeNormOneBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeNormOneBridge implements the following reformulation:
- $\sum |x_i| \le t$ into $[t - \sum y_i, y_i - x_i, y_i + x_i] \in \mathbb{R}_+$.
Source node
NormOneBridge supports:
GinMOI.NormOneCone{T}
Target nodes
NormOneBridge creates:
FinMOI.Nonnegatives
MathOptInterface.Bridges.Constraint.NormOneConeToNormConeBridge — TypeNormOneConeToNormConeBridge{T,F} <: Bridges.Constraint.AbstractBridgeNormOneConeToNormConeBridge implements the following reformulations:
- $(t, x) in NormOneCone(d)$ into $(t, x) in NormCone(1, d)$
Source node
NormOneConeToNormConeBridge supports:
FinMOI.NormOneCone
Target nodes
NormOneConeToNormConeBridge creates:
FinMOI.NormCone
MathOptInterface.Bridges.Constraint.NormSpectralBridge — TypeNormSpectralBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeNormSpectralBridge implements the following reformulation:
- $t \ge \sigma_1(X)$ into $\left[\begin{array}{c c}t\mathbf{I} & X^\top \\ X & t \mathbf{I}\end{array}\right] \succeq 0$
Source node
NormSpectralBridge supports:
GinMOI.NormSpectralCone
Target nodes
NormSpectralBridge creates:
MathOptInterface.Bridges.Constraint.NormToPowerBridge — TypeNormToPowerBridge{T,F} <: Bridges.Constraint.AbstractBridgeNormToPowerBridge implements the following reformulation:
- $(t, x) \in NormCone(p, 1+d)$ into $(r_i, t, x_i) \in PowerCone(1 / p)$ for all $i$, and $\sum\limits_i r_i == t$.
For details, see Alizadeh, F., and Goldfarb, D. (2001). "Second-order cone programming." Mathematical Programming, Series B, 95:3-51.
Source node
NormToPowerBridge supports:
FinMOI.NormCone
Target nodes
NormToPowerBridge creates:
MathOptInterface.Bridges.Constraint.NumberConversionBridge — TypeNumberConversionBridge{T,F1,S1,F2,S2} <: Bridges.Constraint.AbstractBridgeNumberConversionBridge implements the following reformulation:
- $f1(x) \in S1$ to $f2(x) \in S2$
where f and S are the same functional form, but differ in their coefficient type.
Source node
NumberConversionBridge supports:
F1inS1
Target node
NumberConversionBridge creates:
F2inS2
MathOptInterface.Bridges.Constraint.QuadtoSOCBridge — TypeQuadtoSOCBridge{T} <: Bridges.Constraint.AbstractBridgeQuadtoSOCBridge converts quadratic inequalities
\[\frac{1}{2}x^T Q x + a^T x \le ub\]
into MOI.RotatedSecondOrderCone constraints, but it only applies when $Q$ is positive definite.
This is because, if Q is positive definite, there exists U such that $Q = U^T U$, and so the inequality can then be rewritten as;
\[\|U x\|_2^2 \le 2 (-a^T x + ub)\]
Therefore, QuadtoSOCBridge implements the following reformulations:
- $\frac{1}{2}x^T Q x + a^T x \le ub$ into $(1, -a^T x + ub, Ux) \in RotatedSecondOrderCone$ where $Q = U^T U$
- $\frac{1}{2}x^T Q x + a^T x \ge lb$ into $(1, a^T x - lb, Ux) \in RotatedSecondOrderCone$ where $-Q = U^T U$
Source node
QuadtoSOCBridge supports:
Target nodes
RelativeEntropyBridge creates:
Errors
This bridge errors if Q is not positive definite.
MathOptInterface.Bridges.Constraint.RSOCtoNonConvexQuadBridge — TypeRSOCtoNonConvexQuadBridge{T} <: Bridges.Constraint.AbstractBridgeRSOCtoNonConvexQuadBridge implements the following reformulations:
- $||x||_2^2 \le 2tu$ into $\sum x^2 - 2tu \le 0$, $1t + 0 \ge 0$, and $1u + 0 \ge 0$.
The MOI.ScalarAffineFunctions $1t + 0$ and $1u + 0$ are used in case the variables have other bound constraints.
This transformation starts from a convex constraint and creates a non-convex constraint. Unless the solver has explicit support for detecting rotated second-order cones in quadratic form, this may (wrongly) be interpreted by the solver as being non-convex. Therefore, this bridge is not added automatically by MOI.Bridges.full_bridge_optimizer. Care is recommended when adding this bridge to a optimizer.
Source node
RSOCtoNonConvexQuadBridge supports:
Target nodes
RSOCtoNonConvexQuadBridge creates:
MathOptInterface.Bridges.Constraint.RSOCtoPSDBridge — TypeRSOCtoPSDBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeRSOCtoPSDBridge implements the following reformulation:
- $||x||_2^2 \le 2t\cdot u$ into $\left[\begin{array}{c c}t & x^\top \\ x & 2tu \mathbf{I}\end{array}\right]\succeq 0$
Source node
RSOCtoPSDBridge supports:
Target nodes
RSOCtoPSDBridge creates:
MathOptInterface.Bridges.Constraint.RSOCtoSOCBridge — TypeRSOCtoSOCBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeRSOCtoSOCBridge implements the following reformulation:
- $||x||_2^2 \le 2tu$ into $||\frac{t - u}{\sqrt 2}, x||_2 \le \frac{t + u}{\sqrt 2}$
Source node
RSOCtoSOCBridge supports:
Target node
RSOCtoSOCBridge creates:
FinMOI.SecondOrderCone
MathOptInterface.Bridges.Constraint.ReifiedAllDifferentToCountDistinctBridge — TypeReifiedAllDifferentToCountDistinctBridge{T,F} <:
Bridges.Constraint.AbstractBridgeReifiedAllDifferentToCountDistinctBridge implements the following reformulations:
- $r \iff x \in \textsf{AllDifferent}(d)$ to $r \iff (n, x) \in \textsf{CountDistinct}(1+d)$ and $n = d$
- $r \iff f(x) \in \textsf{AllDifferent}(d)$ to $r \iff (d, f(x)) \in \textsf{CountDistinct}(1+d)$
Source node
ReifiedAllDifferentToCountDistinctBridge supports:
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
ReifiedAllDifferentToCountDistinctBridge creates:
MathOptInterface.Bridges.Constraint.ReifiedCountDistinctToMILPBridge — TypeReifiedCountDistinctToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeReifiedCountDistinctToMILPBridge implements the following reformulation:
- $r \iff (n, x) \in \textsf{CountDistinct}(1+d)$ into a mixed-integer linear program.
Reformulation
The reformulation is non-trivial, and it depends on the finite domain of each variable $x_i$, which we as define $S_i = \{l_i,\ldots,u_i\}$.
First, we introduce new binary variables $z_{ij}$, which are $1$ if variable $x_i$ takes the value $j$ in the optimal solution and $0$ otherwise:
\[\begin{aligned} z_{ij} \in \{0, 1\} & \;\; \forall i \in 1\ldots d, j \in S_i \\ x_i - \sum\limits_{j\in S_i} j \cdot z_{ij} = 0 & \;\; \forall i \in 1\ldots d \\ \sum\limits_{j\in S_i} z_{ij} = 1 & \;\; \forall i \in 1\ldots d \\ \end{aligned}\]
Then, we introduce new binary variables $y_j$, which are $1$ if a variable takes the value $j$ in the optimal solution and $0$ otherwise.
\[\begin{aligned} y_{j} \in \{0, 1\} & \;\; \forall j \in \bigcup_{i=1,\ldots,d} S_i \\ y_j \le \sum\limits_{i \in 1\ldots d: j \in S_i} z_{ij} \le M y_j & \;\; \forall j \in \bigcup_{i=1,\ldots,d} S_i\\ \end{aligned}\]
Finally, $n$ is constrained to be the number of $y_j$ elements that are non-zero, with some slack:
\[n - \sum\limits_{j \in \bigcup_{i=1,\ldots,d} S_i} y_{j} = \delta^+ - \delta^-\]
And then the slack is constrained to respect the reif variable $r$:
\[\begin{aligned} d_1 \le \delta^+ \le M d_1 \\ d_2 \le \delta^- \le M d_s \\ d_1 + d_2 + r = 1 \\ d_1, d_2 \in \{0, 1\} \end{aligned}\]
Source node
ReifiedCountDistinctToMILPBridge supports:
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
ReifiedCountDistinctToMILPBridge creates:
MathOptInterface.Bridges.Constraint.RelativeEntropyBridge — TypeRelativeEntropyBridge{T,F,G,H} <: Bridges.Constraint.AbstractBridgeRelativeEntropyBridge implements the following reformulation that converts a MOI.RelativeEntropyCone into an MOI.ExponentialCone:
- $u \ge \sum_{i=1}^n w_i \log \left(\frac{w_i}{v_i}\right)$ into $y_i \ge 0$, $u \ge \sum_{i=1}^n y_i$, and $(-y_i, w_i, v_i) \in ExponentialCone$.
Source node
RelativeEntropyBridge supports:
Target nodes
RelativeEntropyBridge creates:
FinMOI.GreaterThan{T}GinMOI.ExponentialCone
MathOptInterface.Bridges.Constraint.RootDetBridge — TypeRootDetBridge{T,F,G,H} <: Bridges.Constraint.AbstractBridgeThe MOI.RootDetConeTriangle is representable by MOI.PositiveSemidefiniteConeTriangle and MOI.GeometricMeanCone constraints, see [1, p. 149].
Indeed, $t \le \det(X)^{1/n}$ if and only if there exists a lower triangular matrix $Δ$ such that:
\[\begin{align*} \begin{pmatrix} X & Δ\\ Δ^\top & \mathrm{Diag}(Δ) \end{pmatrix} & \succeq 0\\ (t, \mathrm{Diag}(Δ)) & \in GeometricMeanCone \end{align*}\]
Source node
RootDetBridge supports:
Target nodes
RootDetBridge creates:
[1] Ben-Tal, Aharon, and Arkadi Nemirovski. Lectures on modern convex optimization: analysis, algorithms, and engineering applications. Society for Industrial and Applied Mathematics, 2001.
MathOptInterface.Bridges.Constraint.SOCtoNonConvexQuadBridge — TypeSOCtoNonConvexQuadBridge{T} <: Bridges.Constraint.AbstractBridgeSOCtoNonConvexQuadBridge implements the following reformulations:
- $||x||_2 \le t$ into $\sum x^2 - t^2 \le 0$ and $1t + 0 \ge 0$
The MOI.ScalarAffineFunction $1t + 0$ is used in case the variable has other bound constraints.
This transformation starts from a convex constraint and creates a non-convex constraint. Unless the solver has explicit support for detecting second-order cones in quadratic form, this may (wrongly) be interpreted by the solver as being non-convex. Therefore, this bridge is not added automatically by MOI.Bridges.full_bridge_optimizer. Care is recommended when adding this bridge to a optimizer.
Source node
SOCtoNonConvexQuadBridge supports:
Target nodes
SOCtoNonConvexQuadBridge creates:
MathOptInterface.Bridges.Constraint.SOCtoPSDBridge — TypeSOCtoPSDBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeSOCtoPSDBridge implements the following reformulation:
- $||x||_2 \le t$ into $\left[\begin{array}{c c}t & x^\top \\ x & t \mathbf{I}\end{array}\right]\succeq 0$
This bridge is not added by default by MOI.Bridges.full_bridge_optimizer because bridging second order cone constraints to semidefinite constraints can be achieved by the SOCtoRSOCBridge followed by the RSOCtoPSDBridge, while creating a smaller semidefinite constraint.
Source node
SOCtoPSDBridge supports:
GinMOI.SecondOrderCone
Target nodes
SOCtoPSDBridge creates:
MathOptInterface.Bridges.Constraint.SOCtoRSOCBridge — TypeSOCtoRSOCBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeSOCtoRSOCBridge implements the following reformulation:
- $||x||_2 \le t$ into $(t+x_1)(t-x_1)\ge ||(x_2\ldots,x_N)||_2^2$
Assumptions
SOCtoRSOCBridgeassumes that the length ofxis at least one.
Source node
SOCtoRSOCBridge supports:
GinMOI.SecondOrderCone
Target node
SOCtoRSOCBridge creates:
MathOptInterface.Bridges.Constraint.SOS1ToMILPBridge — TypeSOS1ToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeSOS1ToMILPBridge implements the following reformulation:
- $x \in \textsf{SOS1}(d)$ into a mixed-integer linear program.
Source node
SOS1ToMILPBridge supports:
FinMOI.SOS1
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
SOS1ToMILPBridge creates:
MathOptInterface.Bridges.Constraint.SOS2ToMILPBridge — TypeSOS2ToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeSOS2ToMILPBridge implements the following reformulation:
- $x \in \textsf{SOS2}(d)$ into a mixed-integer linear program.
Source node
SOS2ToMILPBridge supports:
FinMOI.SOS2
where F is MOI.VectorOfVariables or MOI.VectorAffineFunction{T}.
Target nodes
SOS2ToMILPBridge creates:
MathOptInterface.Bridges.Constraint.ScalarFunctionizeBridge — TypeScalarFunctionizeBridge{T,S} = FunctionConversionBridge{T,MOI.ScalarAffineFunction{T},MOI.VariableIndex,S}ScalarFunctionizeBridge implements the following reformulations:
- $x \in S$ into $1x + 0 \in S$
Source node
ScalarFunctionizeBridge supports:
MOI.VariableIndexinS
Target nodes
ScalarFunctionizeBridge creates:
MathOptInterface.Bridges.Constraint.ScalarSlackBridge — TypeScalarSlackBridge{T,F,S} <: Bridges.Constraint.AbstractBridgeScalarSlackBridge implements the following reformulation:
- $f(x) \in S$ into $f(x) - y == 0$ and $y \in S$
Source node
ScalarSlackBridge supports:
GinS, whereGis notMOI.VariableIndexandSis notMOI.EqualTo
Target nodes
ScalarSlackBridge creates:
FinMOI.EqualTo{T}MOI.VariableIndexinS
MathOptInterface.Bridges.Constraint.ScalarizeBridge — TypeScalarizeBridge{T,F,S}ScalarizeBridge implements the following reformulations:
- $f(x) - a \in \mathbb{R}_+$ into $f_i(x) \ge a_i$ for all $i$
- $f(x) - a \in \mathbb{R}_-$ into $f_i(x) \le a_i$ for all $i$
- $f(x) - a \in \{0\}$ into $f_i(x) == a_i$ for all $i$
Source node
ScalarizeBridge supports:
GinMOI.Nonnegatives{T}GinMOI.Nonpositives{T}GinMOI.Zeros{T}
Target nodes
ScalarizeBridge creates:
FinS, whereSis one ofMOI.GreaterThan{T},MOI.LessThan{T}, andMOI.EqualTo{T}, depending on the type of the input set.
MathOptInterface.Bridges.Constraint.SecondOrderConeToNormConeBridge — TypeSecondOrderConeToNormConeBridge{T,F} <: Bridges.Constraint.AbstractBridgeSecondOrderConeToNormConeBridge implements the following reformulations:
- $(t, x) in SecondOrderCone(d)$ into $(t, x) in NormCone(2, d)$
Source node
SecondOrderConeToNormConeBridge supports:
FinMOI.SecondOrderCone
Target nodes
SecondOrderConeToNormConeBridge creates:
FinMOI.NormCone
MathOptInterface.Bridges.Constraint.SemiToBinaryBridge — TypeSemiToBinaryBridge{T,S} <: Bridges.Constraint.AbstractBridgeSemiToBinaryBridge implements the following reformulations:
- $x \in \{0\} \cup [l, u]$ into
\[\begin{aligned} x \leq z u \\ x \geq z l \\ z \in \{0, 1\} \end{aligned}\]
- $x \in \{0\} \cup \{l, \ldots, u\}$ into
\[\begin{aligned} x \leq z u \\ x \geq z l \\ z \in \{0, 1\} \\ x \in \mathbb{Z} \end{aligned}\]
Source node
SemiToBinaryBridge supports:
Target nodes
SemiToBinaryBridge creates:
MathOptInterface.Bridges.Constraint.SetConversionBridge — TypeSetConversionBridge{T,S2,S1,F} <:
MOI.Bridges.Constraint.SetMapBridge{T,S2,S1,F,F}SetConversionBridge implements the following reformulations:
- $f(x) \in S1$ into $f(x) \in S2$
In order to add this bridge, you need to create a bridge specific for a given type T and set S2:
MOI.Bridges.add_bridge(model, MOI.Bridges.Constraint.SetConversionBridge{T,S2})In order to define a bridge with S2 specified but T unspecified, for example for JuMP.add_bridge, you can use
const MyBridge{T,S1,F} = MOI.Bridges.Constraint.SetConversionBridge{T,S2,S1,F}See also FunctionConversionBridge.
Source node
SetConversionBridge supports:
FinS1
Target nodes
SetConversionBridge creates:
FinS2
MathOptInterface.Bridges.Constraint.SetDotInverseScalingBridge — TypeSetDotInverseScalingBridge{T,S,F,G} <: Bridges.Constraint.AbstractBridgeSetDotInverseScalingBridge implements the reformulation from constraints in the MOI.Scaled{S} to constraints in the S.
Source node
SetDotInverseScalingBridge supports:
GinMOI.Scaled{S}
Target node
SetDotInverseScalingBridge creates:
FinS
MathOptInterface.Bridges.Constraint.SetDotScalingBridge — TypeSetDotScalingBridge{T,S,F,G} <: Bridges.Constraint.AbstractBridgeSetDotScalingBridge implements the reformulation from constraints in S to constraints in MOI.Scaled{S}.
Source node
SetDotScalingBridge supports:
GinS
Target node
SetDotScalingBridge creates:
FinMOI.Scaled{S}
MathOptInterface.Bridges.Constraint.SetMapBridge — Typeabstract type SetMapBridge{T,S2,S1,F,G} <: MultiSetMapBridge{T,S1,G} endConsider two type of sets, S1 and S2, and a linear mapping A such that the image of a set of type S1 under A is a set of type S2.
A SetMapBridge{T,S2,S1,F,G} is a bridge that maps G-in-S1 constraints into F-in-S2 by mapping the function through A.
The linear map A is described by;
Implementing a method for these two functions is sufficient to bridge constraints. However, in order for the getters and setters of attributes such as dual solutions and starting values to work as well, a method for the following functions must be implemented:
MOI.Bridges.inverse_map_setMOI.Bridges.inverse_map_functionMOI.Bridges.adjoint_map_functionMOI.Bridges.inverse_adjoint_map_function
See the docstrings of each function to see which feature would be missing if it was not implemented for a given bridge.
MathOptInterface.Bridges.Constraint.SplitComplexEqualToBridge — TypeSplitComplexEqualToBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeSplitComplexEqualToBridge implements the following reformulation:
- $f(x) + g(x) * im = a + b * im$ into $f(x) = a$ and $g(x) = b$
Source node
SplitComplexEqualToBridge supports:
where G is a function with Complex coefficients.
Target nodes
SplitComplexEqualToBridge creates:
FinMOI.EqualTo{T}
where F is the type of the real/imaginary part of G.
MathOptInterface.Bridges.Constraint.SplitComplexZerosBridge — TypeSplitComplexZerosBridge{T,F,G} <: Bridges.Constraint.AbstractBridgeSplitComplexZerosBridge implements the following reformulation:
- $f(x) \in \{0\}^n$ into $\text{Re}(f(x)) \in \{0\}^n$ and $\text{Im}(f(x)) \in \{0\}^n$
Source node
SplitComplexZerosBridge supports:
GinMOI.Zeros
where G is a function with Complex coefficients.
Target nodes
SplitComplexZerosBridge creates:
FinMOI.Zeros
where F is the type of the real/imaginary part of G.
MathOptInterface.Bridges.Constraint.SplitHyperRectangleBridge — TypeSplitHyperRectangleBridge{T,G,F} <: Bridges.Constraint.AbstractBridgeSplitHyperRectangleBridge implements the following reformulation:
- $f(x) \in \textsf{HyperRectangle}(l, u)$ to $[f(x) - l; u - f(x)] \in \mathbb{R}_+$.
Source node
SplitHyperRectangleBridge supports:
FinMOI.HyperRectangle
Target nodes
SplitHyperRectangleBridge creates:
GinMOI.Nonnegatives
MathOptInterface.Bridges.Constraint.SplitIntervalBridge — TypeSplitIntervalBridge{T,F,S,LS,US} <: Bridges.Constraint.AbstractBridgeSplitIntervalBridge implements the following reformulations:
- $l \le f(x) \le u$ into $f(x) \ge l$ and $f(x) \le u$
- $f(x) = b$ into $f(x) \ge b$ and $f(x) \le b$
- $f(x) \in \{0\}$ into $f(x) \in \mathbb{R}_+$ and $f(x) \in \mathbb{R}_-$
Source node
SplitIntervalBridge supports:
FinMOI.Interval{T}FinMOI.EqualTo{T}FinMOI.Zeros
Target nodes
SplitIntervalBridge creates:
FinMOI.LessThan{T}FinMOI.GreaterThan{T}
or
FinMOI.NonnegativesFinMOI.Nonpositives
If T<:AbstractFloat and S is MOI.Interval{T} then no lower (resp. upper) bound constraint is created if the lower (resp. upper) bound is typemin(T) (resp. typemax(T)). Similarly, when MOI.ConstraintSet is set, a lower or upper bound constraint may be deleted or created accordingly.
MathOptInterface.Bridges.Constraint.SquareBridge — TypeSquareBridge{T,F,G,TT,ST} <: Bridges.Constraint.AbstractBridgeSquareBridge implements the following reformulations:
- $(t, u, X) \in LogDetConeSquare$ into $(t, u, Y) in LogDetConeTriangle$
- $(t, X) \in RootDetConeSquare$ into $(t, Y) in RootDetConeTriangle$
- $X \in AbstractSymmetricMatrixSetSquare$ into $Y in AbstractSymmetricMatrixSetTriangle$
where $Y$ is the upper triangluar component of $X$.
In addition, constraints are added as necessary to constrain the matrix $X$ to be symmetric. For example, the constraint for the matrix:
\[\begin{pmatrix} 1 & 1 + x & 2 - 3x\\ 1 + x & 2 + x & 3 - x\\ 2 - 3x & 2 + x & 2x \end{pmatrix}\]
can be broken down to the constraint of the symmetric matrix
\[\begin{pmatrix} 1 & 1 + x & 2 - 3x\\ \cdot & 2 + x & 3 - x\\ \cdot & \cdot & 2x \end{pmatrix}\]
and the equality constraint between the off-diagonal entries (2, 3) and (3, 2) $3 - x == 2 + x$. Note that no symmetrization constraint needs to be added between the off-diagonal entries (1, 2) and (2, 1) or between (1, 3) and (3, 1) because the expressions are the same.
Source node
SquareBridge supports:
FinST
Target nodes
SquareBridge creates:
GinTT
MathOptInterface.Bridges.Constraint.TableToMILPBridge — TypeTableToMILPBridge{T,F} <: Bridges.Constraint.AbstractBridgeTableToMILPBridge implements the following reformulation:
- $x \in Table(t)$ into
\[\begin{aligned} z_{j} \in \{0, 1\} & \quad \forall i, j \\ \sum\limits_{j=1}^n z_{j} = 1 \\ \sum\limits_{j=1}^n t_{ij} z_{j} = x_i & \quad \forall i \end{aligned}\]
Source node
TableToMILPBridge supports:
FinMOI.Table{T}
Target nodes
TableToMILPBridge creates:
MathOptInterface.Bridges.Constraint.ToScalarNonlinearBridge — TypeToScalarNonlinearBridge{T,G,S} <: AbstractFunctionConversionBridge{G,S}ToScalarNonlinearBridge implements the following reformulation:
- $g(x) \in S$ into $f(x) \in S$
where g is an abstract scalar function and f is a MOI.ScalarNonlinearFunction.
Source node
ToScalarNonlinearBridge supports:
G<:AbstractScalarFunctioninS
Target nodes
ToScalarNonlinearBridge creates:
MathOptInterface.Bridges.Constraint.ToScalarQuadraticBridge — TypeToScalarQuadraticBridge{T,G,S} <: AbstractFunctionConversionBridge{G,S}ToScalarQuadraticBridge implements the following reformulation:
- $g(x) \in S$ into $f(x) \in S$
where g is an abstract scalar function and f is a MOI.ScalarQuadraticFunction.
Source node
ToScalarQuadraticBridge supports:
G<:AbstractScalarFunctioninS
Target nodes
ToScalarQuadraticBridge creates:
MathOptInterface.Bridges.Constraint.ToVectorQuadraticBridge — TypeToVectorQuadraticBridge{T,G,S} <: AbstractFunctionConversionBridge{G,S}ToVectorQuadraticBridge implements the following reformulation:
- $g(x) \in S$ into $f(x) \in S$
where g is an abstract vector function and f is a MOI.VectorQuadraticFunction.
Source node
ToVectorQuadraticBridge supports:
G<:AbstractVectorFunctioninS
Target nodes
ToVectorQuadraticBridge creates:
MathOptInterface.Bridges.Constraint.VectorFunctionizeBridge — TypeVectorFunctionizeBridge{T,S} = FunctionConversionBridge{T,MOI.VectorAffineFunction{T},S}VectorFunctionizeBridge implements the following reformulations:
- $x \in S$ into $Ix + 0 \in S$
Source node
VectorFunctionizeBridge supports:
Target nodes
VectorFunctionizeBridge creates:
MathOptInterface.Bridges.Constraint.VectorSlackBridge — TypeVectorSlackBridge{T,F,S} <: Bridges.Constraint.AbstractBridgeVectorSlackBridge implements the following reformulation:
- $f(x) \in S$ into $f(x) - y \in \{0\}$ and $y \in S$
Source node
VectorSlackBridge supports:
GinS, whereGis notMOI.VectorOfVariablesandSis notMOI.Zeros
Target nodes
VectorSlackBridge creates:
FinMOI.ZerosMOI.VectorOfVariablesinS
MathOptInterface.Bridges.Constraint.VectorizeBridge — TypeVectorizeBridge{T,F,S,G} <: Bridges.Constraint.AbstractBridgeVectorizeBridge implements the following reformulations:
- $g(x) \ge a$ into $[g(x) - a] \in \mathbb{R}_+$
- $g(x) \le a$ into $[g(x) - a] \in \mathbb{R}_-$
- $g(x) == a$ into $[g(x) - a] \in \{0\}$
where T is the coefficient type of g(x) - a.
See also IntervalToHyperRectangleBridge for double-sided bound constraints.
Source node
VectorizeBridge supports:
GinMOI.GreaterThan{T}GinMOI.LessThan{T}GinMOI.EqualTo{T}
Target nodes
VectorizeBridge creates:
FinS, whereSis one ofMOI.Nonnegatives,MOI.Nonpositives,MOI.Zerosdepending on the type of the input set.
MathOptInterface.Bridges.Constraint.ZeroOneBridge — TypeZeroOneBridge{T} <: Bridges.Constraint.AbstractBridgeZeroOneBridge implements the following reformulation:
- $x \in \{0, 1\}$ into $x \in \mathbb{Z}$, $1x \in [0, 1]$.
ZeroOneBridge adds a linear constraint instead of adding variable bounds to avoid conflicting with bounds set by the user.
Source node
ZeroOneBridge supports:
Target nodes
ZeroOneBridge creates:
Objective bridges
These bridges are subtypes of Bridges.Objective.AbstractBridge.
MathOptInterface.Bridges.Objective.FunctionConversionBridge — TypeFunctionConversionBridge{T,F,G} <: AbstractBridgeFunctionConversionBridge implements the following reformulations:
- $\min \{g(x)\}$ into $\min\{f(x)\}$
- $\max \{g(x)\}$ into $\max\{f(x)\}$
for these pairs of functions:
MOI.ScalarAffineFunctiontoMOI.ScalarQuadraticFunctionMOI.ScalarQuadraticFunctiontoMOI.ScalarNonlinearFunctionMOI.VectorAffineFunctiontoMOI.VectorQuadraticFunction
Source node
FunctionConversionBridge supports:
Target nodes
FunctionConversionBridge creates:
- One objective node:
MOI.ObjectiveFunction{F}
MathOptInterface.Bridges.Objective.FunctionizeBridge — TypeFunctionizeBridge{T,G} <: FunctionConversionBridge{T,MOI.ScalarAffineFunction{T},G}FunctionizeBridge implements the following reformulations:
- $\min \{x\}$ into $\min\{1x + 0\}$
- $\max \{x\}$ into $\max\{1x + 0\}$
where T is the coefficient type of 1 and 0.
Source node
FunctionizeBridge supports:
Target nodes
FunctionizeBridge creates:
- One objective node:
MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}
MathOptInterface.Bridges.Objective.QuadratizeBridge — TypeQuadratizeBridge{T,G} <: FunctionConversionBridge{T,MOI.ScalarQuadraticFunction{T},G}QuadratizeBridge implements the following reformulations:
- $\min \{a^\top x + b\}$ into $\min\{x^\top \mathbf{0} x + a^\top x + b\}$
- $\max \{a^\top x + b\}$ into $\max\{x^\top \mathbf{0} x + a^\top x + b\}$
where T is the coefficient type of 0.
Source node
QuadratizeBridge supports:
Target nodes
QuadratizeBridge creates:
- One objective node:
MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{T}}
MathOptInterface.Bridges.Objective.SlackBridge — TypeSlackBridge{T,F,G}SlackBridge implements the following reformulations:
- $\min\{f(x)\}$ into $\min\{y\;|\; f(x) - y \le 0\}$
- $\max\{f(x)\}$ into $\max\{y\;|\; f(x) - y \ge 0\}$
where F is the type of f(x) - y, G is the type of f(x), and T is the coefficient type of f(x).
Source node
SlackBridge supports:
Target nodes
SlackBridge creates:
- One variable node:
MOI.VariableIndexinMOI.Reals - One objective node:
MOI.ObjectiveFunction{MOI.VariableIndex} - One constraint node, that depends on the
MOI.ObjectiveSense:F-in-MOI.LessThanifMIN_SENSEF-in-MOI.GreaterThanifMAX_SENSE
When using this bridge, changing the optimization sense is not supported. Set the sense to MOI.FEASIBILITY_SENSE first to delete the bridge, then set MOI.ObjectiveSense and re-add the objective.
MathOptInterface.Bridges.Objective.ToScalarNonlinearBridge — TypeToScalarNonlinearBridge{T,G} <: FunctionConversionBridge{T,MOI.ScalarNonlinearFunction,G}ToScalarNonlinearBridge implements the following reformulations:
- $\min\{x^\top \mathbf{𝑄} x + a^\top x + b\}$ into $\min\{f(x)\}$
- $\max\{x^\top \mathbf{𝑄} x + a^\top x + b\}$ into $\max\{f(x)\}$
where f(x) is a MOI.ScalarNonlinearFunction.
Source node
ToScalarNonlinearBridge supports:
Target nodes
ToScalarNonlinearBridge creates:
- One objective node:
MOI.ObjectiveFunction{MOI.ScalarNonlinearFunction}
MathOptInterface.Bridges.Objective.VectorFunctionizeBridge — TypeVectorFunctionizeBridge{T,G} <: FunctionConversionBridge{T,MOI.VectorAffineFunction{T},G}VectorFunctionizeBridge implements the following reformulations:
- $\min \{x\}$ into $\min\{1x + 0\}$
- $\max \{x\}$ into $\max\{1x + 0\}$
where T is the coefficient type of 1 and 0.
Source node
VectorFunctionizeBridge supports:
Target nodes
VectorFunctionizeBridge creates:
- One objective node:
MOI.ObjectiveFunction{MOI.VectorAffineFunction{T}}
MathOptInterface.Bridges.Objective.VectorSlackBridge — TypeVectorSlackBridge{T,F,G}VectorSlackBridge implements the following reformulations:
- $\min\{f(x)\}$ into $\min\{y\;|\; y - f(x) \in \mathbb{R}_+ \}$
- $\max\{f(x)\}$ into $\max\{y\;|\; f(x) - y \in \mathbb{R}_+ \}$
where F is the type of f(x) - y, G is the type of f(x), and T is the coefficient type of f(x).
Source node
VectorSlackBridge supports:
Target nodes
VectorSlackBridge creates:
- One variable node:
MOI.VectorOfVariablesinMOI.Reals - One objective node:
MOI.ObjectiveFunction{MOI.VectorOfVariables} - One constraint node:
F-in-MOI.Nonnegatives
When using this bridge, changing the optimization sense is not supported. Set the sense to MOI.FEASIBILITY_SENSE first to delete the bridge, then set MOI.ObjectiveSense and re-add the objective.
Variable bridges
These bridges are subtypes of Bridges.Variable.AbstractBridge.
MathOptInterface.Bridges.Variable.FlipSignBridge — Typeabstract type FlipSignBridge{T,S1,S2} <: SetMapBridge{T,S2,S1} endAn abstract type that simplifies the creation of other bridges.
MathOptInterface.Bridges.Variable.FreeBridge — TypeFreeBridge{T} <: Bridges.Variable.AbstractBridgeFreeBridge implements the following reformulation:
- $x \in \mathbb{R}$ into $y, z \ge 0$ with the substitution rule $x = y - z$,
where T is the coefficient type of y - z.
Source node
FreeBridge supports:
Target nodes
FreeBridge creates:
- One variable node:
MOI.VectorOfVariablesinMOI.Nonnegatives
MathOptInterface.Bridges.Variable.HermitianToSymmetricPSDBridge — TypeHermitianToSymmetricPSDBridge{T} <: Bridges.Variable.AbstractBridgeHermitianToSymmetricPSDBridge implements the following reformulation:
- Hermitian positive semidefinite
n x ncomplex matrix to a symmetric positive semidefinite2n x 2nreal matrix satisfying equality constraints described below.
Source node
HermitianToSymmetricPSDBridge supports:
Target node
HermitianToSymmetricPSDBridge creates:
MOI.VectorOfVariablesinMOI.PositiveSemidefiniteConeTriangleMOI.ScalarAffineFunction{T}inMOI.EqualTo{T}
Reformulation
The reformulation is best described by example.
The Hermitian matrix:
\[\begin{bmatrix} x_{11} & x_{12} + y_{12}im & x_{13} + y_{13}im\\ x_{12} - y_{12}im & x_{22} & x_{23} + y_{23}im\\ x_{13} - y_{13}im & x_{23} - y_{23}im & x_{33} \end{bmatrix}\]
is positive semidefinite if and only if the symmetric matrix:
\[\begin{bmatrix} x_{11} & x_{12} & x_{13} & 0 & y_{12} & y_{13} \\ & x_{22} & x_{23} & -y_{12} & 0 & y_{23} \\ & & x_{33} & -y_{13} & -y_{23} & 0 \\ & & & x_{11} & x_{12} & x_{13} \\ & & & & x_{22} & x_{23} \\ & & & & & x_{33} \end{bmatrix}\]
is positive semidefinite.
The bridge achieves this reformulation by adding a new set of variables in MOI.PositiveSemidefiniteConeTriangle(6), and then adding three groups of equality constraints to:
- constrain the two
xblocks to be equal - force the diagonal of the
yblocks to be0 - force the lower triangular of the
yblock to be the negative of the upper triangle.
MathOptInterface.Bridges.Variable.NonposToNonnegBridge — TypeNonposToNonnegBridge{T} <: Bridges.Variable.AbstractBridgeNonposToNonnegBridge implements the following reformulation:
- $x \in \mathbb{R}_-$ into $y \in \mathbb{R}_+$ with the substitution rule $x = -y$,
where T is the coefficient type of -y.
Source node
NonposToNonnegBridge supports:
Target nodes
NonposToNonnegBridge creates:
- One variable node:
MOI.VectorOfVariablesinMOI.Nonnegatives,
MathOptInterface.Bridges.Variable.ParameterToEqualToBridge — TypeParameterToEqualToBridge{T} <: Bridges.Variable.AbstractBridgeParameterToEqualToBridge implements the following reformulation:
- $x \in Parameter(v)$ into $x == v$
Source node
ParameterToEqualToBridge supports:
Target nodes
ParameterToEqualToBridge creates:
- One variable node:
MOI.VariableIndexinMOI.EqualTo{T}
MathOptInterface.Bridges.Variable.RSOCtoPSDBridge — TypeRSOCtoPSDBridge{T} <: Bridges.Variable.AbstractBridgeRSOCtoPSDBridge implements the following reformulation:
- $||x||_2^2 \le 2tu$ where $t, u \ge 0$ into $Y \succeq 0$, with the substitution rule: $Y = \left[\begin{array}{c c}t & x^\top \\ x & 2u \mathbf{I}\end{array}\right].$
Additional bounds are added to ensure the off-diagonals of the $2uI$ submatrix are 0, and linear constraints are added to ensure the diagonal of $2uI$ takes the same values.
As a special case, if $|x|| = 0$, then RSOCtoPSDBridge reformulates into $(t, u) \in \mathbb{R}_+$.
Source node
RSOCtoPSDBridge supports:
Target nodes
RSOCtoPSDBridge creates:
- One variable node that depends on the input dimension:
MOI.VectorOfVariablesinMOI.Nonnegativesif dimension is1or2MOI.VectorOfVariablesin
MOI.PositiveSemidefiniteConeTriangleotherwise - The constraint node
MOI.VariableIndexinMOI.EqualTo - The constant node
MOI.ScalarAffineFunctioninMOI.EqualTo
MathOptInterface.Bridges.Variable.RSOCtoSOCBridge — TypeRSOCtoSOCBridge{T} <: Bridges.Variable.AbstractBridgeRSOCtoSOCBridge implements the following reformulation:
- $||x||_2^2 \le 2tu$ into $||v||_2 \le w$, with the substitution rules $t = \frac{w}{\sqrt 2} + \frac{v_1}{\sqrt 2}$, $u = \frac{w}{\sqrt 2} - \frac{v_1}{\sqrt 2}$, and $x = (v_2,\ldots,v_N)$.
Source node
RSOCtoSOCBridge supports:
Target node
RSOCtoSOCBridge creates:
MathOptInterface.Bridges.Variable.SOCtoRSOCBridge — TypeSOCtoRSOCBridge{T} <: Bridges.Variable.AbstractBridgeSOCtoRSOCBridge implements the following reformulation:
- $||x||_2 \le t$ into $2uv \ge ||w||_2^2$, with the substitution rules $t = \frac{u}{\sqrt 2} + \frac{v}{\sqrt 2}$, $x = (\frac{u}{\sqrt 2} - \frac{v}{\sqrt 2}, w)$.
Assumptions
SOCtoRSOCBridgeassumes that $|x| \ge 1$.
Source node
SOCtoRSOCBridge supports:
Target node
SOCtoRSOCBridge creates:
MathOptInterface.Bridges.Variable.SetMapBridge — Typeabstract type SetMapBridge{T,S1,S2} <: AbstractBridge endConsider two type of sets, S1 and S2, and a linear mapping A such that the image of a set of type S1 under A is a set of type S2.
A SetMapBridge{T,S1,S2} is a bridge that substitutes constrained variables in S2 into the image through A of constrained variables in S1.
The linear map A is described by:
Implementing a method for these two functions is sufficient to bridge constrained variables. However, in order for the getters and setters of attributes such as dual solutions and starting values to work as well, a method for the following functions must be implemented:
MOI.Bridges.inverse_map_setMOI.Bridges.inverse_map_functionMOI.Bridges.adjoint_map_functionMOI.Bridges.inverse_adjoint_map_function.
See the docstrings of each function to see which feature would be missing if it was not implemented for a given bridge.
Fieldnames
If S1 and S2 are [MOI.AbstractScalarSet], the struct must have fields:
variable::MOI.VariableIndexconstraint::MOI.ConstraintIndex{MOI.VariableIndex,S1}
If S1 and S2 are [MOI.AbstractVectorSet], the struct must have fields:
variable::Vector{MOI.VariableIndex}constraint::MOI.ConstraintIndex{MOI.VectorOfVariables,S1}
MathOptInterface.Bridges.Variable.VectorizeBridge — TypeVectorizeBridge{T,S} <: Bridges.Variable.AbstractBridgeVectorizeBridge implements the following reformulations:
- $x \ge a$ into $[y] \in \mathbb{R}_+$ with the substitution rule $x = a + y$
- $x \le a$ into $[y] \in \mathbb{R}_-$ with the substitution rule $x = a + y$
- $x == a$ into $[y] \in \{0\}$ with the substitution rule $x = a + y$
where T is the coefficient type of a + y.
Source node
VectorizeBridge supports:
MOI.VariableIndexinMOI.GreaterThan{T}MOI.VariableIndexinMOI.LessThan{T}MOI.VariableIndexinMOI.EqualTo{T}
Target nodes
VectorizeBridge creates:
- One variable node:
MOI.VectorOfVariablesinS, whereSis one ofMOI.Nonnegatives,MOI.Nonpositives,MOI.Zerosdepending on the type of $S$.
MathOptInterface.Bridges.Variable.ZerosBridge — TypeZerosBridge{T} <: Bridges.Variable.AbstractBridgeZerosBridge implements the following reformulation:
- $x \in \{0\}$ into the substitution rule $x = 0$,
where T is the coefficient type of 0.
Source node
ZerosBridge supports:
Target nodes
ZerosBridge does not create target nodes. It replaces all instances of x with 0 via substitution. This means that no variables are created in the underlying model.
Caveats
The bridged variables are similar to parameters with zero values. Parameters with non-zero values can be created with constrained variables in MOI.EqualTo by combining a VectorizeBridge and this bridge.
However, functions modified by ZerosBridge cannot be unbridged. That is, for a given function, we cannot determine if the bridged variables were used.
A related implication is that this bridge does not support MOI.ConstraintDual. However, if a MOI.Utilities.CachingOptimizer is used, the dual can be determined by the bridged optimizer using MOI.Utilities.get_fallback because the caching optimizer records the unbridged function.