help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Strange Question


From: cgi2
Subject: Re: [Help-glpk] Strange Question
Date: Wed, 03 Mar 2004 15:31:16 -0800

On Tue, 2 Mar 2004 16:10:19 -0700
"Welson Sun" <address@hidden> wrote:
>Hi all, I have met a strange question with Glpk, can you help me out?
> 
>I am using Glpk in Cygwin under WindowsXP. Since currently there is no
>Windows makefile for Glpk JNI, I used the precompiled version from
>address@hidden .
> 
>My LP problem is quite simple:
> 
>Minimize C1X1 + C2X2 + ..... + CnXn
>So that
>    Xi - Xj <= Wij ( 1 <= i,j <= n )
> 
>Where all X are integer and all Wij are non-negtive integer.
> 
>The first strange problem is that I can use simplex() method to solve this,
>while I cannot use integer() method to solve this, the later will report:
> 
>GlpkMsg: lpx_integer: optimal solution of LP relaxation required
> 
>I have set the problem to be MIP type, so how can this be possible?

You have to first solve using simplex and then call the integer solver like so:

solver.simplex();
solver.integer();

>The second strange problem is that I cannot retrieve the X solution
>correctly when the number of X is greater than 40. It will solve the
>problem, I have tested with 1000 X variables, but it just cannot retrieve
>the solution, sometimes it will report:
>ufree: ptr = 0095CB90; memory allocation error
>And sometimes, it just exits when it is in the middle of retriving solution.

I experience this too. I think it's a bug in the JNI. The following workaround 
solves the problem though:
Don't let the solver object get garbage collected. I do this by putting the 
object into a static List after I'm done
with it. I release its memory before doing so using the command 
solver.deleteProb(). It's not a perfect solution but
works.

public static final List keepers = new LinkedList();
keepers.add(solver);
Do this in some class that itself doesn't get garbage collected till the end of 
all processing.

-M

________________________________________________
Don't E-Mail, ZipMail! http://www.zipmail.com/




reply via email to

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