Skip to main content

GRBVar::index() seems to not exist

Ongoing

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.
  • Marika Karbstein
    • Gurobi Staff

    That is right, the functions GRBVar::index() and GRBConstr:index() are not available in Gurobi Version 8.1.

    The documentation on the Gurobi Webiste can be filtered by version. In this way, you will only see the functions that are really available.

    0
  • Elisheva Rabinowitz
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you!

    As a followup question, in the version I'm using (8.1), is there any easy way to find out if a GRBVar object is in fact initialized?

    For example, if at some point in my code I have an array of type GRBVar and later on want to check which indices contain active variables, is there an easy way for me to do that? The relevant code would look something like

    GRBVar v[10];

    ....

    v[i] = addVar(0, 0, ...);

    for some index i, and then later on I would like to have a condition of the sort

    if(v[3]){

    ....

    which checks if v[3] has a value that has been returned from addVar/s.

    Currently, I used GRBModel::getVars() and iterated through the returned array, while checking for each existing variable if is v[3], using GRBVar::sameAs(v[3]). Is there a more elegant way to do this?

    Thanks

    0

Post is closed for comments.