help-glpk
[Top][All Lists]
Advanced

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

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


From: Andrew Makhorin
Subject: Re: [Help-glpk] GLPK 4_23 internal error in call back
Date: Sun, 11 Nov 2007 23:26:48 +0300

> Thanks for the quick response. My callBack is shown below. I am calling
> glp_delete_prob(lp) only in main and not in the call back

>  --------------------main program-----------------------------
>                  ....
>                 ret = glpk423._glp_lpx_simplex(lp);
>                 ret = glpk423.glp_intopt(lp, piocp);//--piocp pointer to
> param
>                  ...
>                 glpk423.glp_delete_prob(lp);
>                 ....
> --------------------------Call Back ----------------------------
>         public void callBack(IntPtr tree, IntPtr info)
>         {
>             this.StatusText = "Gap = " + glpk423.glp_ios_mip_gap(tree) +
>                 " Reason = " + glpk423.glp_ios_reason(tree);
>           if (glpk423.glp_ios_reason(tree) ==
> (int)glpk423.glpk_reasonCode.GLP_IBINGO) 
>           {  if (glpk423.glp_ios_mip_gap(tree) <= 0.05) 
>                 glpk423.glp_ios_terminate(tree); 
>           } 
>         }

> ---------------------------------------------------------------------------------
>>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.

I am not a C# prorammer and cannot check your code.

Please see the test program (in C) below, which works correctly.

************************************************************************

/* test.c */

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <glpk.h>

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);
      }
      return;
}

int main(int argc, char *argv[])
{     glp_prob *mip;
      glp_iocp parm;
      assert(argc == 2);
      mip = lpx_read_mps(argv[1]);
      assert(mip != NULL);
      glp_simplex(mip, NULL);
      glp_init_iocp(&parm);
      parm.cb_func = cb_func;
      glp_intopt(mip, &parm);
      glp_delete_prob(mip);
      /* check that no memory blocks are still allocated */
      {  int count;
         glp_ulong total;
         glp_mem_usage(&count, NULL, &total, NULL);
         assert(count == 0);
         assert(total.lo == 0 && total.hi == 0);
      }
      return 0;
}

/* eof */

************************************************************************

lpx_read_mps: reading problem data from `p0201.mps'...
lpx_read_mps: problem P0201
lpx_read_mps: 134 rows, 201 columns, 2124 non-zeros
lpx_read_mps: 201 integer columns, all of which are binary
lpx_read_mps: 1513 cards were read
      0:   objval =   0.000000000e+00   infeas =   1.000000000e+00 (0)
     87:   objval =   1.306500000e+04   infeas =   1.772086751e-17 (0)
*    87:   objval =   1.306500000e+04   infeas =   1.497413304e-14 (0)
*   190:   objval =   6.875000000e+03   infeas =   7.347022296e-14 (0)
OPTIMAL SOLUTION FOUND
Integer optimization begins...
+   190: mip =     not found yet >=              -inf        (1; 0)
+   523: >>>>>   7.975000000e+03 >=   6.875000000e+03  13.8% (30; 1)
+  1544: >>>>>   7.675000000e+03 >=   7.065000000e+03   7.9% (106; 22)
+  1544: mip =   7.675000000e+03 >=   7.065000000e+03   7.9% (106; 22)
SEARCH TERMINATED BY APPLICATION






reply via email to

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