GRBVar::index() seems to not exist
進行中Hi,
In the C++ API here https://www.gurobi.com/documentation/9.5/refman/cpp_api_details.html it is mentioned that GRBVar has a method called index() which returns the index of the variable in the model.
When trying to use this method, I get the error " 'class GRBVar' has no member named 'index'."
Looking at the gurobi_c++.h file in the path where gurobi is installed, I see that in fact the class does not seem to have a definition of the 'index' method.
Can you please clarify how I'm supposed to use this method? Does it exist only in a different version of gurobi? I am using gurobi811.
In addition, I noticed that the same thing is true about GRBConstr:index() - it also does not appear in the h file.
Thanks.
-
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 -
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
サインインしてコメントを残してください。
コメント
2件のコメント