Skip to main content

Error when using mycallback function with a new model

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • 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

Post is closed for comments.