Skip to content

Commit af5848d

Browse files
authored
Remove acronyms (#445)
1 parent bd3f78f commit af5848d

18 files changed

+155
-118
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Pajarito"
22
uuid = "2f354839-79df-5901-9f0a-cdb2aac6fe30"
3-
repo = "https://github.com/jump-dev/Pajarito.jl.git"
43
authors = ["Chris Coey <coey.chris@gmail.com>"]
4+
repo = "https://github.com/jump-dev/Pajarito.jl.git"
55
version = "0.8.1"
66

77
[deps]

src/Cones/Cones.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ module Cones
99

1010
import LinearAlgebra
1111
import JuMP
12-
const MOI = JuMP.MOI
13-
const VR = JuMP.VariableRef
14-
const AE = JuMP.AffExpr
12+
import MathOptInterface as MOI
1513

1614
import Pajarito: Cache, Optimizer
1715

@@ -35,15 +33,15 @@ const OACone = Union{
3533
MOI.PositiveSemidefiniteConeTriangle,
3634
}
3735

38-
setup_auxiliary(::Cache, ::Optimizer) = VR[]
36+
setup_auxiliary(::Cache, ::Optimizer) = JuMP.VariableRef[]
3937

4038
extend_start(::Cache, ::Vector{Float64}, ::Optimizer) = Float64[]
4139

4240
num_ext_variables(::Cache) = 0
4341

4442
function dot_expr(
4543
z::AbstractVecOrMat{Float64},
46-
vars::AbstractVecOrMat{<:Union{VR,AE}},
44+
vars::AbstractVecOrMat{<:Union{JuMP.VariableRef,JuMP.AffExpr}},
4745
opt::Optimizer,
4846
)
4947
return JuMP.@expression(opt.oa_model, LinearAlgebra.dot(z, vars))

src/Cones/exponentialcone.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ equivalently (p < 0, q ≥ p * (log(r / -p) + 1))
1313
=#
1414

1515
mutable struct ExponentialCone <: Cache
16-
oa_s::Vector{AE}
16+
oa_s::Vector{JuMP.AffExpr}
1717
ExponentialCone() = new()
1818
end
1919

20-
function create_cache(oa_s::Vector{AE}, ::MOI.ExponentialCone, ::Optimizer)
20+
function create_cache(
21+
oa_s::Vector{JuMP.AffExpr},
22+
::MOI.ExponentialCone,
23+
::Optimizer,
24+
)
2125
@assert length(oa_s) == 3
2226
cache = ExponentialCone()
2327
cache.oa_s = oa_s
@@ -51,13 +55,13 @@ function get_subp_cuts(
5155
if p > 0 || r < 0
5256
# z ∉ K
5357
@warn("exponential cone dual vector violates variable bounds")
54-
return AE[]
58+
return JuMP.AffExpr[]
5559
end
5660
q = z[2]
5761
(u, v, w) = cache.oa_s
5862

5963
if p > -1e-12
60-
return AE[]
64+
return JuMP.AffExpr[]
6165
elseif r / -p > 1e-8
6266
# strengthened cut is (p, p * (log(r / -p) + 1), r)
6367
q = p * (log(r / -p) + 1)
@@ -67,7 +71,7 @@ function get_subp_cuts(
6771
r = -p * exp(q / p - 1)
6872
cut = JuMP.@expression(opt.oa_model, p * u + q * v + r * w)
6973
else
70-
return AE[]
74+
return JuMP.AffExpr[]
7175
end
7276
return [cut]
7377
end
@@ -95,7 +99,7 @@ function get_sep_cuts(
9599
q = -log(ℯ / 2 * r)
96100
cut = JuMP.@expression(opt.oa_model, -u + q * v + r * w)
97101
else
98-
return AE[]
102+
return JuMP.AffExpr[]
99103
end
100104
elseif ws / vs > 1e-8 && us - vs * log(ws / vs) > opt.tol_feas
101105
# vs and ws not near zero
@@ -108,7 +112,7 @@ function get_sep_cuts(
108112
q = (us - vs) / vs * -p
109113
cut = JuMP.@expression(opt.oa_model, p * u + q * v + w)
110114
else
111-
return AE[]
115+
return JuMP.AffExpr[]
112116
end
113117
return [cut]
114118
end

src/Cones/positivesemidefiniteconetriangle.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ w ⪰ 0
99
=#
1010

1111
mutable struct PositiveSemidefiniteConeTriangle <: Cache
12-
oa_s::Vector{AE}
12+
oa_s::Vector{JuMP.AffExpr}
1313
d::Int
14-
W::Matrix{<:Union{VR,AE}}
14+
W::Matrix{<:Union{JuMP.VariableRef,JuMP.AffExpr}}
1515
PositiveSemidefiniteConeTriangle() = new()
1616
end
1717

1818
function create_cache(
19-
oa_s::Vector{AE},
19+
oa_s::Vector{JuMP.AffExpr},
2020
moi_cone::MOI.PositiveSemidefiniteConeTriangle,
2121
::Optimizer,
2222
)
@@ -57,7 +57,7 @@ function get_subp_cuts(
5757
# strengthened cuts from eigendecomposition are λᵢ * rᵢ * rᵢ'
5858
R = vec_to_symm(cache.d, z)
5959
F = LinearAlgebra.eigen!(LinearAlgebra.Symmetric(R, :U), 1e-9, Inf)
60-
isempty(F.values) && return AE[]
60+
isempty(F.values) && return JuMP.AffExpr[]
6161
R_eig = F.vectors * LinearAlgebra.Diagonal(sqrt.(F.values))
6262
return _get_cuts(R_eig, cache, opt)
6363
end
@@ -74,7 +74,7 @@ function get_sep_cuts(
7474
-Inf,
7575
-opt.tol_feas,
7676
)
77-
isempty(F.values) && return AE[]
77+
isempty(F.values) && return JuMP.AffExpr[]
7878
return _get_cuts(F.vectors, cache, opt)
7979
end
8080

@@ -85,7 +85,7 @@ function _get_cuts(
8585
)
8686
# cuts from eigendecomposition are rᵢ * rᵢ'
8787
W = cache.W
88-
cuts = AE[]
88+
cuts = JuMP.AffExpr[]
8989
for i in 1:size(R_eig, 2)
9090
@views r_i = R_eig[:, i]
9191
R_i = r_i * r_i'

src/Cones/powercone.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ equivalently (q > 0, p ≥ t / (1-t) * q * |(1-t) * r / q|^(1/t))
1414

1515
mutable struct PowerCone <: Cache
1616
t::Real
17-
oa_s::Vector{AE}
17+
oa_s::Vector{JuMP.AffExpr}
1818
PowerCone() = new()
1919
end
2020

21-
function create_cache(oa_s::Vector{AE}, moi_cone::MOI.PowerCone, ::Optimizer)
21+
function create_cache(
22+
oa_s::Vector{JuMP.AffExpr},
23+
moi_cone::MOI.PowerCone,
24+
::Optimizer,
25+
)
2226
@assert length(oa_s) == 3
2327
cache = PowerCone()
2428
cache.t = moi_cone.exponent
@@ -48,7 +52,7 @@ function get_subp_cuts(z::Vector{Float64}, cache::PowerCone, opt::Optimizer)
4852
if min(p, q) < 0
4953
# z ∉ K
5054
@warn("dual vector is not in the dual cone")
51-
return AE[]
55+
return JuMP.AffExpr[]
5256
end
5357

5458
# strengthened cut is (p, q, sign(r) * (p/t)^t * (q/(1-t))^(1-t))
@@ -67,7 +71,7 @@ function get_sep_cuts(s::Vector{Float64}, cache::PowerCone, opt::Optimizer)
6771
# check s ∉ K
6872
t = cache.t
6973
if us >= 0 && vs >= 0 && (us^t * vs^(1 - t) - abs(ws)) > -opt.tol_feas
70-
return AE[]
74+
return JuMP.AffExpr[]
7175
end
7276

7377
# gradient cut is (t * (us/vs)^(t-1), (1-t) * (us/vs)^t, -sign(ws))

src/Cones/secondordercone.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ linear and 3-dim rotated second order cone constraints
1313
=#
1414

1515
mutable struct SecondOrderCone{E<:NatExt} <: Cache
16-
oa_s::Vector{AE}
16+
oa_s::Vector{JuMP.AffExpr}
1717
d::Int
18-
ϕ::Vector{VR}
18+
ϕ::Vector{JuMP.VariableRef}
1919
SecondOrderCone{E}() where {E<:NatExt} = new{E}()
2020
end
2121

2222
function create_cache(
23-
oa_s::Vector{AE},
23+
oa_s::Vector{JuMP.AffExpr},
2424
moi_cone::MOI.SecondOrderCone,
2525
opt::Optimizer,
2626
)
@@ -52,7 +52,7 @@ function get_sep_cuts(
5252
ws_norm = LinearAlgebra.norm(ws)
5353
# check s ∉ K
5454
if us - ws_norm > -opt.tol_feas
55-
return AE[]
55+
return JuMP.AffExpr[]
5656
end
5757

5858
# cut is (1, -ws / ‖ws‖)
@@ -84,7 +84,7 @@ function _get_cuts(
8484
opt::Optimizer,
8585
)
8686
# strengthened cut is (‖r‖, r)
87-
clean_array!(r) && return AE[]
87+
clean_array!(r) && return JuMP.AffExpr[]
8888
p = LinearAlgebra.norm(r)
8989
u = cache.oa_s[1]
9090
@views w = cache.oa_s[2:end]
@@ -142,12 +142,12 @@ function _get_cuts(
142142
cache::SecondOrderCone{Ext},
143143
opt::Optimizer,
144144
)
145-
clean_array!(r) && return AE[]
145+
clean_array!(r) && return JuMP.AffExpr[]
146146
p = LinearAlgebra.norm(r)
147147
u = cache.oa_s[1]
148148
@views w = cache.oa_s[2:end]
149149
ϕ = cache.ϕ
150-
cuts = AE[]
150+
cuts = JuMP.AffExpr[]
151151
for i in 1:(cache.d)
152152
r_i = r[i]
153153
iszero(r_i) && continue

src/JuMP_tools.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# tools for JuMP functions
77

8-
function add_cuts(cuts::Vector{AE}, opt::Optimizer, viol_only::Bool)
8+
function add_cuts(cuts::Vector{JuMP.AffExpr}, opt::Optimizer, viol_only::Bool)
99
if viol_only
1010
# filter out unviolated cuts
1111
cuts = filter(cut -> get_value(cut, opt.lazy_cb) < -opt.tol_feas, cuts)
@@ -16,22 +16,28 @@ function add_cuts(cuts::Vector{AE}, opt::Optimizer, viol_only::Bool)
1616
return !isempty(cuts)
1717
end
1818

19-
function _add_cuts(cuts::Vector{AE}, model::JuMP.Model, ::Nothing)
19+
function _add_cuts(cuts::Vector{JuMP.AffExpr}, model::JuMP.Model, ::Nothing)
2020
JuMP.@constraint(model, cuts .>= 0)
2121
return
2222
end
2323

24-
function _add_cuts(cuts::Vector{AE}, model::JuMP.Model, cb)
24+
function _add_cuts(cuts::Vector{JuMP.AffExpr}, model::JuMP.Model, cb)
2525
cons = JuMP.@build_constraint(cuts .>= 0)
2626
MOI.submit.(model, MOI.LazyConstraint(cb), cons)
2727
return
2828
end
2929

30-
get_value(expr::Union{VR,AE}, ::Nothing) = JuMP.value(expr)
30+
function get_value(expr::Union{JuMP.VariableRef,JuMP.AffExpr}, ::Nothing)
31+
return JuMP.value(expr)
32+
end
3133

32-
get_value(expr::Union{VR,AE}, cb) = JuMP.callback_value(cb, expr)
34+
function get_value(expr::Union{JuMP.VariableRef,JuMP.AffExpr}, cb)
35+
return JuMP.callback_value(cb, expr)
36+
end
3337

34-
get_value(exprs::Vector{<:Union{VR,AE}}, cb) = [get_value(e, cb) for e in exprs]
38+
function get_value(exprs::Vector{<:Union{JuMP.VariableRef,JuMP.AffExpr}}, cb)
39+
return [get_value(e, cb) for e in exprs]
40+
end
3541

3642
function check_set_time_limit(opt::Optimizer, model::JuMP.Model)
3743
time_left = opt.time_limit - time() + opt.solve_time

0 commit comments

Comments
 (0)