简体   繁体   English

getValue() cplex C++

[英]getValue() cplex C++

Actually, I'm a beginner on using cplex on C++.实际上,我是在 C++ 上使用 cplex 的初学者。 I try to stock the values of a variable (IloIntVarArray) after solving the MIP on a vector that I've put as an argument of the function by getValue(), but it doesn't work.在我通过 getValue() 作为 function 的参数放置向量上的 MIP 后,我尝试存储变量 (IloIntVarArray) 的值,但它不起作用。 Any suggestions?有什么建议么?

Here's an example这是一个例子

IloNumArray values(getEnv());
getValues(values, _x);
for (int i = 0; i < _graph->GetArcCount(); i++)
{
    ClassOfArcs* arc = _graph->GetArc(i);
    arc->value = (double)values[arc->index];
}
values.clear();

Where x is an IloNumVarArray holding the value of variable x_ij (going from customer i to j).其中 x 是一个 IloNumVarArray,保存变量 x_ij 的值(从客户 i 到 j)。 In the example, I wish to store the values of x in an std::vector _x.在示例中,我希望将 x 的值存储在 std::vector _x 中。

Don't forget to do a value.end() when you finish passing all other variables in your model to avoid memory leaks.当您完成传递 model 中的所有其他变量时,不要忘记执行 value.end() 以避免 memory 泄漏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM