Skip to content

Commit adcbcc1

Browse files
authored
Fix setting HeuristicCallback twice (#338)
1 parent 9811124 commit adcbcc1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/MOI_wrapper/HeuristicCallback.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function MOI.set(o::Optimizer, ::MOI.HeuristicCallback, cb::Function)
6666
description="Heuristic set in the MOI optimizer",
6767
)
6868
else
69-
o.moi_heuristic.cutcallback = cb
69+
o.moi_heuristic.heurcallback = cb
7070
end
7171
return nothing
7272
end

test/MOI_tests.jl

+10
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,11 @@ function test_heuristic_callback()
874874
MOI.set(o, MOI.HeuristicCallback(), heuristic_callback)
875875
MOI.optimize!(o)
876876
@test ncalls[] > 0
877+
n = ncalls[]
878+
_ = MOI.add_variable(o) # Modify model so last solution not still optimal
879+
MOI.set(o, MOI.HeuristicCallback(), heuristic_callback)
880+
MOI.optimize!(o)
881+
@test ncalls[] > n
877882
return
878883
end
879884

@@ -1209,6 +1214,11 @@ function test_obtaining_the_LP_solution()
12091214
@test MOI.get(optimizer, MOI.TerminationStatus()) == MOI.OPTIMAL
12101215
@test MOI.get(optimizer, MOI.PrimalStatus()) == MOI.FEASIBLE_POINT
12111216
@test MOI.get(optimizer, MOI.ObjectiveValue()) 1.0 atol = atol rtol = rtol
1217+
n = calls
1218+
_ = MOI.add_variable(optimizer) # Modify model so last solution not still optimal
1219+
MOI.set(optimizer, MOI.UserCutCallback(), cutcallback)
1220+
MOI.optimize!(optimizer)
1221+
@test calls >= n
12121222
return
12131223
end
12141224

0 commit comments

Comments
 (0)