lemon-project-template-glpk
diff deps/glpk/examples/mplsamp1.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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/deps/glpk/examples/mplsamp1.c Sun Nov 06 20:59:10 2011 +0100 1.3 @@ -0,0 +1,32 @@ 1.4 +/* mplsamp1.c */ 1.5 + 1.6 +#include <stdio.h> 1.7 +#include <stdlib.h> 1.8 +#include <glpk.h> 1.9 + 1.10 +int main(void) 1.11 +{ glp_prob *lp; 1.12 + glp_tran *tran; 1.13 + int ret; 1.14 + lp = glp_create_prob(); 1.15 + tran = glp_mpl_alloc_wksp(); 1.16 + ret = glp_mpl_read_model(tran, "egypt.mod", 0); 1.17 + if (ret != 0) 1.18 + { fprintf(stderr, "Error on translating model\n"); 1.19 + goto skip; 1.20 + } 1.21 + ret = glp_mpl_generate(tran, NULL); 1.22 + if (ret != 0) 1.23 + { fprintf(stderr, "Error on generating model\n"); 1.24 + goto skip; 1.25 + } 1.26 + glp_mpl_build_prob(tran, lp); 1.27 + ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps"); 1.28 + if (ret != 0) 1.29 + fprintf(stderr, "Error on writing MPS file\n"); 1.30 +skip: glp_mpl_free_wksp(tran); 1.31 + glp_delete_prob(lp); 1.32 + return 0; 1.33 +} 1.34 + 1.35 +/* eof */