You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
992 B

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