Skip to content

Commit 7f5f8a4

Browse files
committed
Update
1 parent f6aafc3 commit 7f5f8a4

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

src/Test/test_nonlinear.jl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ function test_VectorNonlinearOracle_LagrangeMultipliers_MAX_SENSE(
23892389
) where {T}
23902390
@requires _supports(config, MOI.optimize!)
23912391
@requires _supports(config, MOI.ConstraintDual)
2392-
@requires _supports(config, MOI.LagrangeMultipliers)
2392+
@requires _supports(config, MOI.LagrangeMultiplier)
23932393
@requires MOI.supports_constraint(
23942394
model,
23952395
MOI.VectorOfVariables,
@@ -2410,11 +2410,15 @@ function test_VectorNonlinearOracle_LagrangeMultipliers_MAX_SENSE(
24102410
f = one(T) * x[1] + one(T) * x[2]
24112411
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
24122412
c = MOI.add_constraint(model, MOI.VectorOfVariables(x), set)
2413-
MOI.optimize!(model)
24142413
y = T(1) / sqrt(T(2))
2414+
CI = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.VectorNonlinearOracle{T}}
2415+
if MOI.supports(model, MOI.LagrangeMultiplierStart(), CI)
2416+
MOI.set(model, MOI.LagrangeMultiplierStart(), c, T[-y])
2417+
end
2418+
MOI.optimize!(model)
24152419
@test isapprox(MOI.get(model, MOI.VariablePrimal(), x), [y, y], config)
24162420
@test isapprox(MOI.get(model, MOI.ConstraintDual(), c), T[-1, -1], config)
2417-
@test isapprox(MOI.get(model, MOI.LagrangeMultipliers(), c), T[-y])
2421+
@test isapprox(MOI.get(model, MOI.LagrangeMultiplier(), c), T[-y])
24182422
return
24192423
end
24202424

@@ -2435,7 +2439,7 @@ function setup_test(
24352439
(F, S) => [T[-1, -1]],
24362440
)
24372441
ci = only(MOI.get(mock, MOI.ListOfConstraintIndices{F,S}()))
2438-
MOI.set(mock, MOI.LagrangeMultipliers(), ci, T[-y])
2442+
MOI.set(mock, MOI.LagrangeMultiplier(), ci, T[-y])
24392443
end,
24402444
)
24412445
model.eval_variable_constraint_dual = false
@@ -2454,7 +2458,7 @@ function test_VectorNonlinearOracle_LagrangeMultipliers_MIN_SENSE(
24542458
) where {T}
24552459
@requires _supports(config, MOI.optimize!)
24562460
@requires _supports(config, MOI.ConstraintDual)
2457-
@requires _supports(config, MOI.LagrangeMultipliers)
2461+
@requires _supports(config, MOI.LagrangeMultiplier)
24582462
@requires MOI.supports_constraint(
24592463
model,
24602464
MOI.VectorOfVariables,
@@ -2475,11 +2479,15 @@ function test_VectorNonlinearOracle_LagrangeMultipliers_MIN_SENSE(
24752479
f = one(T) * x[1] + one(T) * x[2]
24762480
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
24772481
c = MOI.add_constraint(model, MOI.VectorOfVariables(x), set)
2478-
MOI.optimize!(model)
24792482
y = T(1) / sqrt(T(2))
2483+
CI = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.VectorNonlinearOracle{T}}
2484+
if MOI.supports(model, MOI.LagrangeMultiplierStart(), CI)
2485+
MOI.set(model, MOI.LagrangeMultiplierStart(), c, T[y])
2486+
end
2487+
MOI.optimize!(model)
24802488
@test isapprox(MOI.get(model, MOI.VariablePrimal(), x), [-y, -y], config)
24812489
@test isapprox(MOI.get(model, MOI.ConstraintDual(), c), T[1, 1], config)
2482-
@test isapprox(MOI.get(model, MOI.LagrangeMultipliers(), c), T[y])
2490+
@test isapprox(MOI.get(model, MOI.LagrangeMultiplier(), c), T[y])
24832491
return
24842492
end
24852493

@@ -2500,7 +2508,7 @@ function setup_test(
25002508
(F, S) => [T[1, 1]],
25012509
)
25022510
ci = only(MOI.get(mock, MOI.ListOfConstraintIndices{F,S}()))
2503-
MOI.set(mock, MOI.LagrangeMultipliers(), ci, T[y])
2511+
MOI.set(mock, MOI.LagrangeMultiplier(), ci, T[y])
25042512
end,
25052513
)
25062514
model.eval_variable_constraint_dual = false

