Disable logging to Console when Running Environments in Parallel
Hi,
I am currently working on a Dantzig-Wolfe decomposition in Python, where at each stage, I have several independent subproblems that I solve in parallel. The code runs as it should. However, as each process is started, the following prints to the console:
Set parameter Username
Academic license - for non-commercial use only - expires 2025-05-02
As I have understood it, Gurobi starts a new environment when starting a new process. I have therefore tried the following inside the function solve_sp that is called in parallel, as suggested in this post https://support.gurobi.com/hc/en-us/articles/360044784552-How-do-I-suppress-all-console-output-from-Gurobi.
with gp.Env(empty=True) as env:
env.setParam('OutputFlag', 0)
env.setParam('LogToConsole', 0)
env.start()
with DantzigWolfeSP(
...,
env=env
) as sp:
sp.build(...)
sp.optimize()
sp.write(self._results_path+f'dantzig_wolfe/sub/column_{next(self.subproblem_counter)}.sol')
return SOLUTION
Where DantzigWolfeSP inherits from gp.Model().
The code that executes the parallel processes looks like this:
with ProcessPoolExecutor() as executor:
#Submit all subproblems to the executor
futures = [executor.submit(
self.solve_sp,
mab_duals,
yearly_production_duals,
tanks_in_use_duals,
dp,
CNS.DEFAULT_MEAN,
0
) for dp in self._deployment_periods[:-3]]
# Process results as they complete
for future in as_completed(futures):
obj_rc, obj_sol, x_bar, e_bar, n_bar, *_ = future.result()
# Non-improving extreme-point
if obj_rc is None or obj_rc <= 0:
continue
self.add_extreme_point(x_bar, e_bar, n_bar, obj_sol)
extreme_point_added = True
However, this does not stop the logging to the console.
I also tried creating a gurobi.env file specifying the parameters LogToConsole and OutputFlag. This removed the logging of Academic licence, but not Set parameter Username.
Any idea how I can suppress the logging to console?
Thank you in advance.
Best regards,
Olav Foerland
Please sign in to leave a comment.
Comments
0 comments