Skip to main content

GRBVar objects behaviour (and other questions)

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three 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.
  • David Torres Sanchez
    • Gurobi Staff

    Hi Lorenzo,

    I'll try and answer these.

    1. They are not constant. If you look at the examples: Mip1.java it is very easy to see this use. I'm not sure these objects would be very useful otherwise.
    2. Same for other GRB constructs: constraints, linear expressions, ...
    3. I think so, you can also query the index: GRBVar.index().
    4. I think so, but I would keep them locally and query them individually to make sure.
    5. It is documented: GRBModel.getVarByName(). VSCode probably only picks up the docstrings in the classpath which are not up-to-date.
    6. Same as 4. It will be more performant if you are going to query them often. But maybe getVarByName as it is a bit safer.
    7. Not allowed to change parameters in a callback, as you say, you can terminate and restart: How do I change parameters in a callback?
    8. Yes, this is still the case. At some points of the solution process, Gurobi can just be busy with something that is incompatible (different algorithms, cut generation, ...). But if you use GRBCallback.useSolution it is processed asap after, this could well be immediate. Please note that the solution may be discarded if it is worse than the ones already found. Also, see: GRBCallback.setSolution().

    Hope this helps.
    Cheers, 
    David

    0
  • David Torres Sanchez
    • Gurobi Staff

    Side question: if I will ever need in future to post a similar "batch" of questions, do you prefer all of them in a single post, or one post for each question?

    I am happy with this format as some of these are related :)
    But maybe it is better for searching purposes to have them split into different questions, but I guess it is entirely up to you!

    Cheers, 
    David

    0

Post is closed for comments.