Skip to content

Commit

Permalink
Merge pull request #357 from JuliaOpt/rearrange
Browse files Browse the repository at this point in the history
Rearrange exports; deprecate `lambdamin`, `lambdamax`
  • Loading branch information
ericphanson committed Jan 13, 2020
2 parents 8bf8b53 + f93e340 commit 9578b9c
Show file tree
Hide file tree
Showing 70 changed files with 80 additions and 170 deletions.
2 changes: 1 addition & 1 deletion docs/examples_literate/general_examples/basic_usage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ x.value


y = Semidefinite(2)
p = maximize(lambdamin(y), tr(y)<=6)
p = maximize(eigmin(y), tr(y)<=6)
solve!(p, SCS.Optimizer(verbose=0))
p.optval

Expand Down
3 changes: 1 addition & 2 deletions docs/examples_literate/mixed_integer/aux_files/antidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
# All expressions and atoms are subtpyes of AbstractExpr.
# Please read expressions.jl first.
#############################################################################

import Convex.sign, Convex.monotonicity, Convex.curvature, Convex.evaluate, Convex.conic_form!
export antidiag, sign, monotonicity, curvature, evaluate, conic_form!
export antidiag

### Diagonal
### Represents the kth diagonal of an mxn matrix as a (min(m, n) - k) x 1 vector
Expand Down
4 changes: 2 additions & 2 deletions docs/src/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ solver (including SCS and Mosek).
| ------------------ | --------------------------------- | ------- | ------------- | ------------------------------ |
| `nuclearnorm(x)` | sum of singular values of $x$ | convex | not monotonic | none |
| `operatornorm(x)` | max of singular values of $x$ | convex | not monotonic | none |
| `lambdamax(x)` | max eigenvalue of $x$ | convex | not monotonic | none |
| `lambdamin(x)` | min eigenvalue of $x$ | concave | not monotonic | none |
| `eigmax(x)` | max eigenvalue of $x$ | convex | not monotonic | none |
| `eigmin(x)` | min eigenvalue of $x$ | concave | not monotonic | none |
| `matrixfrac(x, P)` | $x^TP^{-1}x$ | convex | not monotonic | IC: P is positive semidefinite |

Exponential + SDP representable Functions
Expand Down
30 changes: 28 additions & 2 deletions src/Convex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,36 @@ module Convex
using OrderedCollections: OrderedDict
using LinearAlgebra
using SparseArrays
using AbstractTrees: AbstractTrees

using MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities
const MOIB = MOI.Bridges

global DEFAULT_SOLVER = nothing
# Functions
export conv, dotsort, entropy, exp, geomean, hinge_loss, huber, inner_product, invpos
export log_perspective, logisticloss, logsumexp, matrixfrac, neg, norm2, norm_1, norm_inf, nuclearnorm
export partialtrace, partialtranspose, pos, qol_elementwise, quadform, quadoverlin, rationalnorm
export relative_entropy, scaledgeomean, sigmamax, square, sumlargest, sumlargesteigs, sumsmallest, sumsquares

# rexports from LinearAlgebra
export diag, diagm, Diagonal, dot, eigmax, eigmin, kron, logdet, norm, tr

# Constraints
export isposdef, , # PSD constraints
export socp

# Variables
export Constant, ComplexVariable, HermitianSemidefinite, Semidefinite, Variable
export curvature, evaluate, fix!, free!, monotonicity, sign, vexity

# Signs
export Positive, Negative, ComplexSign, NoSign

# Problems
export add_constraint!, add_constraints!, maximize, minimize, Problem, satisfy, solve!

### modeling framework
include("dcp.jl")
include("expressions.jl")
Expand Down Expand Up @@ -71,7 +94,7 @@ include("atoms/second_order_cone/huber.jl")
### SDP atoms
include("atoms/sdp_cone/nuclearnorm.jl")
include("atoms/sdp_cone/operatornorm.jl")
include("atoms/sdp_cone/lambda_min_max.jl")
include("atoms/sdp_cone/eig_min_max.jl")
include("atoms/sdp_cone/matrixfrac.jl")
include("atoms/sdp_cone/sumlargesteigs.jl")

Expand All @@ -98,4 +121,7 @@ function clearmemory()
Base.depwarn("Convex.clearmemory() is deprecated, as the memory leak it works around has been closed (in https://github.com/JuliaOpt/Convex.jl/pull/322). This function no longer does anything and will be removed in a future Convex.jl release.", :clearmemory )
end

@deprecate lambdamin eigmin
@deprecate lambdamax eigmax

end
3 changes: 0 additions & 3 deletions src/atoms/affine/add_subtract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
# Please read expressions.jl first.
#############################################################################

