【发布时间】:2018-01-18 19:37:43
【问题描述】:
我正在将 cplex 与 java 一起使用,并且我正在尝试在 cplex 中求解这个方程,例如,
U = A + B
其中A和B是表达式,U是目标函数,所有这些表达式U、A和B都是数组
这是我的一段代码
IloLinearIntExpr[] U = new IloLinearIntExpr[n];
IloLinearIntExpr[] A = new IloLinearIntExpr[n];
IloLinearIntExpr[] B = new IloLinearIntExpr[n];
for(int i = 0; i < n; i++){
U[i] = cplex.linearIntExpr();
A[i] = cplex.linearIntExpr();
B[i] = cplex.linearIntExpr();
}
for(int i = 0; i < n; i++){
B[i].addTerm(1, P(X));
B[i].addTerm(1, C(Y));
A[i].addTerm(X, 1);
U[i].addTerm(cplex.sum(A[i],B[i])); // it seems to be there is a problem here
cplex.addMaximize(U[i]);
}
如果我们添加两个表达式,cplex 似乎有问题,请你在这个问题上建议我。
【问题讨论】:
-
请在您的问题中包含错误信息。