Skip to content

Commit 62ed3d1

Browse files
authored
Fix dG for QP (#188)
* Fix dG for QP * Fix tests * Fix test
1 parent 1c5bf1a commit 62ed3d1

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

src/quadratic_diff.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,5 +596,5 @@ function _get_dA(b_cache::QPForwBackCache, g_cache::QPCache, ci::CI{F,S}
596596
λ = g_cache.inequality_duals
597597
= b_cache.
598598
l = _neg_if_gt(λ[i], S)
599-
return lazy_combination(+, l * dλ[i], z, l * λ[i], dz)
599+
return lazy_combination(+, l * dλ[i], z, l, dz)
600600
end

test/jump.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,13 @@ end
190190
@test moi_function(MOI.get(model, DiffOpt.BackwardOutObjective())) moi_function(expected) atol=ATOL rtol=RTOL
191191

192192
dh = [0.35714284; 0.4285714]
193-
# This ws already broken
194-
# @test_broken dl_dG ≈ [0.05102035 0.30612245 0.255102;
195-
# 0.06122443 0.36734694 0.3061224] atol=ATOL rtol=RTOL
196193
dG = -[0.05102035 0.30612245 0.255102;
197194
0.06122443 0.36734694 0.3061224]
198195
for (j,jc) in enumerate([c1, c2])
199196
grad = MOI.get(model, DiffOpt.BackwardOutConstraint(), jc)
200197
@test JuMP.constant(grad) -dh[j] atol=ATOL rtol=RTOL
201198
for (i,iv) in enumerate(z)
202-
@test_broken JuMP.coefficient(grad, iv) dG[j,i] atol=ATOL rtol=RTOL
199+
@test JuMP.coefficient(grad, iv) dG[j,i] atol=ATOL rtol=RTOL
203200
end
204201
end
205202
end

test/moi_wrapper.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ end
182182
-0.11224488 0.07653058 -0.06122449]
183183
dq = [-0.2142857, 0.21428567, -0.07142857]
184184

185-
dG = [0.09476022 0.26239144 0.26968323
186-
0.08743854 0.34111495 0.31484575]
185+
dG = [0.05102692 0.30612244 0.25510856
186+
0.06120519 0.36734693 0.30610315]
187187
dh = [-0.35714284; -0.4285714]
188188

189189
qp_test_with_solutions(

test/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function qp_test(
194194
@_test(-dhb ./ λ, ∇λb)
195195
end
196196
if ∇λb !== nothing
197-
@_test(Diagonal(λ) * (∇λb * z' + λ * ∇zb'), dGb)
197+
@_test(Diagonal(λ) * ∇λb * z' + λ * ∇zb', dGb)
198198
end
199199

200200
# Test against [AK17, eq. (7)]

0 commit comments

Comments
 (0)