0

I would like to know if there is another form of coding that could be used (within CPLEX) to have the same results as in the code below:

dvar int+ n[1..2];

dexpr float z = - 3*n[1]^2 - 4*n[2]^2 - 4*n[1]*n[2] 
                + 5000*n[1] + 2000*n[2];    

maximize z;


subject to {
  ct1:    - 7*n[1] - 2*n[2]  <= -3000;
  ct2:    - 5 * n[1] - 3 *n[2] <= -2000;
}

1 Answers1

0

within CPLEX you could also use Constraint Programming:

using CP;

dvar int+ n[1..2] in 0..10000;

dexpr float z = - 3*n[1]^2 - 4*n[2]^2 - 4*n[1]*n[2] 
                + 5000*n[1] + 2000*n[2];    

maximize z;


subject to {
  ct1:    - 7*n[1] - 2*n[2]  <= -3000;
  ct2:    - 5 * n[1] - 3 *n[2] <= -2000;
}

gives the same result but relies on CPOptimizer

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15