Hello,
I am using cplex 12.10 to create and solve a model in Java. The problem is a large MIP. In this model I create a constraint of the following form:
(-10.0E7*bin(A,B) + 1.0*x(A) - 1.0*x(B)) <= 21.609175078904347
bin(A,B) is a binary variable (cplex.boolVar()), while x(A) ad x(B) are numVars (cplex.numVar()). The intention is that either
- the difference x(A)-x(B) is smaller than 21.609175078904347 OR
- bin(A,B) is forced to be set to one, thereby fulfilling this constraint trivially. The sum over all binary variables is minimized, i.e., I want the binary variable to be 0.
This constraint is created as follows in a class which extends IloCplex:
IloRange constraint = le(sum(sum(sum(prod(-1, x_b), x_a), -21.609175078904347), prod(-100000000, bin_a_b)), 0);
System.out.println(constraint);
add(constraint);
The System output prints the following line
IloRange : -infinity <= (-10.0E7*bin(A,B) + 1.0*x(A) - 1.0*x(B)) <= 21.609175078904347
Then I export the model to an .lp file format with the following command (outside of the class, in the class which has access to the IloCplex object):
my_cplex.exportModel(/path/to/file/location);
This creates a file called exported_model.lp. In that file I find the following constraint
c1789: - x(B) + x(A) - 100000000 bin(A,B) <= 32.1204280114237
As you can see the model has changed the number on the right hand side of the constraint from 21.609175078904347 to 32.1204280114237. This leads to the situation where solutions with a too big difference between x(A) and x(B) are counted as valid solutions.
I have no explanation for this behavior and am pretty lost, after looking for an error in my model. Is there any cplex behavior which could explain the difference between the console output and the immediately following export of the model?
Thank you for your help.
Here is some additional information, which I have gathered in the process of finding an error in this program.
Between creating the constraint and adding the constraint to the program there are no additional steps. Further you can see that there is a large number of other constraints in the model, some of which also access x(A) and x(B).
Between creating the constraint and exporting the model there are also no additional steps. Specifically nothing which changes a constraint. The solving process of the model is not started yet. Cplex does not produce any console output up to the export process. In the export process the following output is created:
Warning: Output names have been modified due to duplicate names or characters invalid in LP format.
Default row names c1, c2 ... being created.
When solving the model, it produces the following output:
Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de
CPXPARAM_Threads 1
Tried aggregator 4 times.
MIP Presolve eliminated 407 rows and 11 columns.
MIP Presolve modified 407 coefficients.
Aggregator did 231 substitutions.
Reduced MIP has 22748 rows, 7425 columns, and 59455 nonzeros.
Reduced MIP has 3608 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.05 sec. (40.90 ticks)
Probing time = 0.01 sec. (1.07 ticks)
Tried aggregator 1 time.
Detecting symmetries...
Reduced MIP has 22748 rows, 7425 columns, and 59455 nonzeros.
Reduced MIP has 3608 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.04 sec. (23.18 ticks)
Probing time = 0.00 sec. (1.06 ticks)
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Root relaxation solution time = 1.14 sec. (1370.27 ticks)
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0 0 integral 0 22.0008 22.0008 18591 -0.00%
Elapsed time = 1.40 sec. (1541.95 ticks, tree = 0.00 MB, solutions = 1)
Root node processing (before b&c):
Real time = 1.40 sec. (1542.17 ticks)
Sequential b&c:
Real time = 0.00 sec. (0.00 ticks)
------------
Total (root+branch&cut) = 1.40 sec. (1542.17 ticks)
Solution for model found!
------------------------------
Soeren Nickel
------------------------------
#DecisionOptimization