export +, -
export sign, curvature, monotonicity, evaluate

### Unary Negation

struct NegateAtom <: AbstractExpr
Expand Down
2 changes: 0 additions & 2 deletions src/atoms/affine/conjugate.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Base.conj
export conj
export sign, curvature, monotonicity, evaluate, conic_form!
struct ConjugateAtom <: AbstractExpr
head::Symbol
id_hash::UInt64
Expand Down
2 changes: 0 additions & 2 deletions src/atoms/affine/conv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Handles convolution between a constant vector and an expression vector.
#############################################################################

export conv

function conv(x::Value, y::AbstractExpr)
if (size(x,2) != 1 && length(size(x)) != 1) || size(y,2) != 1
error("convolution only supported between two vectors")
Expand Down
2 changes: 0 additions & 2 deletions src/atoms/affine/diag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

# k >= min(num_cols, num_rows) || k <= -min(num_rows, num_cols)
import LinearAlgebra.diag
export diag
#export sign, curvature, monotonicity, evaluate

### Diagonal
### Represents the kth diagonal of an mxn matrix as a (min(m, n) - k) x 1 vector
Expand Down
1 change: 0 additions & 1 deletion src/atoms/affine/diagm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#############################################################################

import LinearAlgebra.diagm, LinearAlgebra.Diagonal
export diagm, Diagonal

struct DiagMatrixAtom <: AbstractExpr
head::Symbol
Expand Down
1 change: 0 additions & 1 deletion src/atoms/affine/dot.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import LinearAlgebra.dot
export dot

ismatrix(x::AbstractExpr) = (s = size(x); length(s) == 2 && s[1] > 1 && s[2] > 1)
ismatrix(::AbstractMatrix) = true
Expand Down
3 changes: 1 addition & 2 deletions src/atoms/affine/index.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Base: getindex, to_index
export IndexAtom, getindex
import Base.getindex

const ArrayOrNothing = Union{AbstractArray, Nothing}

Expand Down
2 changes: 0 additions & 2 deletions src/atoms/affine/inner_product.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export inner_product

