[Top][All Lists]

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

[Help-glpk] Re: CallBacks with PreSolver

From: Andrew Makhorin
Subject: [Help-glpk] Re: CallBacks with PreSolver
Date: Thu, 05 Jun 2003 00:44:32 +0400

>I am using GLPK 3.3 API as a DLL for some Visual Basic 6 applications.
>I have implemented a call-back to VB with lib_set_print_hook, which
> allows to graphically display the opmization progress, by calls to
> lpx_get_col_info in the VB callback routine.
>This works fine. However, when using the presolver, all calls to
> lpx_get_col_info return 0 as the variable value.
>It seems (although I'm not very good in C) that the presolver uses its
> own internal LPX problem, which is unknown of the API.Callbacks are
> done by this internal simplex, when my calls to lpx_get_col_info still
> refer to the original problem...
>Did I get the problem right?

Yes, the lp presolver transforms the original lp passed to lpx_simplex
as a LPX object into an internal lp represented as another LPX object,
which is then actually solved. Once the transformed lp has been solved,
its basic solution is used to recover the solution of the original lp,
i.e. during the search the original LPX object is not changed.

>Is there a workaround to this ? (which would not imply too heavy C-code
> modifications  )

Accessing the problem object components from the hook routine is very
implementation specific and may not work in future versions of glpk.
If you need to visualize intermediate basic solutions generated by the
simplex solver, the better way which does not use undocumented features
may be the following (I hope it is easy to transpose the fragment below
in VB):

   /* create lp problem */
   lp = lpx_create_prob();
   /* scale the problem (if necessary) */
   /* find an advanced initial basis (if necessary) */
   /* disable lp presolver */
   lpx_set_int_parm(lp, LPX_K_PRESOL, 0);
   /* solve the problem */
   while (2 + 2 == 4)
   {  /* allow at most 100 iterations of the simplex */
      lpx_set_int_parm(lp, LPX_K_ITLIM, 100);
      /* invoke the simplex */
      /* visualize the current basic solution */
      ... = lpx_get_status(lp);
      ... = lpx_get_obj_val(lp);
      ... = lpx_get_col_info(lp, ...);
      /* check if the optimum has been reached */
      if (lpx_get_status(lp) == LPX_OPT) break;
      /* if not, continue the search */

i.e. the idea is to obtain intermediate solutions by limiting the number
of simplex iterations (100 is taken as an example; you can specify any
other limit).

reply via email to

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