Angelıque
Angelıque

Reputation: 15

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:

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:

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?

Upvotes: 0

Views: 286

Answers (1)

Alex Fleischer
Alex Fleischer

Reputation: 10059

To set the name of x[1][2] to x[1][2] you can write:

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

Upvotes: 1

Related Questions