> Can anybody please tell me where I can find more examples on C > programs which use GLPK API routines in order to solve MIP problems ? > I am looking for something similar to example (sample.c) mentioned in > glpk.pdf manual, but to solve MIP (mixed integer linear) problem instead > of LP.
The following main program reads MIP problem instance in free MPS format from file flugpl.mps, constructs an advanced initial basis, solves LP relaxation with the primal simplex method, finds integer optimal solution, and writes the solution to file flugpl.txt. (The instance flugpl.mps can be found in the Miplib 3.0 problem set; see http://www.caam.rice.edu/~bixby/miplib/miplib3.html .) /* mipsamp.c */ #include <stdio.h> #include <stdlib.h> #include <glpk.h> int main(void) { glp_prob *P; P = glp_create_prob(); glp_read_mps(P, GLP_MPS_FILE, NULL, "flugpl.mps"); glp_adv_basis(P, NULL); glp_simplex(P, NULL); glp_intopt(P, NULL); glp_print_mip(P, "flugpl.txt"); glp_delete_prob(P); return 0; } /* eof */ Below here is shown the terminal output from this example program. Reading problem data from `flugpl.mps'... Problem: FLUGPL Objective: KOSTEN 19 rows, 18 columns, 64 non-zeros 11 integer variables, none of which are binary 111 records were read Constructing initial basis... Size of triangular part = 19 0: obj = 9.702000000e+05 infeas = 7.530e+03 (0) * 7: obj = 1.174572591e+06 infeas = 0.000e+00 (0) * 8: obj = 1.167185726e+06 infeas = 0.000e+00 (0) OPTIMAL SOLUTION FOUND Integer optimization begins... + 8: mip = not found yet >= -inf (1; 0) + 115: >>>>> 1.201800000e+06 >= 1.179568889e+06 1.8% (51; 30) + 146: >>>>> 1.201500000e+06 >= 1.182909259e+06 1.5% (54; 50) + 248: mip = 1.201500000e+06 >= tree is empty 0.0% (0; 369) INTEGER OPTIMAL SOLUTION FOUND Writing MIP solution to `flugpl.txt'... _______________________________________________ Help-glpk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-glpk
