Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed May 2, 2024
1 parent 904a1e6 commit d991267
Show file tree
Hide file tree
Showing 13 changed files with 400 additions and 309 deletions.
2 changes: 2 additions & 0 deletions src/Convex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ for (root, _, files) in walkdir(joinpath(@__DIR__, "atoms"))
end
end

include("supported_operations.jl")

for (root, _, files) in walkdir(joinpath(@__DIR__, "reformulations"))
for file in files
include(joinpath(root, file))
Expand Down
45 changes: 0 additions & 45 deletions src/atoms/AbsAtom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,6 @@ mutable struct AbsAtom <: AbstractExpr
AbsAtom(x::AbstractExpr) = new((x,), x.size)
end

"""
Base.abs(x::Convex.AbstractExpr)
The epigraph of \$|x|\$.
## Examples
Applies to a single expression:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable()
Variable
size: (1, 1)
sign: real
vexity: affine
id: 103…720
julia> abs(x)
abs (convex; positive)
└─ real variable (id: 103…720)
```
And element-wise to a matrix of expressions:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable(3)
Variable
size: (3, 1)
sign: real
vexity: affine
id: 389…882
julia> abs(x)
abs (convex; positive)
└─ 3-element real variable (id: 389…882)
```
## DCP properties
| Sign | Monotonicity | Curvature |
| :--- | :----------- | :-------- |
| Positive | depends on the sign of \$x\$ | Convex |
"""
Base.abs(x::AbstractExpr) = AbsAtom(x)

head(io::IO, ::AbsAtom) = print(io, "abs")

Base.sign(::AbsAtom) = Positive()
Expand Down
45 changes: 0 additions & 45 deletions src/atoms/ExpAtom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,6 @@ mutable struct ExpAtom <: AbstractExpr
end
end

"""
Base.exp(x::Convex.AbstractExpr)
The epigraph of \$e^x\$.
## Examples
Applies to a single expression:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable()
Variable
size: (1, 1)
sign: real
vexity: affine
id: 103…720
julia> exp(x)
exp (convex; positive)
└─ real variable (id: 103…720)
```
And element-wise to a matrix of expressions:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable(3)
Variable
size: (3, 1)
sign: real
vexity: affine
id: 389…882
julia> exp(x)
exp (convex; positive)
└─ 3-element real variable (id: 389…882)
```
## DCP properties
| Sign | Monotonicity | Curvature |
| :--- | :----------- | :-------- |
| Positive | Nondecreasing | Convex |
"""
Base.exp(x::AbstractExpr) = ExpAtom(x)

head(io::IO, ::ExpAtom) = print(io, "exp")

Base.sign(::ExpAtom) = Positive()
Expand Down
45 changes: 0 additions & 45 deletions src/atoms/LogAtom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,6 @@ mutable struct LogAtom <: AbstractExpr
end
end

"""
Base.log(x::Convex.AbstractExpr)
The hypograph of \$\\log(x)\$.
## Examples
Applies to a single expression:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable()
Variable
size: (1, 1)
sign: real
vexity: affine
id: 103…720
julia> log(x)
log (concave; real)
└─ real variable (id: 103…720)
```
And element-wise to a matrix of expressions:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable(3)
Variable
size: (3, 1)
sign: real
vexity: affine
id: 161…499
julia> log(x)
log (concave; real)
└─ 3-element real variable (id: 161…499)
```
## DCP properties
| Sign | Monotonicity | Curvature |
| :--- | :----------- | :-------- |
| None | Nondecreasing | Concave |
"""
Base.log(x::AbstractExpr) = LogAtom(x)

head(io::IO, ::LogAtom) = print(io, "log")

Base.sign(::LogAtom) = NoSign()
Expand Down
30 changes: 0 additions & 30 deletions src/atoms/LogSumExpAtom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,6 @@ mutable struct LogSumExpAtom <: AbstractExpr
end
end

