在CPLEX C ++中使用addMIPStart()时出错 [英] Error in using addMIPStart() in CPLEX C++

查看:238
本文介绍了在CPLEX C ++中使用addMIPStart()时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用addMIPStart()时遇到问题.

I faced a problem while using addMIPStart().

首先,出于测试目的,我提出了一个广义分配问题(只有一组二进制决策变量x [i] [] j),并使用addMIPStart()添加了一个边界.效果很好.

At first, for testing purpose, I took a generalized assignment problem (has only one set of binary decision variables x[i][]j) and add a bound using addMIPStart(). It has worked perfectly.

但是,当我针对自己的问题尝试同样的操作时,出现了一个错误问题CPLEX:" IloExtractable 189 IloNumVarl尚未被Iloalgorithm 000001ECF89B160提取".

But, when I was trying the same on my own problem, I got an error problem CPLEX: "IloExtractable 189 IloNumVarl has not been extracted by Iloalgorithm 000001ECF89B160".

在我的问题中,有四种类型的变量:

In my problem, there are four types of variables:

x[k][p][t] = IloNumVar(env, 0.0, 1, ILOINT, name.str().c_str());  //binary
y[p][t] = IloNumVar(env, 0.0, 1, ILOINT, name.str().c_str());  //binary
z[k][p][t] = IloNumVar(env, 0.0, 1, ILOINT, name.str().c_str());  //binary
w[p][t] = IloNumVar(env, 0.0, IloInfinity, ILOINT, name.str().c_str()); //pure integer

现在,我添加了以下代码......................

Now, I have added the following piece of code ......................

/*************************************************/
    IloNumVarArray startVar(env);
    IloNumArray startVal(env);
    IloNum remExtResource = 0;
    IloInt cutOffTime = 0;
    IloInt totExtResource = 0;

    for (k = 0; k < K; k++) {
        for (p = 0; p<P; p++) {
            for (t = 0; t<T + 2; t++) {
                startVar.add(x[k][p][t]);
                startVal.add(0);
            }
        }
    }
    for (k = 0; k < K; k++) {
        for (p = 0; p<P2; p++) {
            for (t = 0; t<T + 1; t++) {
                startVar.add(z[k][p][t]);
                startVal.add(0);
            }
        }
    }
    for (p = 0; p<P2; p++) {
        totExtResource = ceil(D[p] / a_e[p]);
        cutOffTime = ceil(totExtResource / Q[p]);
        for (t_p = 0; t_p<T + 2; t_p++) {
            if (t <= cutOffTime){
                startVar.add(y[p][t]);
                startVal.add(0);
            }
            if (t > cutOffTime){
                startVar.add(y[p][t]);
                startVal.add(1);
            }
        }
        totExtResource = 0;
        cutOffTime = 0;
    }
    for (p = 0; p<P2; p++) {
        remExtResource = ceil(D[p] / a_e[p]);
        for (t = 0; t<T + 1; t++) {
            if (t == 0) {
                startVar.add(w[p][t]);
                startVal.add(0);
            }
            else {
                if (remExtResource == 0) {
                    startVar.add(w[p][t]);
                    startVal.add(0);
                }
                else if ((remExtResource > 0) && (remExtResource <= Q[p])) {
                    startVar.add(w[p][t]);
                    startVal.add(remExtResource);
                    remExtResource = 0;
                }
                else {
                    startVar.add(w[p][t]);
                    startVal.add(Q[p]);
                    remExtResource = remExtResource - Q[p];
                }
            }
        }
        remExtResource = 0;
    }
    // cplex.addMIPStart(startVar, startVal, IloCplex::MIPStartAuto, "secondMIPStart");
    cplex.addMIPStart(startVar, startVal);
    startVal.end();
    startVar.end();
/*************************************************/

作为开始的解决方案,我将所有 x变量 z变量设置为 0 .根据某些逻辑,某些 y变量 0 ,有些为 1 ,而某些 w变量为分配给全部容量 Q [p] ,而其他分配为 0 .

As a starting solution, I make all the x-variables and z-variables to 0. And based on some logic some y-variables are 0 and some are 1, whereas some w-variables are assigned to full capacity Q[p], whereas others are 0.

它具有我遵循的相同逻辑,但是可以找到我在这里错过的东西.你能帮我吗?

It has the same logic I have followed but could find what I have missed here. Could you please help me?

推荐答案

最常见的是,当我看到这种错误时,这是​​因为我试图为不在我问题中的变量添加一个mipstart值.例如,声明了变量,但不涉及任何约束或目标,因此cplex在其提取的模型中没有变量.

Most often when I have seen this sort of error it's because I am trying to add a mipstart value for a variable that is not in my problem. Eg the variables are declared but not involved in any constraints or in the objective, so cplex doesn't have them in its extracted model.

这篇关于在CPLEX C ++中使用addMIPStart()时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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