help-glpk
[Top][All Lists]
Advanced

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

Re: Re [Help-glpk] : GLPK 4_23 internal error in call back


From: ms
Subject: Re: Re [Help-glpk] : GLPK 4_23 internal error in call back
Date: Tue, 13 Nov 2007 00:33:37 +0300

Thanks for your reply and the link to your C# wrapper. It is very useful. In
my case, I compiled the GLPK 4.23 source using
Build_glpk_with_VC6_MT_DLL.bat file in VS2005 to generate glpk_4_23.dll. I
wrote a C# wrapper class, similar to what you provided, to call the APIs
using P/Invoke. It worked well except for the call back which I need to
terminate the solution when the mip gap reaches a given value. The problem I
believe is in my declation of of glp_iocp structure in C# and pinning it
from being moved around by the Garbage Collector.

In the meantine, I poked around the GLPK source and found I can pass the
mip_gap via an undocumented parameter, LPX_K_MIPGAP, using 
_glp_lpx_set_real_parm(lp, LPX_K_MIPGAP, mp_gap). This allowed me to use
_glp_lpx_intopt(lp) instead of glp_intopt(lp, &parm) which requires me to
pass the glp_iocp structure containing the mip_gap and the callback method.
This struct ls the one that is still giving me headaches. In the meantime, I
am quite content with using _glp_lpx_intopt(lp) and _glp_lib_print_hook
which gives me the solution progress and terminates when the limit is
reached set by _glp_lpx_set_real_parm(lp, LPX_K_MIPGAP, mp_gap). 

Thanks
ms



yo yo wrote:
> 
> Please also note that there is a C# wrapper for GLPK called GLPKSharp that
> you can find here http://yoyovicksblog.blogspot.com/
> Although I didn't update it for a while, it is meant to ease the
> development of C# application using GLPK.
> 
> Thanks,
> YO.
> 
> ----- Message d'origine ----
> De : Andrew Makhorin <address@hidden>
> A : ms <address@hidden>
> Cc : address@hidden
> Envoye le : Dimanche, 11 Novembre 2007, 18h35mn 23s
> Objet : Re: [Help-glpk] GLPK 4_23 internal error in call back
> 
>> I am using GLPK 4.23 for solving a MIP problem and using call back
>  suggested
>> by Andrew Makhorin to exit when the MIP gap is <= 5%
> 
>> ---------------------------------------------------
>> void cb_func(glp_tree *tree, void *info) 
>> {     if (glp_ios_reason(tree) == GLP_IBINGO) 
>>       {  if (glp_ios_mip_gap(tree) < 0.10) 
>>             glp_ios_terminate(tree); 
>>       } 
>>       . . . 
>> } 
> 
>> int main(void) 
>> {     glp_prob *mip; 
>>       glp_iocp parm; 
>>       . . . 
>>       glp_init_iocp(&parm); 
>>       parm.cb_func = cb_func; 
>>       glp_intopt(mip, &parm); 
>>       . . . 
>> } 
>>
> 
> -------------------------------------------------------------------------------------
> 
>> The call back works fine upto certain point when I get the following
>  error:
> 
>> GLPK internal error: lp->tree == NULL; file ..\src\glpapi01.c, line
>  1147
> 
>> I compiled the source using VS2005 and calling the API's in C#. If I
>  don't
>> use use call backs the program works fine. But I don't have control
>  over the
>> mip gap. Any suggestion will be appreciated.
> 
>> Sam
>> -------------output-----------------------------------------
>> 11:02:09 AM *  1341:   objval =  8.225886544e+002   infeas = 
>> 5.280220705e-013 (0)
>> 11:02:09 AM OPTIMAL SOLUTION FOUND
>> 11:02:09 AM Integer optimization begins...
>> Gap = 1.79769313486232E+308 Reason = 6
>> Gap = 1.79769313486232E+308 Reason = 7
>> 11:02:10 AM +  1341: mip =     not found yet >=              -inf    
>     (1;
>> 0)
>> Gap = 1.79769313486232E+308 Reason = 1
>> Gap = 1.79769313486232E+308 Reason = 3
>> Gap = 1.79769313486232E+308 Reason = 4
>> Gap = 1.79769313486232E+308 Reason = 5
>> Gap = 1.79769313486232E+308 Reason = 7
>> 11:02:13 AM +  1341: mip =     not found yet >=  8.225886544e+002    
>     (2;
>> 0)
>> Gap = 1.79769313486232E+308 Reason = 1
>> Gap = 1.79769313486232E+308 Reason = 3
>> Gap = 1.79769313486232E+308 Reason = 4
>> Gap = 1.79769313486232E+308 Reason = 5
>> Gap = 1.79769313486232E+308 Reason = 7
>> 11:02:17 AM +  1345: mip =     not found yet >=  8.225886544e+002    
>     (3;
>> 0)
>> 11:02:17 AM GLPK internal error: lp->tree == NULL; file
>  ..\src\glpapi01.c,
>> line 1147
> 
> 
> Looks like you call glp_delete_prob (directly or indirectly) in the
> callback routine that is not allowed (there must be an error message
> which is not implemented yet). The callback routine should only call
> glp_ios_terminate and return, in which case glp_intopt will return
> immediately with the code GLP_ESTOP.
> 
> 
> 
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-glpk
> 
> 
> 
> 
> 
>      
> _____________________________________________________________________________ 
> Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo!
> Mail
> 
> 
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-glpk
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Re-%3A-GLPK-4_23-internal-error-in-call-back-tf4791011.html#a13714489
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.








reply via email to

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