How to perform Integer Linear Programming in Apach

2019-09-17 08:18发布

The org.apache.commons.math3.optim.linear package in Apache Commons Math Library allows Linear Optimization but the returned values are double. Is there any way to perform Integer Linear Programming using this library? I tried googling but there seems to be no mention of ILP anywhere.

Alternatively, is there any other Java library that can do ILP? please not that I need to run this on android so SCPSolver, GLPK, Or-tools. etc. are not possible.

Thanks in advance.

2条回答
贪生不怕死
2楼-- · 2019-09-17 08:52

Just to fix ShahiM's answer:

查看更多
时光不老,我们不散
3楼-- · 2019-09-17 09:12

As this question and 'Linear Programming in Android' in general is a rarely discussed topic, I figured I would post my findings here for anyone searching in the future.

BTW, I ended up using a port of Ojalgo, given below.

These are the LP Libs that I found can be readily imported into an android project :

Apache Commons Math

Perhaps the most well maintained library, this one supports Linear Optimization but does not have "Integer" LP.

The next two libraries do support Integer LP and/or Mixed Integer LP.

Choco Solver

Even though the Latest version of Choco (4.0) is based on Java 8, there is a Java 7 variant of version 3.3.3 . You can find it here. This imports into Android Studio without any issues.

Another issue you might run into is that even though there are guides and tutorials on their website for version 4, you wont be able to find any guides for Choco 3 except for the Javadocs. But fortunately someone had made a PDF of the older guides which you can get by Googling "Choco3 User Manual".

Also note that Choco is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. So if you want to use LP in a commercial project, consider the next option.

Oj! Algorithms

Ojalgo is another great library which has an MIT Licence and supports Java 7. But as I found out, it uses a couple of Java calls that is not available in Android.

Luckily, an MVP has ported the library to work in Android : KIC/ojAlgoAndroid

This port ran with no issues. I have forked and created a release on Jitpack : shahimclt/ojAlgoAndroid.

查看更多
登录 后发表回答