alpar@1
|
1 |
/* mplsamp2.c */
|
alpar@1
|
2 |
|
alpar@1
|
3 |
#include <stdio.h>
|
alpar@1
|
4 |
#include <stdlib.h>
|
alpar@1
|
5 |
#include <glpk.h>
|
alpar@1
|
6 |
|
alpar@1
|
7 |
int main(void)
|
alpar@1
|
8 |
{ glp_prob *mip;
|
alpar@1
|
9 |
glp_tran *tran;
|
alpar@1
|
10 |
int ret;
|
alpar@1
|
11 |
mip = glp_create_prob();
|
alpar@1
|
12 |
tran = glp_mpl_alloc_wksp();
|
alpar@1
|
13 |
ret = glp_mpl_read_model(tran, "sudoku.mod", 1);
|
alpar@1
|
14 |
if (ret != 0)
|
alpar@1
|
15 |
{ fprintf(stderr, "Error on translating model\n");
|
alpar@1
|
16 |
goto skip;
|
alpar@1
|
17 |
}
|
alpar@1
|
18 |
ret = glp_mpl_read_data(tran, "sudoku.dat");
|
alpar@1
|
19 |
if (ret != 0)
|
alpar@1
|
20 |
{ fprintf(stderr, "Error on translating data\n");
|
alpar@1
|
21 |
goto skip;
|
alpar@1
|
22 |
}
|
alpar@1
|
23 |
ret = glp_mpl_generate(tran, NULL);
|
alpar@1
|
24 |
if (ret != 0)
|
alpar@1
|
25 |
{ fprintf(stderr, "Error on generating model\n");
|
alpar@1
|
26 |
goto skip;
|
alpar@1
|
27 |
}
|
alpar@1
|
28 |
glp_mpl_build_prob(tran, mip);
|
alpar@1
|
29 |
glp_simplex(mip, NULL);
|
alpar@1
|
30 |
glp_intopt(mip, NULL);
|
alpar@1
|
31 |
ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
|
alpar@1
|
32 |
if (ret != 0)
|
alpar@1
|
33 |
fprintf(stderr, "Error on postsolving model\n");
|
alpar@1
|
34 |
skip: glp_mpl_free_wksp(tran);
|
alpar@1
|
35 |
glp_delete_prob(mip);
|
alpar@1
|
36 |
return 0;
|
alpar@1
|
37 |
}
|
alpar@1
|
38 |
|
alpar@1
|
39 |
/* eof */
|