Skip to content
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

Log an optimizer's output to somewhere else, instead of simply in Julia REPL? #3903

Closed
WalterMadelim opened this issue Dec 25, 2024 · 1 comment

Comments

@WalterMadelim
Copy link

Often, in order to realize an algorithm, we need to establish ≥ 1 optimization models.

while true
  JuMP.optimize!(model_1)
  ...
  JuMP.optimize!(model_2)
end

If they all log to stdout which is the Julia REPL, it doesn't seem neat.
Is there a method set_log_file to let a specific optimizer log into a specific file?

model_1 = JuMP.Model(() -> Gurobi.Optimizer()) # for example, Gurobi is the optimizer
JuMP.unset_silent(model_1) # meant to let Gurobi log
JuMP.set_log_file(model_1, "Gurobi.log", "a") # mode "a" means new logs are appended to the end of file "output.log"

model_2 = JuMP.Model(() -> Ipopt.Optimizer())  
JuMP.unset_silent(model_2) 
JuMP.set_log_file(model_2, "Ipopt.log", "w") # mode "w" means that log of the 2nd-time optimization will overwrite those log during the 1st-time optimization

Reference: you can refer to the help-doc of open in Julia REPL, for the different modes, e.g. "a", "w".

@odow
Copy link
Member

odow commented Dec 26, 2024

Closing because JuMP does not control how optimizers log, to the REPL (aka stdout) or to a file.

These are solver-specific parameters. Please consult the documentation of the solver you are trying to use.

If you have related questions, please ask them on the discussion forum at https://jump.dev/forum

@odow odow closed this as completed Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants