这个错误有什么建议吗?

时间:2016-09-26 19:25:34

标签: java cplex

  

错误:(198,32)java:没有为addTerm找到合适的方法(double,ilog.concert.IloIntVar [])方法ilog.concert.IloLinearIntExpr.addTerm(int,ilog.concert.IloIntVar)不适用        (参数不匹配;可能从double转换为int的有损转换)      方法ilog.concert.IloLinearIntExpr.addTerm(ilog.concert.IloIntVar,int)不适用        (参数不匹配; double无法转换为ilog.concert.IloIntVar)

//for Virtual link Variable Y i,j m,n,k and flow variable F i,j m,n,k

IloIntVar[][][][][] ylink=new IloIntVar[VNVert_k][VNVert_k][VNVert_k][VNVert_k][];
IloIntVar[][][][][] flink=new IloIntVar[VNVert_k][VNVert_k][VNVert_k][VNVert_k][];
for (int i = 0; i < VNVert_k; i++) {
    for (int j = 0; j < VNVert_k; j++) {
        for (int k = 0; k < VNVert_k; k++) {
            for (int l = 0; l < VNVert_k; l++) {
                ylink[i][j][k][l]=cplex.intVarArray(VNVert_k,0,1);
                flink[i][j][k][l]=cplex.intVarArray(VNVert_k,0,1);

            }
        }
    }
}


//---------------------------- Constraints
IloLinearNumExpr exp1 = cplex.linearNumExpr();
IloLinearNumExpr exp2 = cplex.linearNumExpr();
IloLinearNumExpr exp3 = cplex.linearNumExpr();
IloLinearIntExpr exp4 = cplex.linearIntExpr();

for (int i = 0; i <SubVert ; i++) {
    for (int j = 0; j < SubVert; j++) {
        //constraint
        exp1.addTerm(M,xlink[i][j]);
        //constraint 5 ∑ Xij=1
        exp2.addTerm(1,xlink[i][j]);
        cplex.addLe(exp2,1);
        // constriant 6 ∑ Xij=1
        exp3.addTerm(1,xlink[i][j]);
        cplex.addEq(exp3,1);
        for (int k = 0; k <SubVert ; k++) {
            for (int l = 0; l < VNVert_k; l++) {
                //contraint 1
                exp4.addTerm(1.0,flink[i][j][k][l]);
                cplex.addGe(exp1,exp4);
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

根据错误消息,当您需要addTerm时,您需要double int