简体   繁体   English

Java / Cplex约束的线性化

[英]Linearization of a constraint for java/cplex

I have a constraint that i need to incorporate in my java/cplex program. 我有一个需要纳入我的java / cplex程序的约束。 the constraint is: 约束是:

(forall q: x[i][j][q][k])(t[i][k]+s[i]+distance[i][j]-t[j][k]) <= 0        forall k, i, j

if I put it in just like that, I get the cplex 5002 (is not positive semi-definite) error because the formulation is not linear. 如果这样输入,则会得到cplex 5002(不是正半定)错误,因为公式不是线性的。 I did the following to linearize the constraint and avoid the problem: 我进行了以下操作以线性化约束并避免该问题:

for(int k=0; k<Ausführung.k; k++){
for(int i=1; i<grossI.length; i++){
    for(int j=1; j<grossJ.length; j++){
        //for(int q=1; q<grossQ.length; q++){
        IloLinearNumExpr sumLastTerm = model.linearNumExpr();
        for(int q=1; q<grossQ.length; q++){
            sumLastTerm.addTerm(-1.0,  w[i][j][q][k]);
        }   
        IloConstraint con = model.addLe(model.sum(model.prod(-2000, sumLastTerm), model.sum(t[i][k], model.sum(Data.service[i], model.sum(distance[i][j], model.prod(-1.0, t[j][k]))))), 0); 
        con.setName("NB (9.7)."+k + i);
    }
}
}

Now, I get a "Row 'NB (9.7).01' infeasible, all entries at implied bounds." 现在,我得到“行'NB(9.7).01'不可行,所有条目均处于隐含边界”。 error message. 错误信息。 I tells me that the error lies in this constraint, just when starting to iterate through it. 我告诉我,错误就在于此约束,就在开始对其进行迭代时。 Can anybody tell me where my mistake is or otherwise verify that it must lie somewhere else? 谁能告诉我我的错误在哪里,或者可以证明它必须位于其他地方?

Ok, the problem was that I forgot the neutralizing "1" in the first term of the inequation. 好的,问题是我忘记了不等式第一项中和的“ 1”。 Hence it should be: 因此应该是:

-2000(1-w[i][j][q][k]) +t[i][j]+s[i]+d[i][j]-t[i][k] <= 0

As that "1" was missing in the first term, the left part of the inequation was not neutralized for the case w[i][j][q][k] == 1. 由于第一项中缺少“ 1”,因此对于w [i] [j] [q] [k] == 1的情况,不等式的左侧部分未被抵消。

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

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