[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Java interface to GLPK - accessing result values
From: |
xypron |
Subject: |
Re: [Help-glpk] Java interface to GLPK - accessing result values |
Date: |
Fri, 13 Feb 2009 11:07:39 -0800 (PST) |
Hello Hartwig,
>> I plan to use GLPK by a Java application.
>> My question is about the step after solving the model. I want to further
>> use the result
>> values (values of decision variables after successful model solve) in my
>> Java application.
>> I created a solution which avoids files and databases.
it is not necessary to use a file or a database to access solutions. I only
tried
to keep my example GLPKSwig.java as simple as possible.
Methods are provided by the API to retrieve the result values. These are
described
in doc/gmpl.pdf of the GLPK source distribution
ftp://ftp.gnu.org/gnu/glpk/glpk-4.36.tar.gz
Here you will also find all methods needed to create the problem
without using an input file.
See the example below.
Best regards
Xypron
/**
* write MIP solution
* @param lp problem
*/
static void write_mip_solution(glp_prob lp)
{
int i;
int n;
String name;
double val;
n = GLPK.glp_get_num_cols(lp);
for(i=1; i <= n; i++)
{
name = GLPK.glp_get_col_name(lp, i);
val = GLPK.glp_mip_col_val(lp, i);
System.out.printf("%s = %f\n", name, val);
}
}
/**
* write simplex solution
* @param lp problem
*/
static void write_lp_solution(glp_prob lp)
{
int i;
int n;
String name;
double val;
n = GLPK.glp_get_num_cols(lp);
for(i=1; i <= n; i++)
{
name = GLPK.glp_get_col_name(lp, i);
val = GLPK.glp_get_col_prim(lp, i);
System.out.printf("%s = %f\n", name, val);
}
}
--
View this message in context:
http://www.nabble.com/Java-interface-to-GLPK---accessing-result-values-tp21935750p22002924.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.