[OS] Java: how to start?

Olivier Cailloux olivier.cailloux at ecp.fr
Thu Jan 28 08:18:44 EST 2010


Oops, missing the xml file, sorry.

Thank you for your fast answer.

Kipp Martin a écrit :
> Hi Olivier:
>
> First, thank you very much for your interest in OS.
>
>
>> - I can't find how to create a correct osil file representing a 
>> simple problem instance. Must be something I didn't get with the way 
>> the coefficients are stored, etc. (Reading from the Optimization 
>> Services 2.0 User’s Manual, Section 11). I have found the example 
>> file OSTestCode.cpp, but when trying to follow the same logic with a 
>> simpler model (two constraints), it does not seem to produce a 
>> correct osil file.
>
> Well this is my fault for not making the writing more clear. Perhaps 
> this will help. Attached is the OSiL file for the following linear 
> program
>
> Max 10*x0 + 9*x1
> s.t.
> .7*x0 + x1 <= 630
> .5*x0 + 0.833333333333333333333*x1 <=600
> 1*x0 + 0.666666666666666666667*x1 <= 708
> .1*x0 + .25*x1 <= 135
I made several more tries but am still unable to find what is my
mistake. I am trying to input the following model.
/* Decision variables */
var gjb2 >=0;
var gjb3 >=0;
var s2 >= 0;
var s3 >= 0;
/* Objective function */
minimize sumofslack: s2 + s3;
/* Constraints */
s.t. lowcat : gjb2 + s2 = 3;
s.t. highcat : gjb3 - s3 - 0.1 = 3;
end;

Attached is the xml osil file I obtained with one of my tries. I don't
see why it is incorrect. (It uses column layout instead of row but I
also tried with row layout with no success.)

>> - Is there any complete working example in the form of a Java piece 
>> of code, defining a problem with a few variables and constraints, and 
>> solving it locally?
>
> No, you will find it much easier to interface with the COIN-OR solvers 
> through C++.
It is important for me to be able to call solvers from Java because I
have several other important pieces of code written in Java (to access
the data, represent problem instance etc.). I would like to avoid
communication between a Java and a C++ piece of code if possible (
error-prone and difficult to do), hence I thought that the Java
implementation of COIN OS was the way to go. Do you think it is not
possible to do this?
>
>> => When calling solver.solve() on a GLPKSover() instance, it 
>> apparently tries to call a web service, as the oril file I receive 
>> says that it "Cannot run program 
>> .../webapps/os/WEB-INF/code/solver/OSSolverServiceLinux", and also 
>> contains 
>> "<serviceURI>http://127.0.1.1:8080/os/OSSolverService.jws</serviceURI>". 
>
>> How to specify I want to simply launch my local GLPK instance? 
>> (CoinSolver() doesn't work either, but maybe for a different reason.)
>> - How to make the command line tool OSSolverService use my glpk 
>> instance? "./OSSolverService -solver clp -osil .../parincLinear.osil" 
>> works, but "./OSSolverService -solver glpk -osil 
>> .../parincLinear.osil" yields "the GLPK solver requested is not 
>> present" (although glpk is installed and works on my system).
>
> Here is the problem -- we cannot link to the glpk library and 
> distribute that binary due the incompatibility of the CLP and GPL. 
> Hence, if you want to use Glpk you actually have to build the 
> OSSolverService from source with the Glpk source code present in 
> ThirdParty/Glpk and then ./OSSolverService -solver glpk -osil 
> .../parincLinear.osil
>
> will work.
Ok, I understand that licence issue. Anyway I was using the command line
solver only to understand how it works and test the link, my ultimate
goal is to call the glpk solver (or others) from the code.

Any help on how to use the GLPKSover() class (or other programmatic
means from Java) to do that would be appreciated.
Olivier


-------------- next part --------------
A non-text attachment was scrubbed...
Name: osil1.xml
Type: text/xml
Size: 1629 bytes
Desc: not available
Url : http://list.coin-or.org/pipermail/os/attachments/20100128/4a492ed9/attachment.xml 


More information about the OS mailing list