equal
deleted
inserted
replaced
|
1 /* mplsamp2.c */ |
|
2 |
|
3 #include <stdio.h> |
|
4 #include <stdlib.h> |
|
5 #include <glpk.h> |
|
6 |
|
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 } |
|
38 |
|
39 /* eof */ |