jump-dev / CPLEX.jl

A Julia interface to the CPLEX solver
https://www.ibm.com/products/ilog-cplex-optimization-studio
MIT License
134 stars 63 forks source link

How does CPX_CALLBACK_INFO_NODE_COUNT work? #446

Closed matheusdiogenesandrade closed 6 months ago

matheusdiogenesandrade commented 6 months ago

I am trying to understand how the triad CPLEX.jl + JuMP.jl + MOI.jl make the function node_count work. So, in the CPLEX.jl we have at line 329:

const CPX_CALLBACK_INFO_NODE_COUNT = 103

In the JuMP.jl we have this:

function node_count(model::GenericModel)
    return MOI.get(model, MOI.NodeCount())
end

And, in the MOI.jl we have this:

"""
    NodeCount()

A model attribute for the total number of branch-and-bound nodes explored while
solving a mixed-integer program (MIP).
"""
struct NodeCount <: AbstractModelAttribute end

Precisely, where exactly the delegation to some cplex CPX function is made to retrieve this info?

Thanks and regards.

odow commented 6 months ago

NodeCount is implemented here:

https://github.com/jump-dev/CPLEX.jl/blob/c986eed415235785e551c51ebff9061aa8975e95/src/MOI/MOI_wrapper.jl#L3308-L3311

CPX_CALLBACK_INFO_NODE_COUNT is unrelated. It is an attribute that can be queried in a callback. See: https://github.com/jump-dev/CPLEX.jl/tree/master?tab=readme-ov-file#callbacks

matheusdiogenesandrade commented 6 months ago

Thank you so much.