lemon-project-template-glpk
view deps/glpk/examples/mplsamp2.c @ 9:33de93886c88
Import GLPK 4.47
author | Alpar Juttner <alpar@cs.elte.hu> |
---|---|
date | Sun, 06 Nov 2011 20:59:10 +0100 |
parents | |
children |
line source
1 /* mplsamp2.c */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <glpk.h>
7 int main(void)
8 { glp_prob *mip;
9 glp_tran *tran;
10 int ret;
11 mip = glp_create_prob();
12 tran = glp_mpl_alloc_wksp();
13 ret = glp_mpl_read_model(tran, "sudoku.mod", 1);
14 if (ret != 0)
15 { fprintf(stderr, "Error on translating model\n");
16 goto skip;
17 }
18 ret = glp_mpl_read_data(tran, "sudoku.dat");
19 if (ret != 0)
20 { fprintf(stderr, "Error on translating data\n");
21 goto skip;
22 }
23 ret = glp_mpl_generate(tran, NULL);
24 if (ret != 0)
25 { fprintf(stderr, "Error on generating model\n");
26 goto skip;
27 }
28 glp_mpl_build_prob(tran, mip);
29 glp_simplex(mip, NULL);
30 glp_intopt(mip, NULL);
31 ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
32 if (ret != 0)
33 fprintf(stderr, "Error on postsolving model\n");
34 skip: glp_mpl_free_wksp(tran);
35 glp_delete_prob(mip);
36 return 0;
37 }
39 /* eof */