lemon-project-template-glpk

annotate deps/glpk/examples/mplsamp2.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 /* mplsamp2.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 *mip;
alpar@9 9 glp_tran *tran;
alpar@9 10 int ret;
alpar@9 11 mip = glp_create_prob();
alpar@9 12 tran = glp_mpl_alloc_wksp();
alpar@9 13 ret = glp_mpl_read_model(tran, "sudoku.mod", 1);
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_read_data(tran, "sudoku.dat");
alpar@9 19 if (ret != 0)
alpar@9 20 { fprintf(stderr, "Error on translating data\n");
alpar@9 21 goto skip;
alpar@9 22 }
alpar@9 23 ret = glp_mpl_generate(tran, NULL);
alpar@9 24 if (ret != 0)
alpar@9 25 { fprintf(stderr, "Error on generating model\n");
alpar@9 26 goto skip;
alpar@9 27 }
alpar@9 28 glp_mpl_build_prob(tran, mip);
alpar@9 29 glp_simplex(mip, NULL);
alpar@9 30 glp_intopt(mip, NULL);
alpar@9 31 ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
alpar@9 32 if (ret != 0)
alpar@9 33 fprintf(stderr, "Error on postsolving model\n");
alpar@9 34 skip: glp_mpl_free_wksp(tran);
alpar@9 35 glp_delete_prob(mip);
alpar@9 36 return 0;
alpar@9 37 }
alpar@9 38
alpar@9 39 /* eof */