Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ makedocs(;
"Complex-domain Optimization" => "complex-domain_optimization.md",
"Solvers" => "solvers.md",
"FAQ" => "faq.md",
"Optimizing in a Loop" => "loop.md",
"Advanced" => "advanced.md",
"Problem Depot" => "problem_depot.md",
"Contributing" => "contributing.md",
Expand Down
62 changes: 0 additions & 62 deletions docs/src/loop.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/src/problem_depot.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ The problems are organized into folders in `src/problem_depot/problems`. Each is
end
```

The `@add_problem` call adds the problem to the registry of problems in [`Convex.ProblemDepot.PROBLEMS`](@ref), which in turn is used by [`run_tests`](@ref) and [`benchmark_suite`](@ref). Next, `affine` is the grouping of the problem; this problem came from one of the affine tests, and in particular is testing the negation atom. Next is the function signature:
The `@add_problem` call adds the problem to the registry of problems in [`Convex.ProblemDepot.PROBLEMS`](@ref), which in turn is used by [`Convex.ProblemDepot.run_tests`](@ref) and [`Convex.ProblemDepot.benchmark_suite`](@ref). Next, `affine` is the grouping of the problem; this problem came from one of the affine tests, and in particular is testing the negation atom. Next is the function signature:

```julia
function affine_negate_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
```

this should be the same for every problem, except for the name, which is a description of the problem. It should include what kind of atoms it uses (`affine` in this case), so that certain kinds of atoms can be ruled out by the `exclude` keyword to [`run_tests`](@ref) and [`benchmark_suite`](@ref); for example, many solvers cannot solve mixed-integer problems, so `mip` is included in the name of such problems.
this should be the same for every problem, except for the name, which is a description of the problem. It should include what kind of atoms it uses (`affine` in this case), so that certain kinds of atoms can be ruled out by the `exclude` keyword to [`Convex.ProblemDepot.run_tests`](@ref) and [`Convex.ProblemDepot.benchmark_suite`](@ref); for example, many solvers cannot solve mixed-integer problems, so `mip` is included in the name of such problems.

Then begins the body of the problem. It is setup like any other Convex.jl problem, only `handle_problem!` is called instead of `solve!`. This allows particular solvers to be used (via e.g. choosing `handle_problem! = p -> solve!(p, solver)`), or for any other function of the problem (e.g. `handle_problem! = p -> Convex.conic_problem(p)` which is used for benchmarking problem formulation speed.) Tests should be included and gated behind `if test` blocks, so that tests can be skipped for benchmarking, or in the case that the problem is not in fact solved during `handle_problem!`.

Expand Down
4 changes: 2 additions & 2 deletions src/atoms/affine/add_subtract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end

-(x::AbstractExpr) = NegateAtom(x)

function conic_form!(x::NegateAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::NegateAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
objective = conic_form!(x.children[1], unique_conic_forms)
objective = -objective
Expand Down Expand Up @@ -102,7 +102,7 @@ function evaluate(x::AdditionAtom)
return mapreduce(evaluate, (a, b) -> a .+ b, x.children)
end

function conic_form!(x::AdditionAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::AdditionAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
objective = ConicObj()
for child in x.children
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/affine/conjugate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function evaluate(x::ConjugateAtom)
return conj(evaluate(x.children[1]))
end

function conic_form!(x::ConjugateAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::ConjugateAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
objective = conic_form!(x.children[1], unique_conic_forms)
for var in keys(objective)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/affine/diag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ diag(x::AbstractExpr, k::Int=0) = DiagAtom(x, k)
# 3. We populate coeff with 1s at the correct indices
# The canonical form will then be:
# coeff * x - d = 0
function conic_form!(x::DiagAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::DiagAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
(num_rows, num_cols) = x.children[1].size
k = x.k
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/affine/diagm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function diagm((d, x)::Pair{<:Integer, <:AbstractExpr})
end
Diagonal(x::AbstractExpr) = DiagMatrixAtom(x)

function conic_form!(x::DiagMatrixAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::DiagMatrixAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
sz = x.size[1]

Expand Down
2 changes: 1 addition & 1 deletion src/atoms/affine/index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function evaluate(x::IndexAtom)
end
end

function conic_form!(x::IndexAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::IndexAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
m = length(x)
n = length(x.children[1])
Expand Down
4 changes: 2 additions & 2 deletions src/atoms/affine/multiply_divide.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function evaluate(x::MultiplyAtom)
return evaluate(x.children[1]) * evaluate(x.children[2])
end

function conic_form!(x::MultiplyAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::MultiplyAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
# scalar multiplication
if x.children[1].size == (1, 1) || x.children[2].size == (1, 1)
Expand Down Expand Up @@ -145,7 +145,7 @@ function evaluate(x::DotMultiplyAtom)
return evaluate(x.children[1]) .* evaluate(x.children[2])
end

function conic_form!(x::DotMultiplyAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::DotMultiplyAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
if vexity(x.children[1]) != ConstVexity()
if vexity(x.children[2]) != ConstVexity()
Expand Down
4 changes: 1 addition & 3 deletions src/atoms/affine/partialtranspose.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end
# borrowing this from transpose.jl:
# Since everything is vectorized, we simply need to multiply x by a permutation
# matrix such that coeff * vectorized(x) - vectorized(x') = 0
function conic_form!(x::PartialTransposeAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::PartialTransposeAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
objective = conic_form!(x.children[1], unique_conic_forms)

Expand All @@ -104,5 +104,3 @@ function conic_form!(x::PartialTransposeAtom, unique_conic_forms::UniqueConicFor
end

partialtranspose(x::AbstractExpr,sys::Int, dim::Vector) = PartialTransposeAtom(x,sys,dim)


4 changes: 2 additions & 2 deletions src/atoms/affine/real_imag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function evaluate(x::RealAtom)
return real.(evaluate(x.children[1]))
end

function conic_form!(x::RealAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::RealAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
new_objective = ConicObj()
objective = conic_form!(x.children[1], unique_conic_forms)
Expand Down Expand Up @@ -93,7 +93,7 @@ function evaluate(x::ImaginaryAtom)
return imag.(evaluate(x.children[1]))
end

function conic_form!(x::ImaginaryAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::ImaginaryAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
new_objective = ConicObj()
objective = conic_form!(x.children[1], unique_conic_forms)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/affine/reshape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function evaluate(x::ReshapeAtom)
return reshape(evaluate(x.children[1]), x.size[1], x.size[2])
end

function conic_form!(x::ReshapeAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::ReshapeAtom, unique_conic_forms::UniqueConicForms)
return conic_form!(x.children[1], unique_conic_forms)
end

Expand Down
4 changes: 2 additions & 2 deletions src/atoms/affine/stack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function evaluate(x::HcatAtom)
end


function conic_form!(x::HcatAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::HcatAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
# build a list of child conic objectives and constraints
objectives = ConicObj[]
Expand Down Expand Up @@ -130,4 +130,4 @@ function hvcat(rows::Tuple{Vararg{Int}}, args::AbstractExprOrValue...)
a += rows[i]
end
return vcat(rs...)
end
end
2 changes: 1 addition & 1 deletion src/atoms/affine/sum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end
# Suppose x was of the form
# x = Ay where A was a coefficient. Then sum(x) can also be considered
# sum(A, 1) * y
function conic_form!(x::SumAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::SumAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
objective = conic_form!(x.children[1], unique_conic_forms)
new_obj = copy(objective)
Expand Down
4 changes: 2 additions & 2 deletions src/atoms/affine/transpose.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ end

# Since everything is vectorized, we simply need to multiply x by a permutation
# matrix such that coeff * vectorized(x) - vectorized(x') = 0
function conic_form!(x::TransposeAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::TransposeAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
objective = conic_form!(x.children[1], unique_conic_forms)

Expand Down Expand Up @@ -102,7 +102,7 @@ end

# Since everything is vectorized, we simply need to multiply x by a permutation
# matrix such that coeff * vectorized(x) - vectorized(x') = 0
function conic_form!(x::AdjointAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::AdjointAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
objective = conic_form!(x.children[1], unique_conic_forms)

Expand Down
2 changes: 1 addition & 1 deletion src/atoms/exp_+_sdp_cone/logdet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function evaluate(x::LogDetAtom)
return log(det(evaluate(x.children[1])))
end

function conic_form!(x::LogDetAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::LogDetAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
A = x.children[1]
D = Variable(size(A)) # diagonal matrix
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/exp_cone/entropy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function evaluate(x::EntropyAtom)
return -c .* log.(c)
end

function conic_form!(e::EntropyAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(e::EntropyAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, e)
# -x log x >= t <=> x exp(t/x) <= 1 <==> (t,x,1) in exp cone
t = Variable(e.size)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/exp_cone/exp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end

exp(x::AbstractExpr) = ExpAtom(x)

function conic_form!(e::ExpAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(e::ExpAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, e)
# exp(x) \leq z <=> (x,ones(),z) \in ExpCone
x = e.children[1]
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/exp_cone/log.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end

log(x::AbstractExpr) = LogAtom(x)

function conic_form!(e::LogAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(e::LogAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, e)
# log(z) \geq x <=> (x,ones(),z) \in ExpCone
z = e.children[1]
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/exp_cone/logsumexp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end

logsumexp(x::AbstractExpr) = LogSumExpAtom(x)

function conic_form!(e::LogSumExpAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(e::LogSumExpAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, e)
# log(sum(exp(x))) <= t <=> sum(exp(x)) <= exp(t) <=> sum(exp(x - t)) <= 1
t = Variable(e.size)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/exp_cone/relative_entropy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function evaluate(e::RelativeEntropyAtom)
return out
end

function conic_form!(e::RelativeEntropyAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(e::RelativeEntropyAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, e)
# transform to conic form:
# x log x/y <= z
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/lp_cone/abs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function evaluate(x::AbsAtom)
return abs.(evaluate(x.children[1]))
end

function conic_form!(x::AbsAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::AbsAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
c = x.children[1]
t = Variable(size(c))
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/lp_cone/dotsort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function evaluate(x::DotSortAtom)
return sum(sort(vec(evaluate(x.children[1])), rev=true) .* sort(vec(x.w), rev=true))
end

function conic_form!(x::DotSortAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::DotSortAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
y = x.children[1]
w = x.w
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/lp_cone/max.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function evaluate(x::MaxAtom)
end

# x <= this and y <= this if max(x, y) = this
function conic_form!(x::MaxAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::MaxAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
this = Variable(x.size[1], x.size[2])
objective = conic_form!(this, unique_conic_forms)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/lp_cone/maximum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end

# x <= this if maximum(x) = this
# so, this - x will be in the :NonNeg cone
function conic_form!(x::MaximumAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::MaximumAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
this = Variable()
objective = conic_form!(this, unique_conic_forms)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/lp_cone/min.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function evaluate(x::MinAtom)
end

# x >= this and y >= this if min(x, y) = this
function conic_form!(x::MinAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::MinAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
this = Variable(x.size[1], x.size[2])
objective = conic_form!(this, unique_conic_forms)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/lp_cone/minimum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end

# x >= this if minimum(x) = this
# so, x - this will be in the :NonNeg cone
function conic_form!(x::MinimumAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::MinimumAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
this = Variable()
objective = conic_form!(this, unique_conic_forms)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/lp_cone/sumlargest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function evaluate(x::SumLargestAtom)
return sum(sort(vec(evaluate(x.children[1])), rev=true)[1:x.k])
end

function conic_form!(x::SumLargestAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::SumLargestAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
c = x.children[1]
t = Variable(size(c))
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/sdp_cone/matrixfrac.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ matrixfrac(x::AbstractExpr, P::AbstractExpr) = MatrixFracAtom(x, P)
matrixfrac(x::Value, P::AbstractExpr) = MatrixFracAtom(Constant(x), P)
matrixfrac(x::AbstractExpr, P::Value) = MatrixFracAtom(x, Constant(P))

function conic_form!(m::MatrixFracAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(m::MatrixFracAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, m)
x = m.children[1]
P = m.children[2]
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/second_order_cone/geomean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function evaluate(q::GeoMeanAtom)
return sqrt.(evaluate(q.children[1]) .* evaluate(q.children[2]))
end

function conic_form!(q::GeoMeanAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(q::GeoMeanAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, q)
sz = q.children[1].size
t = Variable(sz[1], sz[2])
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/second_order_cone/huber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function evaluate(x::HuberAtom)
return c
end

function conic_form!(x::HuberAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::HuberAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
c = x.children[1]
s = Variable(c.size)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/second_order_cone/norm2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end

## Create a new variable euc_norm to represent the norm
## Additionally, create the second order conic constraint (euc_norm, x) in SOC
function conic_form!(x::EucNormAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
function conic_form!(x::EucNormAtom, unique_conic_forms::UniqueConicForms)
if !has_conic_form(unique_conic_forms, x)
euc_norm = Variable()
objective = conic_form!(euc_norm, unique_conic_forms)
Expand Down
Loading