[Cbc] WIP: javaCbc

Rafael.Lopez at lri.fr Rafael.Lopez at lri.fr
Fri May 21 21:14:14 EDT 2010


Recently, I found myself wanting to reuse code I had written to generate
large (quadratic) knapsack instances, which was written in Java, only this
time, instead of creating lp files which would be passed to Cbc/Cplex, I
wanted to directly call the solver, run the B&B, and then extract the
solution. While Cplex already has java bindings, there is no such thing
included with cbc, and the only solution I found is swimp, which I found
quite the headache to even simply compile (still haven't succeded, in
fact).

However, the idea of using swig to generate a java interface to the native
Cbc libraries was interesting, and I recall some people mentioning doing
their own interfaces using swig for some osi classes. I set out to make my
own version, and keep it small and as straightforward as possible. That is
how javaCbc came to be: I needed a fairly simple way to interface with
Cbc, so that I can load or create a model, solve it, and get results, and
possibly modify the model and get information about it. It is probably not
perfect, after all, this is the first time I use swig, so after some trial
and error, I think I found a good compromise between the complexity and
functionality.

In other terms, what javaCbc is: a simple way to call key functions of Cbc
from java; what javaCbc isn't: a full fledged interface to every single
function in the Cbc/Clp/etc libraries. It is small (13k), simple to
install (put it in your cbc directory, edit the Makefile to double check
the paths to the headers/libs and to java, run make) and doesn't require a
million additional tools compared to cbc: you need the java 6 sdk (haven't
tested with openjava) and swig. It might even work with just cbc and the
sdk, but I haven't had the time to test on a clean environment without
swig present.

The archive is locaed at http://airelle.info/prog/javacbc.tar.gz and a
small page was made with instructions at
http://airelle.info/index.php?option=com_content&view=article&id=56



Rafael Lopez




More information about the Cbc mailing list