[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] [Fwd: Get the MIp relative gap at the end of the optimiz
From: |
oguyon |
Subject: |
Re: [Help-glpk] [Fwd: Get the MIp relative gap at the end of the optimization] |
Date: |
Wed, 20 Jul 2011 01:20:08 -0700 (PDT) |
Thank you Andrew and Xypron,
So, I've implemented a callback function for my purpose. Here is my code :
public void callback(glp_tree tree) {
long now = System.currentTimeMillis();
if(now - start >= 5000){
double mipGap = GLPK.glp_ios_mip_gap(tree);
if(mipGap <= 0.01){
GLPK.glp_ios_terminate(tree);
}
}
}
But I still have a problem. The function GLPK.glp_ios_terminate(tree) does
not make exactly what I want. In fact, it terminates the search by setting a
status GLPKConstants.GLP_UNDEF to my model (even if GLPK has found an
integer feasible solution). it's a problem for me.
Does anyone know how to make a better termination of my program through the
callback function, in order to get a status GLPKConstants.GLP_FEAS if an
integer solution has already been found.
Thank you,
Olivier
xypron wrote:
>
> Hello Olivier,
>
>> > I'm using glpk 4.45 through a Java environnement (JRE 1.6.0_24).
>>
>> I don't know details how the callback is implemented in the Java
>> interface. In C its entry point address is passed to glp_intopt thru the
>> glp_iocp control parameter block (2nd parameter).
>
> GLPK for Java is available for download at
> http://glpk-java.sourceforge.net
> It comes with the following examples showing how to use callbacks:
> examples\java\Gmpl.java
> examples\java\GmplSwing.java
>
> Documentation is provided in
> doc\glpk-java.pdf
>
> In GLPK for Java method GLPK.glp_init_iocp(iocp) presets
> the address for the callback such that the C callback calls
> Java method GlpkCallback.callback(long cPtr).
>
> You need an object of a class implementing interface
> org.gnu.glpk.GlpkCallbackListener.
>
> You register it with
> GlpkCallback.addListener(listener);
>
> When a callback occurs method callback of the listener is called.
>
> To find out the reason why the callback is called use
> int reason = GLPK.glp_ios_reason(tree);
>
> You may compare it to constants like
> GLPKConstants.GLP_IBINGO
>
> To stop listening use
> GlpkCallback.removeListener(listener);
>
> Best regards
>
> Xypron
>
> --
> NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-glpk
>
>
--
View this message in context:
http://old.nabble.com/-Fwd%3A-Get-the-MIp-relative-gap-at-the-end-of-the%09optimization--tp32094140p32097429.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.