getVarByName c++
AnsweredAfter optimizing a model, I need to take a specific value "x1" from solutions
Using c++
m1.getVarByName("x1")
I got this error
: error: ambiguous overload for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘GRBVar’)
cout << m1.getVarByName("x1") << endl;
----------------------
I use m1.get(x[i]) and I got this error
lib/gurobi_c++.h:772:18: note: candidate: ‘std::__cxx11::string* GRBModel::get(GRB_StringAttr, const GRBGenConstr*, int)’
std::string* get(GRB_StringAttr attr, const GRBGenConstr* xgenconstrs, int len);
---------------------------------------------------
Is that any way to extract "x1" from solutions
-
Hi Zakarya,
Using \(\texttt{getVarByName("x1")}\) will return a GRBVar.
You cannot print this to stdout.
You can, however, print its value or its name as shown in our mip1_c++.cpp example.Cheers,
David0
Please sign in to leave a comment.
Comments
1 comment