bug-glpk
[Top][All Lists]
Advanced

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

[Bug-glpk] (no subject)


From: glpk xypron
Subject: [Bug-glpk] (no subject)
Date: Sun, 28 Feb 2010 10:46:55 +0100

Hello Andrew,

in the example below I have implemented a callback function.
For testing, please, provide the name of an MIP GMPL file
as only argument (e.g. examples/tsp.mod).

The problem name is set before entering glp_intopt.

glp_get_prob_name(glp_ios_get_prob(tree)) does not return
the problem name but null in the call back function.

Why does glp_prob_name(tree) not return the same
pointer as the one passed to glp_int_opt?

Please, change the code to provide the problem name
in the call back function.

Best regards

Xypron



#include <stdio.h>
#include "glpk.h"

/**
 * Call back function for MIP solver
 */
void cb(glp_tree *tree, void *info) {
   glp_prob *prob;
   prob = glp_ios_get_prob(tree);
   if (glp_ios_reason(tree) == GLP_IBINGO) { 
     printf("callback problem name = %s\n", glp_get_prob_name(prob));
     }
   }

int main(int argc, char **args) {
  glp_prob *prob;
  glp_tran *tran;
  glp_iocp iocp;
  int ret;

  if (argc != 2) {
    printf("usage:\ntest model.mod\n");
    return 1;
  }
  prob = glp_create_prob();
  tran = glp_mpl_alloc_wksp();
  if (0 != glp_mpl_read_model(tran, args[1], 0)) {
    glp_mpl_free_wksp(tran);
    glp_delete_prob(prob);
    printf("file not found %s", args[1]);
    return 1;
  }
  glp_mpl_generate(tran, NULL);
  glp_mpl_build_prob(tran, prob);
  glp_init_iocp(&iocp);
  iocp.presolve = GLP_ON;
  iocp.cb_func = cb;
  printf("problem name for intopt = %s\n", glp_get_prob_name(prob));
  glp_intopt(prob, &iocp);
  glp_mpl_postsolve(tran, prob, GLP_MIP);
  glp_mpl_free_wksp(tran);
  glp_delete_prob(prob);
  return 0;
}

-- 
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser




reply via email to

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