-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppressing output for optimize!
#1883
Comments
This is currently a solver-specific option, see jump-dev/MathOptInterface.jl#663 for a proposal of solver-independent option. For |
Just a remark:
-- Maurice |
These options are solver-specific. We will be implementing a JuMP option to set the log-level to 0 to avoid this. |
You should be able to do |
Just two remarks:
If you are interested in catching the solver's output, see also this post |
Hi Z_OP = Model(with_optimizer(GLPK.Optimizer))
@variable(Z_OP, x[l,m], Bin)
@constraint(Z_OP, e_pac*x .<= e_part)
@objective(Z_OP, Min, sum(B.*x))
optimize!(Z_OP)
X = value.(x)
Z = JuMP.objective_value(Z_OP) |
@lausilvag See jump-dev/GLPK.jl#132 for a reply to your question. |
Hello, Sorry for re-raising an old issue but I'm having trouble with this as well and can't work out what I'm doing wrong. Here are the things I've tried, all of which do not appear to suppress output: model::Model = Model(with_optimizer(Clp.Optimizer, LogLevel=0)) model = Model(Clp.Optimizer) model = Model(Clp.Optimizer) model = Model(Clp.Optimizer) I re-run (via I am using JuMP v0.21.4 |
Use Note that some solvers still print output, even when their printing level option is set to the minimum. We won't be providing a work-around for this because there are general Julia ones: https://discourse.julialang.org/t/consistent-way-to-suppress-solver-output/20437/6?u=odow |
Bonjour,
I have this problem too (only with Clp so I rename the subject).
Le 1 nov. 2020 à 22:38, Oscar Dowson ***@***.***> a écrit :
Use set_silent(model).
This was good enough for Clp, at least with version v0.7.1.
But not since recently after updating my packages.
[a076750e] CPLEX v0.7.2
[9961bab8] Cbc v0.7.1
[e2554f3b] Clp v0.8.2
[4076af6c] JuMP v0.21.5
I suppose some debug messages bypass the [Ll]og[Ll]evel system?
Here are some logs from a test:
Coin0506I Presolve 29 (-91) rows, 20 (-180) columns and 58 (-262) elements
Clp0006I 0 Obj 29128.996 Primal inf 126.12002 (11)
Clp0006I 22 Obj 30390
Clp0000I Optimal - objective value 30390
Coin0511I After Postsolve, objective 30390, infeasibilities - dual 0 (0), primal 0 (0)
Clp0032I Optimal objective 30390 - 22 iterations time 0.002, Presolve 0.00
Coin0506I Presolve 29 (-91) rows, 20 (-180) columns and 58 (-262) elements
Clp0006I 0 Obj -2751.002 Primal inf 270.75679 (19)
Clp0006I 24 Obj 700
Clp0000I Optimal - objective value 700
Coin0511I After Postsolve, objective 700, infeasibilities - dual 0 (0), primal 0 (0)
Clp0032I Optimal objective 700 - 24 iterations time 0.002, Presolve 0.00
Extract from another test:
Coin0506I Presolve 29 (-91) rows, 20 (-180) columns and 58 (-262) elements
Clp0006I 0 Obj 24128.996 Primal inf 178.14002 (12)
Clp0006I 21 Obj 25650
Clp0000I Optimal - objective value 25650
Coin0511I After Postsolve, objective 25650, infeasibilities - dual 0 (0), primal 0 (0)
Clp0032I Optimal objective 25650 - 21 iterations time 0.002, Presolve 0.00
Coin0506I Presolve 29 (-91) rows, 20 (-180) columns and 58 (-262) elements
Clp0006I 0 Obj 29128.996 Primal inf 126.12002 (11)
Clp0006I 22 Obj 30390
Clp0000I Optimal - objective value 30390
…-- Maurice
Note that some solvers still print output, even when their printing level option is set to the minimum. We won't be providing a work-around for this because there are general Julia ones: https://discourse.julialang.org/t/consistent-way-to-suppress-solver-output/20437/6?u=odow
|
Hi @diam As noted by @odow , they won't be providing a workaround as there are general Julia ones. In my case, I'm doing these optimizations in a loop, and simply redirecting stdout (as is suggested in the link above) isn't a great workaround anyway as it makes using Clp slower than GLPK. So for now, I stick with GLPK. Not ideal but not much else I can do. |
Thank you Takuya,
So I guess it's a bug with Coin-Clp solver (I was not sure about that)? Now I understand that the capture of stdout is the only workaround until Coin-Clp is fixed.
As working in a scholar institut (ENSTA Paris) I can use CPLEX, but I like showing to students that JuMP allow us to choose a different solver simply with a command line switch (e.g --xsolver cplex|glpk|clp) from our application.
…-- Maurice
Le 2 nov. 2020 à 09:30, Takuya Iwanaga ***@***.***> a écrit :
Hi @diam
As noted by @odow , they won't be providing a workaround as there are general Julia ones.
In my case, I'm doing these optimizations in a loop, and simply redirecting stdout (as is suggested in the link above) isn't a great workaround anyway as it makes using Clp slower than GLPK. So for now, I stick with GLPK. Not ideal but not much else I can do.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
This may be a regression in Clp.jl. I will investigate. Edit: it was a bug in Clp.jl: jump-dev/Clp.jl#102 |
We adopt the solution outlined by @odow in jump-dev/JuMP.jl#1883 (comment).
We adopt the solution outlined by @odow in jump-dev/JuMP.jl#1883 (comment).
We adopt the solution outlined by @odow in jump-dev/JuMP.jl#1883 (comment).
We adopt the solution outlined by @odow in jump-dev/JuMP.jl#1883 (comment).
We adopt the solution outlined by @odow in jump-dev/JuMP.jl#1883 (comment).
A note for posterity: I came across this issue because I had had trouble silencing
Setting the
Redirecting
In the end, I needed to also flush stdio:
|
We adopt the solution outlined by @odow in jump-dev/JuMP.jl#1883 (comment).
We adopt the solution outlined by @odow in jump-dev/JuMP.jl#1883 (comment).
This is jump-dev/Cbc.jl#168.
Use HiGHS instead.
…On Fri, 17 Feb 2023, 6:25 pm Vincent Tjeng, ***@***.***> wrote:
A note for posterity:
I came across this issue because I had had trouble silencing Cbc.jl
output in my test suite. Without specifying any parameters, we get four
lines of output:
julia> using JuMP, Cbc
julia> model = Model(Cbc.Optimizer);
julia> @variable(model, 0 <= x <= 2); @variable(model, 0 <= y <= 30); @constraint(model, 1x + 5y <= 3); @objective(model, Max, 5*x + 3*y);
julia> optimize!(model)
Presolve 0 (-1) rows, 0 (-2) columns and 0 (-2) elements
Optimal - objective value 10.6
After Postsolve, objective 10.6, infeasibilities - dual 0 (0), primal 0 (0)
Optimal objective 10.6 - 0 iterations time 0.002, Presolve 0.00
Setting the logLevel flag had no impact.
julia> model2 = Model(optimizer_with_attributes(Cbc.Optimizer, Dict("logLevel" => 0)...));
julia> @variable(model2, 0 <= x <= 2); @variable(model2, 0 <= y <= 30); @constraint(model2, 1x + 5y <= 3); @objective(model2, Max, 5*x + 3*y);
julia> optimize!(model2)
Presolve 0 (-1) rows, 0 (-2) columns and 0 (-2) elements
Optimal - objective value 10.6
After Postsolve, objective 10.6, infeasibilities - dual 0 (0), primal 0 (0)
Optimal objective 10.6 - 0 iterations time 0.002, Presolve 0.00
set_silent, suggested by @odow <https://github.com/odow> in #1883
(comment)
<#1883 (comment)>,
has no impact
julia> set_silent(model3)
julia> @variable(model3, 0 <= x <= 2); @variable(model3, 0 <= y <= 30); @constraint(model3, 1x + 5y <= 3); @objective(model3, Max, 5*x + 3*y);
julia> optimize!(model3)
Presolve 0 (-1) rows, 0 (-2) columns and 0 (-2) elements
Optimal - objective value 10.6
After Postsolve, objective 10.6, infeasibilities - dual 0 (0), primal 0 (0)
Optimal objective 10.6 - 0 iterations time 0.002, Presolve 0.00
Redirecting stdout (
https://discourse.julialang.org/t/consistent-way-to-suppress-solver-output/20437/4)
works on the command line, but did not work in tests
julia> model4 = Model(Cbc.Optimizer);
julia> @variable(model4, 0 <= x <= 2); @variable(model4, 0 <= y <= 30); @constraint(model4, 1x + 5y <= 3); @objective(model4, Max, 5*x + 3*y);
julia> redirect_stdout(devnull) do
optimize!(model4)
end
In the end, I needed to also flush stdio:
julia> model5 = Model(Cbc.Optimizer);
julia> @variable(model5, 0 <= x <= 2); @variable(model5, 0 <= y <= 30); @constraint(model5, 1x + 5y <= 3); @objective(model5, Max, 5*x + 3*y);
julia> function optimize_silent!(m)
redirect_stdout(devnull) do
optimize!(m)
# Required, per https://discourse.julialang.org/t/consistent-way-to-suppress-solver-output/20437/9
Base.Libc.flush_cstdio()
end
end
optimize_silent! (generic function with 1 method)
julia> optimize_silent!(model5)
—
Reply to this email directly, view it on GitHub
<#1883 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6MQJJMBMTSY2NJWNLJYZDWX4DSZANCNFSM4G3EZGZQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thanks; used your suggestion in vtjeng/MIPVerify.jl#133. |
Hello,
Is there a way (a keyword argument to the solver or
optimize!
) to suppress the output ofoptimize!
?When I use the Cbc Solver to solve the following toy problem I get the following output:
This is highly inconvenient when one uses the solver inside a loop.
When I use the GLPK solver instead I do not encounter the same problem.
Btw this was not an issue in Jump 0.18.
Any thoughts?
The text was updated successfully, but these errors were encountered: