Skip to content

Commit 3a4ca1b

Browse files
authored
Merge pull request #50 from JuliaOpt/ml/fixcallbacks
fix callback code
2 parents aca66cf + 6bd8f8d commit 3a4ca1b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/GLPKInterfaceMIP.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ MPB.setinfocallback!(m::GLPKMathProgModel, f::Union{Function,Nothing}) = (m.info
225225
_check_tree(d::GLPKCallbackData, funcname::AbstractString) =
226226
(d.tree != C_NULL && d.reason != -1) || error("$funcname can only be called from within a callback")
227227

228-
cbgetstate(d::GLPKCallbackData) = d.state
228+
MPB.cbgetstate(d::GLPKCallbackData) = d.state
229229

230230
function MPB.cbgetlpsolution(d::GLPKCallbackData, output::Vector)
231231
_check_tree(d, "cbgetlpsolution")
@@ -257,9 +257,9 @@ function MPB.cbgetmipsolution(d::GLPKCallbackData, output::Vector)
257257
# the LP solution is actually integral.
258258
# If we add an informational callback for GLPK.IBINGO,
259259
# then this will need to be modified.
260-
return cbgetlpsolution(d, output)
260+
return MPB.cbgetlpsolution(d, output)
261261
end
262-
MPB.cbgetmipsolution(d::GLPKCallbackData) = cbgetlpsolution(d)
262+
MPB.cbgetmipsolution(d::GLPKCallbackData) = MPB.cbgetlpsolution(d)
263263

264264
function MPB.cbgetbestbound(d::GLPKCallbackData)
265265
_check_tree(d, "cbbestbound")
@@ -300,7 +300,7 @@ function MPB.cbaddlazy!(d::GLPKCallbackData, colidx::Vector, colcoef::Vector, se
300300
error("sense must be '=', '<' or '>'")
301301
end
302302
# allocating a new vector is not efficient
303-
solution = cbgetmipsolution(d)
303+
solution = MPB.cbgetmipsolution(d)
304304
# if the cut does not exclude the current solution, ignore it
305305
val = dot(colcoef,solution[colidx])
306306
if (rowlb - 1e-8 <= val <= rowub + 1e-8)
@@ -360,17 +360,17 @@ function MPB.cbaddsolution!(d::GLPKCallbackData)
360360
_initsolution!(d)
361361
_fillsolution!(d)
362362
# test feasibility of solution, would be better if GLPK supported this
363-
l = getvarLB(d.model)
364-
u = getvarUB(d.model)
363+
l = MPB.getvarLB(d.model)
364+
u = MPB.getvarUB(d.model)
365365
for i in 1:length(l)
366366
if d.sol[i] < l[i] - 1e-6 || d.sol[i] > u[i] + 1e-6
367367
Compat.@warn("Ignoring infeasible solution from heuristic callback")
368368
return
369369
end
370370
end
371-
A = getconstrmatrix(d.model)
372-
lb = getconstrLB(d.model)
373-
ub = getconstrUB(d.model)
371+
A = MPB.getconstrmatrix(d.model)
372+
lb = MPB.getconstrLB(d.model)
373+
ub = MPB.getconstrUB(d.model)
374374
y = A*d.sol
375375
for i in 1:length(lb)
376376
if y[i] < lb[i] - 1e-6 || y[i] > ub[i] + 1e-6

0 commit comments

Comments
 (0)