getVarByName c++
回答済みAfter 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
-
正式なコメント
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. -
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
投稿コメントは受け付けていません。
コメント
2件のコメント