Skip to content

Commit 4b1052e

Browse files
authored
Discuss extended formulations in docs (#396)
* Discuss extended formulations in docs * hardwrap and format
1 parent dd2f6c9 commit 4b1052e

File tree

1 file changed

+67
-8
lines changed

1 file changed

+67
-8
lines changed

docs/src/index.md

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,85 @@ Convex.jl - Convex Optimization in Julia
33

44
Convex.jl is a Julia package for [Disciplined Convex
55
Programming](http://dcp.stanford.edu/) (DCP). Convex.jl makes it easy to
6-
describe optimization problems in a natural, mathematical syntax, and to
7-
solve those problems using a variety of different (commercial and
8-
open-source) solvers. Convex.jl can solve
6+
describe optimization problems in a natural, mathematical syntax, and to solve
7+
those problems using a variety of different (commercial and open-source)
8+
solvers. Convex.jl can solve
99

1010
- linear programs
11-
- mixed-integer linear programs and mixed-integer second-order cone
12-
programs
11+
- mixed-integer linear programs and mixed-integer second-order cone programs
1312
- dcp-compliant convex programs including
1413
- second-order cone programs (SOCP)
1514
- exponential cone programs
1615
- semidefinite programs (SDP)
1716

1817
Convex.jl supports many solvers, including
18+
[COSMO](https://github.com/oxfordcontrol/COSMO.jl),
1919
[Mosek](https://github.com/JuliaOpt/Mosek.jl),
2020
[Gurobi](https://github.com/JuliaOpt/gurobi.jl),
2121
[ECOS](https://github.com/JuliaOpt/ECOS.jl),
2222
[SCS](https://github.com/karanveerm/SCS.jl) and
2323
[GLPK](https://github.com/JuliaOpt/GLPK.jl), through
2424
[MathOptInterface](https://github.com/JuliaOpt/MathOptInterface.jl).
2525

26-
Note that Convex.jl was previously called CVX.jl. This package is under
27-
active development; we welcome bug reports and feature requests. For
28-
usage questions, please contact us via the [Julia Discourse](https://discourse.julialang.org/c/domain/opt).
26+
Note that Convex.jl was previously called CVX.jl. This package is under active
27+
development; we welcome bug reports and feature requests. For usage questions,
28+
please contact us via the [Julia
29+
Discourse](https://discourse.julialang.org/c/domain/opt).
30+
31+
## Extended formulations and the DCP ruleset
32+
33+
Convex.jl works by transforming the problem—which possibly has nonsmooth,
34+
nonlinear constructions like the nuclear norm, the log determinant, and so
35+
forth—into a linear optimization problem subject to conic constraints. This
36+
reformulation often involves adding auxiliary variables, and is called an
37+
"extended formulation", since the original problem has been extended with
38+
additional variables. These formulations rely on the problem being modelled by
39+
combining Convex.jl's "atoms" or primitives according to certain rules which
40+
ensure convexity, called the [disciplined convex programming (DCP)
41+
ruleset](http://cvxr.com/cvx/doc/dcp.html). If these atoms are combined in a way
42+
that does not ensure convexity, the extended formulations are often invalid. As
43+
a simple example, consider the problem
44+
45+
```julia
46+
minimize( abs(x), x >= 1, x <= 2)
47+
```
48+
49+
Obviously, the optimum occurs at `x=1`, but let us imagine we want to solve this
50+
problem via Convex.jl using a linear programming (LP) solver. Since `abs` is a
51+
nonlinear function, we need to reformulate the problem to pass it to the LP
52+
solver. We do this by introducing an auxiliary variable `t` and instead solving
53+
54+
```julia
55+
minimize(t, x >= 1, x <= 2, t >= x, t >= -x)
56+
```
57+
58+
That is, we add the constraints `t >= x` and `t >= -x`, and replace `abs(x)` by
59+
`t`. Since we are minimizing over `t` and the smallest possible `t` satisfying
60+
these constraints is the absolute value of `x`, we get the right answer. That
61+
is, this reformulation worked because we were minimizing `abs(x)`, and that is a
62+
valid way to use the primitive `abs`.
63+
64+
If we were maximizing `abs`, Convex.jl would print
65+
66+
> Warning: Problem not DCP compliant: objective is not DCP
67+
68+
Why? Well, let us consider the same reformulation for a maximization problem.
69+
The original problem is now
70+
71+
```julia
72+
maximize( abs(x), x >= 1, x <= 2)
73+
```
74+
75+
and trivially the optimum is 2, obtained at `x=2`. If we do the same
76+
replacements as above, however, we arrive at the problem
77+
78+
```julia
79+
maximize(t, x >= 1, x <= 2, t >= x, t >= -x)
80+
```
81+
82+
whose solution is infinity. In other words, we got the wrong answer by using the
83+
reformulation, since the extended formulation was only valid for a minimization
84+
problem. Convex.jl always performs these reformulations, but they are only
85+
guaranteed to be valid when the DCP ruleset is followed. Therefore, Convex.jl
86+
programatically checks the whether or not these rules were satisfied and warns
87+
if they were not. One should not take these DCP warnings lightly!

0 commit comments

Comments
 (0)