Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Suppress mixed integer programming output

I am running code on a remote server in which I solve many small mixed integer programs(using the .solve() method). I tested my code on my local machine with no issues. However, when I run it remotely it seems that the Sage installation there does not suppress output from .solve(). I get many, many prints to the console which look like:

glp_exact: 224 rows, 196 columns, 588 non-zeros
GNU MP bignum library is being used
      0:   infsum =                      2   (11)
     47:   infsum =                      0   (11)
*    47:   objval =       1.39285714285714   (12)
*   205:   objval =      0.660714285714286   (5)
OPTIMAL SOLUTION FOUND

It would be very helpful to not have Sage constantly printing to the console; is there a way to suppress this output? Some sort of flag, maybe, when I run Sage?

Suppress mixed integer programming output

I am running code on a remote server in which I solve many small mixed integer programs(using the .solve() method). I tested my code on my local machine with no issues. However, when I run it remotely it seems that the Sage installation there does not suppress output from .solve(). I get many, many prints to the console which look like:

glp_exact: 224 rows, 196 columns, 588 non-zeros
GNU MP bignum library is being used
      0:   infsum =                      2   (11)
     47:   infsum =                      0   (11)
*    47:   objval =       1.39285714285714   (12)
*   205:   objval =      0.660714285714286   (5)
OPTIMAL SOLUTION FOUND

It would be very helpful to not have Sage constantly printing to the console; is there a way to suppress this output? Some sort of flag, maybe, when I run Sage?

EDIT: In response to David Coudert's comment, here is the kind of behavior I'm seeing, on a relevant snippet:

sage: def opt(x):
....:     mip = MixedIntegerLinearProgram(maximization=False, solver="GLPK/exact")
....:     mip.add_constraint(mip[0]+mip[1] <= 1)
....:     mip.add_constraint(mip[0]-mip[1] <= 1)
....:     mip.add_constraint(-mip[0]-mip[1] <= 1)
....:     mip.add_constraint(-mip[0]+mip[1] <= 1)
....:     mip.set_objective(mip[0]+x*mip[1])
....:     return mip.solve()
....: 
sage: [opt(n) for n in range(3)]
glp_exact: 4 rows, 2 columns, 8 non-zeros
GNU MP bignum library is being used
*     0:   objval =                      0   (0)
*     2:   objval =                     -1   (0)
OPTIMAL SOLUTION FOUND
glp_exact: 4 rows, 2 columns, 8 non-zeros
GNU MP bignum library is being used
*     0:   objval =                      0   (0)
*     1:   objval =                     -1   (0)
OPTIMAL SOLUTION FOUND
glp_exact: 4 rows, 2 columns, 8 non-zeros
GNU MP bignum library is being used
*     0:   objval =                      0   (0)
*     2:   objval =                     -2   (0)
OPTIMAL SOLUTION FOUND
[-1.0, -1.0, -2.0]

I would only like to have the final line of output printed to the console, yet am also finding the three pieces from GLPK put there too.

Suppress mixed integer programming output

I am running code on a remote server in which I solve many small mixed integer programs(using the .solve() method). I tested my code on my local machine with no issues. However, when I run it remotely it seems that the Sage installation there does not suppress output from .solve(). I get many, many prints to the console which look like:

glp_exact: 224 rows, 196 columns, 588 non-zeros
GNU MP bignum library is being used
      0:   infsum =                      2   (11)
     47:   infsum =                      0   (11)
*    47:   objval =       1.39285714285714   (12)
*   205:   objval =      0.660714285714286   (5)
OPTIMAL SOLUTION FOUND

It would be very helpful to not have Sage constantly printing to the console; is there a way to suppress this output? Some sort of flag, maybe, when I run Sage?

EDIT: In response to David Coudert's comment, here is the kind of behavior I'm seeing, on a relevant snippet:

sage: def opt(x):
....:     mip = MixedIntegerLinearProgram(maximization=False, solver="GLPK/exact")
....:     mip.add_constraint(mip[0]+mip[1] <= 1)
....:     mip.add_constraint(mip[0]-mip[1] <= 1)
....:     mip.add_constraint(-mip[0]-mip[1] <= 1)
....:     mip.add_constraint(-mip[0]+mip[1] <= 1)
....:     mip.set_objective(mip[0]+x*mip[1])
....:     return mip.solve()
....: 
sage: [opt(n) for n in range(3)]
glp_exact: 4 rows, 2 columns, 8 non-zeros
GNU MP bignum library is being used
*     0:   objval =                      0   (0)
*     2:   objval =                     -1   (0)
OPTIMAL SOLUTION FOUND
glp_exact: 4 rows, 2 columns, 8 non-zeros
GNU MP bignum library is being used
*     0:   objval =                      0   (0)
*     1:   objval =                     -1   (0)
OPTIMAL SOLUTION FOUND
glp_exact: 4 rows, 2 columns, 8 non-zeros
GNU MP bignum library is being used
*     0:   objval =                      0   (0)
*     2:   objval =                     -2   (0)
OPTIMAL SOLUTION FOUND
[-1.0, -1.0, -2.0]

I would only like to have the final line of output printed to the console, yet am also finding the three pieces from GLPK put there too.

EDIT 2: I realized I forgot to mention that I'm running Sage 7.4 and that I may have trouble installing CPLX or Gurobi on the server since I do not have admin privileges there. These appear to be the only solvers which allow for the "logfile" approach.