Skip to content

Commit 03076ee

Browse files
committed
Fix dual objective value for max problems
1 parent 57712a1 commit 03076ee

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Interfaces/tulip_julia_api.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ function get_attribute(m::Model{T}, ::DualObjectiveValue) where{T}
289289
- dot(su, Diagonal(isfinite.(xu)), xu)
290290
)
291291

292+
# If problem is maximization, we need to negate the dual value
293+
# to comply with MOI duality convention
294+
z = m.pbdata.objsense ? z : -z
295+
292296
# If solution is a ray, ignore constant objective term
293297
is_ray = m.solution.is_dual_ray
294298
z0 = !is_ray * m.pbdata.obj0

0 commit comments

Comments
 (0)