Skip to main content

Error when using mycallback function with a new model

Answered

Comments

2 comments

  • Jaromił Najman
    • Gurobi Staff

    Hi Libia,

    Could you provide a minimal reproducible example?

    Depending on what you are trying to achieve, it is possible that the number of variables changed in between calls such that the \(\texttt{model._vars}\) object does not longer fit the \(\texttt{model.getVars}\) call. You might want to try

    x = model.cbGetNodeRel(model._vars)
    model.cbSetSolution(model._vars, x)

    However, without an example of your executed code, it is hard to help here.

    Please note that only specific callback functions are meant to be safely callable from within a callback. Thus, using \(\texttt{model.getVars()}\) in this case is not good. We are aware that this is part of our callback.py example and will be adjusted in an upcoming release.

    Best regards, 
    Jaromił

    0
  • Libia Romero Escobedo
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks Jaromil, I will try your advice.

    0

Please sign in to leave a comment.