Skip to content

Commit 2586101

Browse files
committed
[algs] dfauglag for inequality-constrained problems
1 parent cac2845 commit 2586101

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

src/auglag/auglag.jl

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ end
1717
1818
- Draft version.
1919
- Solve a constrained problem with an augmented Lagrangian method, whose subproblem is solved by `NOMAD.jl`.
20+
- Derivative-free version of Andreani et al.'s 2007 AUGLAG, as proposed by Diniz-Ehrhardt et al. in 2011.
2021
2122
# Arguments
2223
- `bb::Blackbox`: the blackbox to be optimized. Should take `x::Vector{Float64}` as an input and return an output of the form `Tuple{Float64,Vector{Float64},Vector{Float64}}` where the first number is the objective value and the vectors of inequality and equality constraints, in this order.
24+
25+
# TODOS
26+
- Handle the types of problems (equalities, inequalities, unconstrained) in a cleaner way.
2327
"""
24-
function dfauglag(bb::Blackbox, x0::Vector{Float64}; λ0::Union{Nothing,Vector{Float64}}=nothing, μ0::Union{Nothing,Vector{Float64}}=nothing, γ::Float64=0.5, MAX_ITERS::Int=100)
28+
function dfauglag(bb::Blackbox, x0::Vector{Float64}; λ0::Union{Nothing,Vector{Float64}}=nothing, μ0::Union{Nothing,Vector{Float64}}=nothing, γ::Float64=1.5, τ::Float64=0.75, MAX_ITERS::Int=100)
2529
# Dimension, number of equalities and inequalities.
2630
n, m, p = get_dim(bb), nb_eqs(bb), nb_ineqs(bb)
2731

@@ -46,7 +50,8 @@ function dfauglag(bb::Blackbox, x0::Vector{Float64}; λ0::Union{Nothing,Vector{F
4650
# Outer iterations of the augmented Lagrangian method.
4751
k = 0
4852
x = x0
49-
options = NOMAD.NomadOptions(max_bb_eval=10)
53+
options = NOMAD.NomadOptions(max_bb_eval=50)
54+
previous_gap = 0.0
5055
while k < MAX_ITERS
5156
# 1. Solve the augmented Lagrangian subproblem with a DFO method, here MADS.
5257
L(y) = auglag_bb_wrapper(bb, y; ρ, λ, μ)
@@ -55,19 +60,30 @@ function dfauglag(bb::Blackbox, x0::Vector{Float64}; λ0::Union{Nothing,Vector{F
5560
x = result.x_best_feas
5661

5762
# 2. Estimate new Lagrange multipliers.
58-
h = [eval_eq(bb, i, x) for i in 1:p]
59-
λ = λ .+* h)
60-
g = [eval_ineq(bb, i, x) for i in 1:m]
61-
V = max.(g, -1 / ρ * μ)
62-
μ = max.(zeros(p), μ .+* g))
63+
if nb_eqs(bb) > 0
64+
h = [eval_eq(bb, i, x) for i in 1:m]
65+
λ = λ .+* h)
66+
end
67+
if nb_ineqs(bb) > 0
68+
g = [eval_ineq(bb, i, x) for i in 1:p]
69+
V = max.(g, -1 / ρ * μ)
70+
μ = max.(zeros(p), μ .+* g))
71+
end
6372

6473
# 3. Update the penalty parameter.
65-
if k > 0
66-
if max(maximum(h), maximum(V)) > τ * max(maximum(hprev), maximum(Vprev)) # TODO: save h and V from previous iteration every time.
67-
ρ *= γ
68-
end
74+
# This rule uses a criterion that measures a combination of feasibility and dual-complementarity.
75+
if nb_ineqs(bb) > 0
76+
gap = max(maximum(h), maximum(V))
77+
else
78+
gap = maximum(h)
79+
end
80+
81+
if gap > τ * previous_gap
82+
ρ *= γ
6983
end
84+
previous_gap = gap
7085

7186
k += 1
87+
println(x)
7288
end
7389
end

0 commit comments

Comments
 (0)