0
votes

I implemented a LP problem in IBM Optimization Studio using OPL to create the model. After verification of the model I wanted to put it in Java to script the parameters for simulation purposes. I found the quickest way to use my OLP model in Java with the following code:

IloOplFactory.setDebugMode(false);
IloOplFactory oplF = new IloOplFactory();
IloOplErrorHandler errHandler = oplF.createOplErrorHandler(System.out);
IloOplModelSource modelSource = oplF.createOplModelSource("myModel.mod");
IloCplex cplex = null;
cplex = oplF.createCplex();
IloOplSettings settings = oplF.createOplSettings(errHandler);
IloOplModelDefinition def = oplF.createOplModelDefinition(modelSource, settings);
IloOplModel opl = oplF.createOplModel(def, cplex);

String inDataFile = "myData.dat";
IloOplDataSource dataSource = oplF.createOplDataSource(inDataFile);
opl.addDataSource(dataSource);

opl.generate();
opl.convertAllIntVars(); // converts integer bounds into LP compatible format
if (cplex.solve()) {
        double obj = opl.getCplex().getObjValue();
        System.out.println("OBJECTIVE: " + obj);
}

Now the problem is if I run "myModel.mod" and "myData.dat" in both IBM Optimization studio and Java that I get VERY different objective results.

In IBM Optimization Studio:

solution (optimal) with objective 125

In Java:

Parallel mode: deterministic, using up to 4 threads for concurrent optimization.
Tried aggregator 1 time.
LP Presolve eliminated 0 rows and 1 columns.
Reduced LP has 5280 rows, 5325 columns, and 25525 nonzeros.
Presolve time = 0.01 sec. (3.77 ticks)

Iteration log . . .
Iteration:     1   Dual objective     =             0.000000
Iteration:   345   Dual objective     =            90.297455
Iteration:   568   Dual objective     =           117.206047
Perturbation started.
Iteration:   707   Dual objective     =           117.206047
Removing perturbation.
Reinitializing dual norms . . .

Dual simplex solved model.

OBJECTIVE: 117.20608137232513

I looked at the data set and my model and an objective of less than 125 should NOT even be possible (I used extreme values to make sure that one of my objective variables was 125, so anything below that should not be possible).

Does anyone know why these results are different? Is it perhaps something in the settings of Java compared to IBM? Is it possible for me to import my IBM optimization studio settings to Java also to test this?

Thank you!

EDIT: here are the IBM Optimization studio logs, I forgot to include those. It does show a lot more info about integers being cut off but this is my first experience with both programs so could someone please help me locate where the problem is or what this all means?

Found incumbent of value 125.000000 after 0.00 sec. (0.53 ticks)
Tried aggregator 1 time.
MIP Presolve eliminated 5027 rows and 4764 columns.
MIP Presolve modified 1191 coefficients.
Reduced MIP has 253 rows, 562 columns, and 1958 nonzeros.
Reduced MIP has 562 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.02 sec. (8.46 ticks)
Probing fixed 8 vars, tightened 0 bounds.
Probing time = 0.00 sec. (2.86 ticks)
Tried aggregator 1 time.
MIP Presolve eliminated 158 rows and 306 columns.
MIP Presolve modified 293 coefficients.
Reduced MIP has 95 rows, 256 columns, and 632 nonzeros.
Reduced MIP has 256 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.02 sec. (1.73 ticks)
Probing fixed 6 vars, tightened 0 bounds.
Probing time = 0.00 sec. (0.12 ticks)
Tried aggregator 1 time.
MIP Presolve eliminated 29 rows and 30 columns.
MIP Presolve modified 2 coefficients.
Reduced MIP has 66 rows, 226 columns, and 522 nonzeros.
Reduced MIP has 226 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.42 ticks)
Probing time = 0.00 sec. (0.07 ticks)
Clique table members: 34.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 4 threads.
Root relaxation solution time = 0.00 sec. (0.36 ticks)

    Nodes                                         Cuts/
   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap

*     0+    0                          125.0000      123.0000             1.60%
      0     0      123.8469     4      125.0000      123.8469       62    0.92%
      0     0        cutoff            125.0000                     81    0.00%
Elapsed time = 0.09 sec. (17.09 ticks, tree = 0.00 MB, solutions = 1)

Zero-half cuts applied:  1
Gomory fractional cuts applied:  1

Root node processing (before b&c):
  Real time             =    0.09 sec. (17.22 ticks)
Parallel b&c, 4 threads:
  Real time             =    0.00 sec. (0.00 ticks)
  Sync time (average)   =    0.00 sec.
  Wait time (average)   =    0.00 sec.
                      ------------
Total (root+branch&cut) =    0.09 sec. (17.22 ticks)

Edit 2: I found that my integer values in my matrix 0..1 are not being rounded to 0 or 1 but instead are counted as 0.932... How can I force Java cplex to round my integers?

SOLVED: it was "opl.convertAllIntVars();" which converted everything to doubles. I took this from sample code and removed it, everything works fine now.

1

1 Answers

0
votes

Your model will be different in some way. I suspect something in the way that integer variables may be handled - the value 125 is rather a round number, while 117.2 is clearly not integer and the log shows it is being solved as a straight LP.

Look at the values of the variables in your two models' solutions and find where the values are different. Hopefully many of the variable values will be similar in both solutions, which should help to narrow your search.

Try exporting your model as an LP file or similar in both and compare the generated models. Maybe solve the two exported models in the CPLEX command line solver, and compare the logs and results.

Try fixing some values from one solution in the other model and re-solve.

Also, give us more of the log output from the OPL model.