status = CPXcallbackgetrelaxationpoint(cb_data, x, 0, 1, obj_p)
@info “Relaxation point: $(x)”
There are a few problems here:
xis not defined yet. You should typically write your callback function after creating the model, etcxgets defined later as aMatrix{VariableRef}, whereas CPLEX needs to be passed aVector{Float64}.x[]is the syntax forRefvariables, not vectors or matrices.
You could instead pass something like this (although I didn’t try it, so there might be a mistake):
if (lpstat[] == CPX_STAT_OPTIMAL) || (lpstat[] == CPX_STAT_OPTIMAL_INFEAS)
# Relaxation is optimal. Find the integer variable that is most fractional.
println("Branching")
obj_p = Ref{Cdouble}()
x_val = Vector{Cdouble}(undef, N^2)
status = CPXcallbackgetrelaxationpoint(cb_data, x_val, 0, N^2 - 1, obj_p)
if Bool(status)
@error "CPXcallbackgetrelaxationpoint failed."
else
@info "Relaxation point: $(x_val)"
@info "Relaxation objective: $(obj_p[])"
end
end