help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] Wrapper for GLPK API in Java


From: glpk xypron
Subject: [Help-glpk] Wrapper for GLPK API in Java
Date: Sat, 24 Sep 2011 15:18:15 +0200

Using the GLPK API with Java is tedious and not intuitive.

I just published on
http://www.xypron.de/projects/linopt/
a wrapper which provides a much more natural interface.

With the wrapper you can access each row and column by a name and
any number of indices.

This is how columns are created:

Problem p = new Problem().
        setName("Cutting Stock");
// x(i,j) : x pieces of product j are cut from stock i
for (int i = 0; i < stock.length; i++) {
    for (int j = 0; j < product.length; j++) {
    p.column("x", i, j).
            type(Problem.ColumnType.INTEGER).
            bounds(0., null);
    }
}

Creating and populating rows looks like this:

// demand(j) = sum( x(i,j) )
for (int j = 0; j < product.length; j++) {
    p.row("demand", j).
            bounds(demand[j], demand[j]);
    for (int i = 0; i < stock.length; i++) {
        p.row("demand", j).
            add(1., "x", i, j);
    }
}

You may download the code with
svn checkout http://www.xypron.de/svn/linopt/ linopt
or use my Maven repository.

Best regards

Xypron
-- 
Follow me at http://twitter.com/#!/xypron

Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]