src/attributes.jl

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3273,15 +3273,15 @@ function get_fallback(
32733273
end
32743274

32753275
"""
3276-
LagrangeMultipliers(result_index::Int = 1)
3276+
LagrangeMultiplier(result_index::Int = 1)
32773277
3278-
An [`AbstractConstraintAttribute`](@ref) for the Lagrange multipliers associated
3278+
An [`AbstractConstraintAttribute`](@ref) for the Lagrange multiplier associated
32793279
with a constraint.
32803280
32813281
## Relationship to `ConstraintDual`
32823282
32833283
In most cases, the value of this attribute is equivalent to
3284-
[`ConstraintDual`](@ref), and querying the value of [`LagrangeMultipliers`](@ref)
3284+
[`ConstraintDual`](@ref), and querying the value of [`LagrangeMultiplier`](@ref)
32853285
will fallback to querying the value of [`ConstraintDual`](@ref).
32863286
32873287
The attribute values differ in one important case.
@@ -3291,7 +3291,7 @@ When there is a [`VectorNonlinearOracle`](@ref) constraint of the form:
32913291
x \\in VectorNonlinearOracle
32923292
```
32933293
the associated [`ConstraintDual`](@ref) is ``\\mu^\\top \\nabla f(x)``, and the
3294-
value of [`LagrangeMultipliers`](@ref) is the vector ``\\mu`` directly.
3294+
value of [`LagrangeMultiplier`](@ref) is the vector ``\\mu`` directly.
32953295
32963296
Both values are useful in different circumstances.
32973297
@@ -3317,25 +3317,37 @@ the [`ResultCount`](@ref) attribute), getting this attribute must throw a
33173317
33183318
Optimizers should implement the following methods:
33193319
```
3320-
MOI.get(::Optimizer, ::MOI.LagrangeMultipliers, ::MOI.ConstraintIndex)
3320+
MOI.get(::Optimizer, ::MOI.LagrangeMultiplier, ::MOI.ConstraintIndex)
33213321
```
33223322
They should not implement [`set`](@ref) or [`supports`](@ref).
33233323
33243324
"""
3325-
struct LagrangeMultipliers <: AbstractConstraintAttribute
3325+
struct LagrangeMultiplier <: AbstractConstraintAttribute
33263326
result_index::Int
33273327

3328-
LagrangeMultipliers(result_index::Int = 1) = new(result_index)
3328+
LagrangeMultiplier(result_index::Int = 1) = new(result_index)
33293329
end
33303330

33313331
function get_fallback(
33323332
model::ModelLike,
3333-
attr::LagrangeMultipliers,
3333+
attr::LagrangeMultiplier,
33343334
ci::ConstraintIndex,
33353335
)
33363336
return get(model, ConstraintDual(attr.result_index), ci)
33373337
end
33383338

3339+
"""
3340+
LagrangeMultiplierStart()
3341+
3342+
An [`AbstractConstraintAttribute`](@ref) for the initial assignment to the
3343+
constraint's [`LagrangeMultiplier`](@ref) that the optimizer may use to
3344+
warm-start the solve.
3345+
3346+
May be `nothing` (unset), a number for [`AbstractScalarFunction`](@ref), or a
3347+
vector for [`AbstractVectorFunction`](@ref).
3348+
"""
3349+
struct LagrangeMultiplierStart <: AbstractConstraintAttribute end
3350+
33393351
"""
33403352
is_set_by_optimize(::AnyAttribute)
33413353
@@ -3394,7 +3406,7 @@ function is_set_by_optimize(
33943406
ConstraintDual,
33953407
ConstraintBasisStatus,
33963408
VariableBasisStatus,
3397-
LagrangeMultipliers,
3409+
LagrangeMultiplier,
33983410
},
33993411
)
34003412
return true

0 commit comments

Comments
 (0)