函数getValue(s)Cplex C ++的问题 [英] Problems with function getValue(s) cplex c++

查看:666
本文介绍了函数getValue(s)Cplex C ++的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人!

求解模型后,我在获取变量x值时遇到问题。

I'm having problems to get variables x values after solving the model.

x变量是四个索引变量。

x variables are a four index variables.

我定义了以下结构:

#define     ILOARRAYNUM2                   IloArray<IloNumArray>
#define     ILOARRAYNUM3                   IloArray<ILOARRAYNUM2 >
#define     ILOARRAYNUM4                   IloArray<ILOARRAYNUM3 >
typedef IloArray<IloNumVarArray> NumVar2Array;
typedef IloArray<NumVar2Array>   NumVar3Array;
typedef IloArray<NumVar3Array>   NumVar4Array;

变量x定义为:

NumVar4Array x; 
ILOARRAYNUM4 _x;

mono.x = NumVar4Array(env, n);
for(int i = 0; i < n; i++) { 
    mono.x[i] = NumVar3Array(env, n);
    for(int j = 0; j < n; j++) {
        mono.x[i][j] = NumVar2Array(env, n);
        for (int k = 0; k < n; k++) {
            mono.x[i][j][k] = IloNumVarArray(env, n, 0.0, 1.0, ILOFLOAT);
        }
    }
}

mono._x = ILOARRAYNUM4(env,n);
for (int i = 0; i < n; i++){
    mono._x[i]    = ILOARRAYNUM3(env,n);
    for (int j = 0; j < n; j++){
        mono._x[i][j]  = ILOARRAYNUM2(env,n);
        for (int k = 0; k < n; k++) {
            mono._x[i][j][k] = IloNumArray(env,n);
        }
    }
}  

获得x的值,我这样做:

To get the values of x, I do:

for (int i = 0; i < n; i++) { 
    for (int j  = 0; j < n; j++) { 
        if (w[i][j] != 0){ 
            for (int k = 0; k < n; k++) {
                for (int m = 0; m < n; m++) {
                    if ( (k != m && k != j && m != i) or (k == m) ) {
                        mono.cplex.getValue(mono.x[i][j][k][m], mono._x[i][j][k][m]);
                    }
                }
            }
        }
    }
}

但是,然后,出现以下错误消息:

But, then, the error message below appears:

IloAlgorithm尚未提取引用的IloExtractable

The referenced IloExtractable has not been extracted by the IloAlgorithm

我在做什么错了?

推荐答案

您在问题中的约束很可能不包括所有变量;可能存在一些不受任何约束约束的变量。您的代码是否获得某些变量的值?您是否尝试通过这段代码进行调试,以查看哪个变量未提取到CPLEX中?

Most likely your constraints in your problem do not include all the variables; there may be some variable which is not involved in any constraint. Does your code get values for some of the variables? Have you tried debugging through this code to see which variable is not extracted to CPLEX?

请参见

See CPLEX - Error in accessing solution C++

这篇关于函数getValue(s)Cplex C ++的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