lemon-project-template-glpk
annotate 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 |
rev | line source |
---|---|
alpar@9 | 1 /* mplsamp1.c */ |
alpar@9 | 2 |
alpar@9 | 3 #include <stdio.h> |
alpar@9 | 4 #include <stdlib.h> |
alpar@9 | 5 #include <glpk.h> |
alpar@9 | 6 |
alpar@9 | 7 int main(void) |
alpar@9 | 8 { glp_prob *lp; |
alpar@9 | 9 glp_tran *tran; |
alpar@9 | 10 int ret; |
alpar@9 | 11 lp = glp_create_prob(); |
alpar@9 | 12 tran = glp_mpl_alloc_wksp(); |
alpar@9 | 13 ret = glp_mpl_read_model(tran, "egypt.mod", 0); |
alpar@9 | 14 if (ret != 0) |
alpar@9 | 15 { fprintf(stderr, "Error on translating model\n"); |
alpar@9 | 16 goto skip; |
alpar@9 | 17 } |
alpar@9 | 18 ret = glp_mpl_generate(tran, NULL); |
alpar@9 | 19 if (ret != 0) |
alpar@9 | 20 { fprintf(stderr, "Error on generating model\n"); |
alpar@9 | 21 goto skip; |
alpar@9 | 22 } |
alpar@9 | 23 glp_mpl_build_prob(tran, lp); |
alpar@9 | 24 ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps"); |
alpar@9 | 25 if (ret != 0) |
alpar@9 | 26 fprintf(stderr, "Error on writing MPS file\n"); |
alpar@9 | 27 skip: glp_mpl_free_wksp(tran); |
alpar@9 | 28 glp_delete_prob(lp); |
alpar@9 | 29 return 0; |
alpar@9 | 30 } |
alpar@9 | 31 |
alpar@9 | 32 /* eof */ |