简体   繁体   English

在 lp 文件 cplex 和 C++ 上写入 model

[英]Writing the model on lp file cplex and C++

I have coded the following constraint in C++ and solving the problem by Calling cplex solver:我在 C++ 中编写了以下约束,并通过调用 cplex 求解器解决了这个问题:

for (IloInt p = 0; p < 3; ++p) {
    for (IloInt t = 0; t < 6; ++t) {
      IloExpr v(env);
      for (IloInt m = 0; m < 5; ++m)
           v += X[p][m][t];
    model.add(v == K[p][t]);
    v.end();
}
 }

What I expect:我期望的是:

X[1][1][1]+X[1][2][1]+X[1][3][1]+X[1][4][1]+X[1][5][1]=K[1][1]

However, when I export the.lp file, I get: I get:但是,当我导出 .lp 文件时,我得到: 我得到:

c1: x1 + x2 + x3 + x4 + x5 = constant

c2: x6 + x7 + x8 + x9 + x10 = constant

c3: x11 + x12 + x13 + x14 + x15 = constant

…...………………………………..………

………………...……......………..….

c18: x86 + x87 + x88 + x89 + x90 = quantity

How can I solve this problem?我怎么解决这个问题?

To set the name of x[1][2] to x[1][2] you can write:要将 x[1][2] 的名称设置为 x[1][2],您可以这样写:

x[1][2].setName("x[1][2]");

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

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