help-glpk
[Top][All Lists]
Advanced

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

[Help-glpk] different solutions for same code


From: hussin hassen
Subject: [Help-glpk] different solutions for same code
Date: Tue, 1 Sep 2009 11:11:06 -0700 (PDT)

Hello ,

I wrote a code in "mathprog" to solve MILP problem. The code is running fine 
with GLPK stand alone solver with the following options:
--dfs --first --mir --gomory --cover --tmlim 10
the minimum price is : 928173
But after solving the same code (and same data) using API routines as shown 
below , I got differen price of : 949072 (and different solution).
Can any body explain why ? is there any thing missing in my C++ code shown 
below?

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

int main(void)
{     glp_prob *mip;
      glp_iocp parm;
      glp_tran *tran;
      int ret;
      mip = glp_create_prob();
      tran = glp_mpl_alloc_wksp();
      ret = glp_mpl_read_model(tran, "mycode.mod", 1);
      if (ret != 0)
      {  fprintf(stderr, "Error on translating model\n");
         goto skip;
      }
      ret = glp_mpl_read_data(tran, "mycode.dat");
      if (ret != 0)
      {  fprintf(stderr, "Error on translating data\n");
         goto skip;
      }
      ret = glp_mpl_generate(tran, NULL);
      if (ret != 0)
      {  fprintf(stderr, "Error on generating model\n");
         goto skip;
      }
      glp_mpl_build_prob(tran, mip);
      glp_simplex(mip, NULL);
      glp_init_iocp (&parm) ;
      parm.br_tech = GLP_BR_FFV ;
      parm.bt_tech = GLP_BT_DFS ;
      parm.gmi_cuts = GLP_ON ;
      parm.mir_cuts = GLP_ON ;
      parm.cov_cuts = GLP_ON ;
      parm.tm_lim = 10000 ;
      ret = glp_intopt(mip, &parm);
      ret = glp_mpl_postsolve(tran, mip, GLP_MIP); 
      if (ret != 0)
         fprintf(stderr, "Error on postsolving model\n");
      glp_print_mip(mip, "mycode.txt"); 
skip: glp_mpl_free_wksp(tran);
      glp_delete_prob(mip);
      return 0;
}

/* eof */


      




reply via email to

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