examples/mplsamp1.c
changeset 1 c445c931472f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/examples/mplsamp1.c	Mon Dec 06 13:09:21 2010 +0100
     1.3 @@ -0,0 +1,32 @@
     1.4 +/* mplsamp1.c */
     1.5 +
     1.6 +#include <stdio.h>
     1.7 +#include <stdlib.h>
     1.8 +#include <glpk.h>
     1.9 +
    1.10 +int main(void)
    1.11 +{     glp_prob *lp;
    1.12 +      glp_tran *tran;
    1.13 +      int ret;
    1.14 +      lp = glp_create_prob();
    1.15 +      tran = glp_mpl_alloc_wksp();
    1.16 +      ret = glp_mpl_read_model(tran, "egypt.mod", 0);
    1.17 +      if (ret != 0)
    1.18 +      {  fprintf(stderr, "Error on translating model\n");
    1.19 +         goto skip;
    1.20 +      }
    1.21 +      ret = glp_mpl_generate(tran, NULL);
    1.22 +      if (ret != 0)
    1.23 +      {  fprintf(stderr, "Error on generating model\n");
    1.24 +         goto skip;
    1.25 +      }
    1.26 +      glp_mpl_build_prob(tran, lp);
    1.27 +      ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps");
    1.28 +      if (ret != 0)
    1.29 +         fprintf(stderr, "Error on writing MPS file\n");
    1.30 +skip: glp_mpl_free_wksp(tran);
    1.31 +      glp_delete_prob(lp);
    1.32 +      return 0;
    1.33 +}
    1.34 +
    1.35 +/* eof */