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.

32 lines
784 B

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