chiark / gitweb /
print best solution
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 7 Mar 2014 16:50:18 +0000 (16:50 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 7 Mar 2014 16:50:18 +0000 (16:50 +0000)
main.c

diff --git a/main.c b/main.c
index 006c071..9e7b0ed 100644 (file)
--- a/main.c
+++ b/main.c
@@ -121,6 +121,7 @@ static void optimise(int doprint) {
 
   /* x_minimum >= 0 */
   glp_set_col_bnds(prob, X_minimum, GLP_LO, 0, 0);
+  glp_set_col_name(prob, X_minimum, "minimum");
 
   /* objective is maximising x_minimum */
   glp_set_obj_dir(prob, GLP_MAX);
@@ -138,6 +139,11 @@ static void optimise(int doprint) {
       /* x_morefrag_i_j >= 0 */
       int X_morefrag_i_j = glp_add_cols(prob, 1);
       glp_set_col_bnds(prob, X_morefrag_i_j, GLP_LO, 0, 0);
+      if (doprint) {
+       char buf[255];
+       snprintf(buf,sizeof(buf),"mf %d,%d",i,j);
+       glp_set_col_name(prob, X_morefrag_i_j, buf);
+      }
 
       /* x_total_i += x_morefrag_i_j */
       /* x_total_j += x_morefrag_i_j */
@@ -244,6 +250,8 @@ int main(int argc, char **argv) {
   prep();
   iterate();
   printf("\n");
+  if (best_prob)
+    glp_print_sol(best_prob,"/dev/stdout");
   if (ferror(stdout) || fclose(stdout)) { perror("stdout"); exit(-1); }
   return 0;
 }