javalinear-programmingojalgo

Speed of ojAlgo linear programming solver


I'm pretty new to linear programming, I did solve my first problem with lpsolve (binary dll called from Java, via the JavaILP wrapper to have a more object-oriented code) and it was very fast (50 ms).

I then decided to avoid native code (if possible) and re-wrote everything using ojAlgo and for my 2100 variables problem the solution time has increased from 50 ms to 1089 ms.

Is this speed normal / expected?

Is it because ojAlgo is using BigDecimal (not so sure it is so, I've seen doubles in the code there and there) and lpsolve is probably using ints?

Can I do something about it?

On the other hand the maximum found increased from 1013 to OPTIMAL 1249, which is good. (using lpsolve I didn't even know a better solution existed)

edit: I didn't notice that a few expression names were clashing and I guess this made them overwrite one another; now I fixed that and an OPTIMAL 1013 solution is found… in 8270 ms.


Solution

  • It's perfectly normal for a pure java solver to be slower than native code.

    Do you have integer variables? If you do then this is a MIP, and those can be quite hard to solve.

    ojAlgo separates between model and solver. The model uses BigDecimal internally. The model analyses the problem and calls different solvers depending on problem characteristics. The solvers can work with whatever number type they want. The built-in ojAlgo solvers work with primitive double.

    You can plug in whichever solver you like in ojAlgo. There are already integrations for 3 top commercial solvers:

    https://github.com/optimatika/ojAlgo-extensions/tree/develop/ojAlgo-cplex

    https://github.com/optimatika/ojAlgo-extensions/tree/develop/ojAlgo-gurobi

    https://github.com/optimatika/ojAlgo-extensions/tree/develop/ojAlgo-mosek

    There are also other pure java, open source, LP solvers available:

    https://github.com/optimatika/ojAlgo-extensions/tree/develop/ojAlgo-joptimizer

    https://github.com/optimatika/ojAlgo-extensions/tree/develop/ojAlgo-commons-math3

    There is not yet an integration for lpsolve...