"""
logsumexp(x::Convex.AbstractExpr)
The epigraph of \$\\log\\left(\\sum_i e^{x_i}\\right)\$.
## Examples
Applies to a single expression:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable(3)
Variable
size: (3, 1)
sign: real
vexity: affine
id: 102…634
julia> logsumexp(x)
logsumexp (convex; real)
└─ 3-element real variable (id: 102…634)
```
## DCP properties
| Sign | Monotonicity | Curvature |
| :--- | :----------- | :-------- |
| None | Nondecreasing | Convex |
"""
logsumexp(x::AbstractExpr) = LogSumExpAtom(x)

head(io::IO, ::LogSumExpAtom) = print(io, "logsumexp")

Base.sign(::LogSumExpAtom) = NoSign()
Expand Down
39 changes: 0 additions & 39 deletions src/atoms/MaxAtom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,6 @@ mutable struct MaxAtom <: AbstractExpr
end
end

"""
Base.max(x::Convex.AbstractExpr, y::Convex.AbstractExpr)
Base.max(x::Convex.AbstractExpr, y::Convex.Value)
Base.max(x::Convex.Value, y::Convex.AbstractExpr)
The hypograph of \$max(x, y)\$.
## Examples
Applies to a single expression:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable();
julia> max(x, 1)
max (convex; real)
├─ real variable (id: 183…974)
└─ [1;;]
```
And element-wise to a matrix of expressions:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable(3);
julia> y = [1, 2, 3];
julia> max(x, y)
max (convex; real)
├─ 3-element real variable (id: 153…965)
└─ [1; 2; 3;;]
```
"""
Base.max(x::AbstractExpr, y::AbstractExpr) = MaxAtom(x, y)

Base.max(x::AbstractExpr, y::Value) = max(x, constant(y))

Base.max(x::Value, y::AbstractExpr) = max(constant(x), y)

head(io::IO, ::MaxAtom) = print(io, "max")

function Base.sign(x::MaxAtom)
Expand Down
43 changes: 0 additions & 43 deletions src/atoms/MinAtom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,6 @@ mutable struct MinAtom <: AbstractExpr
end
end

"""
Base.min(x::Convex.AbstractExpr, y::Convex.AbstractExpr)
Base.min(x::Convex.Value, y::Convex.AbstractExpr)
Base.min(x::Convex.AbstractExpr, y::Convex.Value)
The epigraph of \$min(x, y)\$.
## Related constructors
* `Base.min(x, y)`
## Examples
Applies to a single expression:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable();
julia> min(x, 1)
min (concave; real)
├─ real variable (id: 183…974)
└─ [1;;]
```
And element-wise to a matrix of expressions:
```jldoctest; filter=r"id: [0-9]+…[0-9]+"
julia> x = Variable(3);
julia> y = [1, 2, 3];
julia> min(x, y)
min (concave; real)
├─ 3-element real variable (id: 153…965)
└─ [1; 2; 3;;]
```
"""
Base.min(x::AbstractExpr, y::AbstractExpr) = MinAtom(x, y)

Base.min(x::AbstractExpr, y::Value) = min(x, constant(y))

Base.min(x::Value, y::AbstractExpr) = min(constant(x), y)

head(io::IO, ::MinAtom) = print(io, "min")

function Base.sign(x::MinAtom)
Expand Down
11 changes: 0 additions & 11 deletions src/reformulations/abs2.jl

This file was deleted.

11 changes: 0 additions & 11 deletions src/reformulations/hinge_loss.jl

This file was deleted.

18 changes: 0 additions & 18 deletions src/reformulations/logisticloss.jl

This file was deleted.

11 changes: 0 additions & 11 deletions src/reformulations/neg.jl

This file was deleted.

11 changes: 0 additions & 11 deletions src/reformulations/pos.jl

This file was deleted.

Loading

0 comments on commit d991267

Please sign in to comment.