1

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.

asked Apr 29, 2017 at 17:02
5
  • one more thing, this is a very pressing matter so I'll part with 100 of my hard earned Rep as bounty if you can solve this. Commented Apr 29, 2017 at 17:03
  • That Apache solver is LP only. ojalgo has an integer programming solver. Also there are a lot of java based CP solvers e.g. Choco Commented Apr 29, 2017 at 17:30
  • I am trying out Ojalgo right now. I let you know. Commented Apr 29, 2017 at 17:37
  • @ErwinKalvelagen. Ojalgo is throwing a java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;. Suppose it cannot run on android?? Commented Apr 29, 2017 at 18:59
  • I believe the source is available, so you should be able to fix that. Commented May 1, 2017 at 12:39

2 Answers 2

3

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.

answered May 1, 2017 at 15:33

2 Comments

The use of java.lang.management has been removed from recent builds of ojAlgo - it only depends on the compact1 profile. Further it seems support for Java 8 language features is coming to Android. developer.android.com/studio/preview/features/…
@apete. Thanks for the info. I will try that.
3

Just to fix ShahiM's answer:

answered May 8, 2017 at 11:11

2 Comments

Note that this is BSD-4, so you will have to credit the publisher if you advertise any component that uses the library.
You have to credit the publisher if you advertise the use of the software (e.g. "Choco Solver inside", or "global cardinality constraint inside"). You do not HAVE TO credit the publisher (but you can do it :-)) if you advertise your software, even if that software uses Choco Solver, as long as your add is referring to your software and not Choco Solver features BSD clause:"All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the the organization ."

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.