help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Sample code


From: Andrew Makhorin
Subject: Re: [Help-glpk] Sample code
Date: Wed, 9 Jan 2008 21:26:28 +0300

> I need some example C code where an mps file is read and then optimized.
> I need it for both a MIP where I'd like to be able to use the intopt and
> cuts options and a pure LP.  Can anyone help?

> I know I had it at one time, but I can't find it on my machine or in the
> archives (where I'm sure I'm missing it).

> Any help would be appreciated.

You can start from something like this:

#include <glpk.h>

int main(void)
{     glp_prob *prob;
      int ret;
      prob = lpx_read_mps("foo.mps");
      if (prob == NULL) goto err;
      /* solve lp relaxation */
      glp_scale_prob(prob); /* optional */
      glp_adv_basis(prob);  /* optional */
      ret = glp_simplex(prob, NULL);
      if (ret != 0) goto err;
      /* find mip solution */
      {  glp_iocp parm;
         glp_init_iocp(&parm);
         /* set/change some control parameters here */
         ret = glp_intopt(prob, &parm);
         if (ret != 0) goto err;
      }
      ...
      glp_delete_prob(prob);
      return 0;
}






reply via email to

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