Skip to content

Commit c17b411

Browse files
ericphansonblegatodow
authored
Add dualization example (#652)
* Add dualization example * add Random * add compat * format * Update docs/src/examples/general_examples/dualization.jl Co-authored-by: Benoît Legat <[email protected]> * update vale for dualize * typos * Update docs/src/examples/general_examples/dualization.jl --------- Co-authored-by: Benoît Legat <[email protected]> Co-authored-by: Oscar Dowson <[email protected]>
1 parent 379f7e7 commit c17b411

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
55
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
66
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
77
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
8+
Dualization = "191a621a-6537-11e9-281d-650236a99e60"
89
ECOS = "e2685f51-7e38-5353-a97d-a921fd2c8199"
910
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
1011
Interact = "c601a237-2ae4-5e1e-952c-7a85b0c7eef1"
@@ -23,6 +24,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2324
DataFrames = "1"
2425
Distributions = "0.25"
2526
Documenter = "0.27"
27+
Dualization = "0.5.8"
2628
ECOS = "1"
2729
GLPK = "1"
2830
Interact = "0.10"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# # Dualization
2+
3+
# Sometimes it can be much faster to solve the dual problem than the primal problem.
4+
# Some solvers will automatically dualize the problem when heuristics deem it beneficial,
5+
# and alternative DCP modeling languages like CVX will also automatically dualize the
6+
# problem in some cases.
7+
# Convex.jl does not automatically dualize any problem, but it is easy to manually do so
8+
# with Dualization.jl.
9+
# Here, we will solve a simple semidefinite program (from [issue #492](https://github.com/jump-dev/Convex.jl/issues/492)) to show how easy it is to dualize the problem,
10+
# and that it can potentially provide speed ups.
11+
12+
# First we load our packages:
13+
using LinearAlgebra
14+
using Convex
15+
using SCS
16+
using Random
17+
using Dualization
18+
19+
# Then we setup some test data.
20+
Random.seed!(2022)
21+
p = 50
22+
Σ = Symmetric(randn(p, p))
23+
Σ = Σ * Σ'
24+
25+
# Now we formulate and solve our primal problem:
26+
d = Variable(p)
27+
problem = maximize(sum(d), 0 d, d 1, Σ Diagonal(d))
28+
@elapsed solve!(problem, SCS.Optimizer; silent_solver = true)
29+
30+
# To solve the dual problem instead, we simply call `dual_optimizer` on our
31+
# optimizer function:
32+
@elapsed solve!(problem, dual_optimizer(SCS.Optimizer); silent_solver = true)

docs/styles/config/vocabularies/jump-dev/accept.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ autoregressive
22
bijective
33
[Bb]ugfix
44
docstring
5+
[Dd]ualize
6+
[Dd]ualization
57
[Ee]lementwise
68
[Ee]num
79
injective

0 commit comments

Comments
 (0)