function inner_product(x::AbstractExpr, y::AbstractExpr)
if x.size == y.size && x.size[1] == x.size[2]
return real(tr(x'*y))
Expand Down
1 change: 0 additions & 1 deletion src/atoms/affine/kron.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import LinearAlgebra.kron
export kron

function kron(a::Value, b::AbstractExpr)
rows = AbstractExpr[]
Expand Down
1 change: 0 additions & 1 deletion src/atoms/affine/multiply_divide.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#############################################################################

import Base.Broadcast.broadcasted
export sign, monotonicity, curvature, evaluate, conic_form!

### Scalar and matrix multiplication

Expand Down
3 changes: 1 addition & 2 deletions src/atoms/affine/partialtrace.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export partialtrace

# We compute the partial trace of x by summing over
# (I ⊗ <j| ⊗ I) x (I ⊗ |j> ⊗ I) for all j's
Expand Down Expand Up @@ -40,4 +39,4 @@ function partialtrace(x, sys::Int, dims::Vector)
end

return sum(j -> _term(x, j, sys, dims), 1:dims[sys])
end
end
2 changes: 0 additions & 2 deletions src/atoms/affine/partialtranspose.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Base.sign
export partialtranspose, PartialTransposeAtom
export sign, curvature, monotonicity, evaluate, conic_form!

struct PartialTransposeAtom <: AbstractExpr
head::Symbol
Expand Down
3 changes: 0 additions & 3 deletions src/atoms/affine/real_imag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#############################################################################

import Base.real, Base.imag
export real, imag
export sign, monotonicity, curvature, evaluate


### Real
struct RealAtom <: AbstractExpr
Expand Down
3 changes: 0 additions & 3 deletions src/atoms/affine/reshape.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import Base.reshape, Base.vec
export reshape, vec
export sign, curvature, monotonicity, evaluate, conic_form!


struct ReshapeAtom <: AbstractExpr
head::Symbol
Expand Down
3 changes: 0 additions & 3 deletions src/atoms/affine/stack.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import Base.vcat, Base.hcat, Base.hvcat
export vcat, hcat, hvcat, HcatAtom
export sign, curvature, monotonicity, evaluate, conic_form!

struct HcatAtom <: AbstractExpr
head::Symbol
id_hash::UInt64
Expand Down
2 changes: 0 additions & 2 deletions src/atoms/affine/sum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# All expressions and atoms are subtpyes of AbstractExpr.
# Please read expressions.jl first.
#############################################################################

import Base.sum
export sum

### Sum Atom
struct SumAtom <: AbstractExpr
Expand Down
1 change: 0 additions & 1 deletion src/atoms/affine/trace.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import LinearAlgebra.tr
export tr

function tr(e::AbstractExpr)
return sum(diag(e))
Expand Down
2 changes: 0 additions & 2 deletions src/atoms/affine/transpose.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#############################################################################

import Base.transpose, Base.adjoint
export transpose, adjoint, TransposeAtom, AdjointAtom
export sign, curvature, monotonicity, evaluate, conic_form!

struct TransposeAtom <: AbstractExpr
head::Symbol
Expand Down
1 change: 0 additions & 1 deletion src/atoms/exp_+_sdp_cone/logdet.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import LinearAlgebra.logdet
export logdet

struct LogDetAtom <: AbstractExpr
head::Symbol
Expand Down
3 changes: 0 additions & 3 deletions src/atoms/exp_cone/entropy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# Please read expressions.jl first.
#############################################################################

export entropy
export sign, curvature, monotonicity, evaluate

### Entropy: sum_i -x_i log (x_i)

# TODO: make this work for a *list* of inputs, rather than just for scalar/vector/matrix inputs
Expand Down
3 changes: 0 additions & 3 deletions src/atoms/exp_cone/exp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
# All expressions and atoms are subtpyes of AbstractExpr.
# Please read expressions.jl first.
#############################################################################

import Base.exp
export exp
export sign, curvature, monotonicity, evaluate

### Exponential

Expand Down
3 changes: 0 additions & 3 deletions src/atoms/exp_cone/log.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
# All expressions and atoms are subtpyes of AbstractExpr.
# Please read expressions.jl first.
#############################################################################

import Base.log
export log
export sign, curvature, monotonicity, evaluate

### Logarithm

Expand Down
3 changes: 0 additions & 3 deletions src/atoms/exp_cone/logsumexp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# Please read expressions.jl first.
#############################################################################

export logsumexp, logisticloss
export sign, curvature, monotonicity, evaluate

### LogSumExp

# TODO: make this work for a *list* of inputs, rather than just for vector/matrix inputs
Expand Down
3 changes: 0 additions & 3 deletions src/atoms/exp_cone/relative_entropy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# Please read expressions.jl first.
#############################################################################

export relative_entropy, log_perspective
export sign, curvature, monotonicity, evaluate

# TODO: make this work for a *list* of inputs, rather than just for scalar/vector/matrix inputs

struct RelativeEntropyAtom <: AbstractExpr
Expand Down
3 changes: 0 additions & 3 deletions src/atoms/lp_cone/abs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
# All expressions and atoms are subtpyes of AbstractExpr.
# Please read expressions.jl first.
#############################################################################

import Base.abs, Base.abs2
export abs, abs2
export sign, curvature, monotonicity, evaluate

### Absolute Value

Expand Down
3 changes: 0 additions & 3 deletions src/atoms/lp_cone/dotsort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# Please read expressions.jl first.
#############################################################################

export dotsort
export sign, curvature, monotonicity, evaluate

# This atom computes dot(sort(x), sort(w)), where w is constant
# for example, if w = [1 1 1 0 0 0 ... 0], it computes the sum of the 3 largest elements of x
struct DotSortAtom <: AbstractExpr
Expand Down
1 change: 0 additions & 1 deletion src/atoms/lp_cone/max.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Please read expressions.jl first.
#############################################################################
import Base.max
export max, pos, hinge_loss

# TODO: This can easily be extended to work
### Max Atom
Expand Down
1 change: 0 additions & 1 deletion src/atoms/lp_cone/maximum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Please read expressions.jl first.
#############################################################################
import Base.maximum
export maximum

### Maximum Atom
struct MaximumAtom <: AbstractExpr
Expand Down
1 change: 0 additions & 1 deletion src/atoms/lp_cone/min.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Please read expressions.jl first.
#############################################################################
import Base.min
export min, neg

# TODO: This can easily be extended to work
### Min Atom
Expand Down
1 change: 0 additions & 1 deletion src/atoms/lp_cone/minimum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Please read expressions.jl first.
#############################################################################
import Base.minimum
export minimum

### Minimum Atom
struct MinimumAtom <: AbstractExpr
Expand Down
3 changes: 0 additions & 3 deletions src/atoms/lp_cone/sumlargest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# Please read expressions.jl first.
#############################################################################

export sumlargest, sumsmallest
export sign, curvature, monotonicity, evaluate

struct SumLargestAtom <: AbstractExpr
head::Symbol
id_hash::UInt64
Expand Down
Loading

0 comments on commit 9578b9c

Please sign in to comment.