lemon-project-template-glpk
view deps/glpk/examples/mplsamp1.c @ 11:4fc6ad2fb8a6
Test GLPK in src/main.cc
author | Alpar Juttner <alpar@cs.elte.hu> |
---|---|
date | Sun, 06 Nov 2011 21:43:29 +0100 |
parents | |
children |
line source
1 /* mplsamp1.c */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <glpk.h>
7 int main(void)
8 { glp_prob *lp;
9 glp_tran *tran;
10 int ret;
11 lp = glp_create_prob();
12 tran = glp_mpl_alloc_wksp();
13 ret = glp_mpl_read_model(tran, "egypt.mod", 0);
14 if (ret != 0)
15 { fprintf(stderr, "Error on translating model\n");
16 goto skip;
17 }
18 ret = glp_mpl_generate(tran, NULL);
19 if (ret != 0)
20 { fprintf(stderr, "Error on generating model\n");
21 goto skip;
22 }
23 glp_mpl_build_prob(tran, lp);
24 ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps");
25 if (ret != 0)
26 fprintf(stderr, "Error on writing MPS file\n");
27 skip: glp_mpl_free_wksp(tran);
28 glp_delete_prob(lp);
29 return 0;
30 }
32 /* eof */