alpar@1
|
1 |
/* mplsamp1.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 *lp;
|
alpar@1
|
9 |
glp_tran *tran;
|
alpar@1
|
10 |
int ret;
|
alpar@1
|
11 |
lp = glp_create_prob();
|
alpar@1
|
12 |
tran = glp_mpl_alloc_wksp();
|
alpar@1
|
13 |
ret = glp_mpl_read_model(tran, "egypt.mod", 0);
|
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_generate(tran, NULL);
|
alpar@1
|
19 |
if (ret != 0)
|
alpar@1
|
20 |
{ fprintf(stderr, "Error on generating model\n");
|
alpar@1
|
21 |
goto skip;
|
alpar@1
|
22 |
}
|
alpar@1
|
23 |
glp_mpl_build_prob(tran, lp);
|
alpar@1
|
24 |
ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps");
|
alpar@1
|
25 |
if (ret != 0)
|
alpar@1
|
26 |
fprintf(stderr, "Error on writing MPS file\n");
|
alpar@1
|
27 |
skip: glp_mpl_free_wksp(tran);
|
alpar@1
|
28 |
glp_delete_prob(lp);
|
alpar@1
|
29 |
return 0;
|
alpar@1
|
30 |
}
|
alpar@1
|
31 |
|
alpar@1
|
32 |
/* eof */
|