# New Gurobi.jl syntax trouble

**URL:** <https://discourse.julialang.org/t/new-gurobi-jl-syntax-trouble/50344>\
**Category:** Optimization (Mathematical)\
**Tags:** question, optimization\
**Created:** [November 17, 2020, 11:38pm UTC](https://discourse.julialang.org/t/new-gurobi-jl-syntax-trouble/50344 "2020-11-17T23:38:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![afazevedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/afazevedo/32/16394_2.png) [@afazevedo](https://discourse.julialang.org/u/afazevedo)\
**Post date:** [November 17, 2020, 11:38pm UTC](https://discourse.julialang.org/t/new-gurobi-jl-syntax-trouble/50344/1 "2020-11-17T23:38:22Z")

</div>

Hi all

I’ve got some issues in adapting to the new Gurobi.jl syntax.  
For example, this is a callback that I made in the old syntax:

```julia
function cb(cb_data, cb_where)

    if cb_where == CB_MIPNODE
        #first node
        if cbget_mipnode_nodcnt(cb_data, cb_where) == 0
            #Pegando a relaxação linear de todas as variáveis
            linear_rel = cbget_mipnode_rel(cb_data, cb_where)

            tam = length(linear_rel)-(n+1)
            aux = linear_rel[1:tam]

            #Graph
            flow_graph = DiGraph(n+1)
            capacity_matrix = zeros(n+1, n+1)

            for j in 1:n
                for i in 1:n+1
                    if aux[(j-1)*(n+1) + i] > g_params.EPS
                        add_edge!(flow_graph, i, j)
                        capacity_matrix[i,j] = aux[(j-1)*(n+1) + i]
                    end
                end
            end
end
end

```

I would like to transform that one to the new syntax. For the “nodcnt” I managed to adapt using

```julia
resultP = Ref {Cint} ()
    GRBcbget (cb_data, cb_where, GRB_CB_MIPNODE_NODCNT, resultP)

```

However, I’m having issues to query the linear relaxation values ☹  
Error like these is happening:

```julia
signal (11): Segmentation fault
in expression starting at /PATH/TO/EXAMPLE.jl 88
cb at /home/afazevedo/Documentos/dissertacao/src/bc.jl:47
unknown function (ip: 0x7fffffffffffffff)
Allocations: 176939438 (Pool: 176893431; Big: 46007); GC: 148

```

I imagine it has to do with allocation and pointers, but I don’t know how to solve it.  
Can anyone help me? 🤯

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [November 18, 2020, 12:56am UTC](https://discourse.julialang.org/t/new-gurobi-jl-syntax-trouble/50344/2 "2020-11-18T00:56:58Z")

</div>

A couple of points:

1. `GRB_CB_MIPNODE_NODCNT` is a `Cdouble`: [https://www.gurobi.com/documentation/9.0/refman/cb\_codes.html](https://www.gurobi.com/documentation/9.0/refman/cb_codes.html)

2. For the primal solution, follow the example: [GitHub - jump-dev/Gurobi.jl: Julia interface for Gurobi Optimizer](https://github.com/jump-dev/Gurobi.jl#callbacks).

---

<div class="post-metadata">

**Author:** ![afazevedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/afazevedo/32/16394_2.png) [@afazevedo](https://discourse.julialang.org/u/afazevedo)\
**Post date:** [November 18, 2020, 1:04pm UTC](https://discourse.julialang.org/t/new-gurobi-jl-syntax-trouble/50344/3 "2020-11-18T13:04:16Z")

</div>

Thanks a lot!! ❤
