Reputation: 1037
I have a .mod file and want to solve the LP within it with GLPK.
I know there is a method by using the cmd (Windows) with glpsol -m name.mod
but then I will have to parse the output result which I want to avoid.
Is there a method by using the glpk libraries for Java to get the .mod file solve it and then get the output without the parsing and cmd part?
Upvotes: 0
Views: 405
Reputation: 1037
So there is possible way to get the output of glpk without parsing it manually. The following code is from an answer seen from this link: Input/output in GLPK for Java
static void writeMipSolution(glp_prob lp) {
String name = GLPK.glp_get_obj_name(lp);
double val = GLPK.glp_mip_obj_val(lp);
System.out.println(name + " = " + val);
int n = GLPK.glp_get_num_cols(lp);
for (int i = 1; i <= n; i++) {
name = GLPK.glp_get_col_name(lp, i);
val = GLPK.glp_mip_col_val(lp, i);
System.out.println(name + " = " + val);
}
}
Upvotes: 0