ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 20 Sep 2021 06:38:57 +0200Suppress mixed integer programming outputhttps://ask.sagemath.org/question/59104/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.zjsMon, 20 Sep 2021 06:38:57 +0200https://ask.sagemath.org/question/59104/suppressing output in notebookhttps://ask.sagemath.org/question/7857/suppressing-output-in-notebook/How can I suppress output in notebook? In terminal mode I can write simply a semicolon after the command, but it does not work in notebooks.czsanSat, 08 Jan 2011 18:09:30 +0100https://ask.sagemath.org/question/7857/