From d2fc2556af3992f5833ad8c9aa182207033a8260 Mon Sep 17 00:00:00 2001 From: Nikolaus Sonnenschein Date: Wed, 31 Aug 2016 11:59:10 +0200 Subject: [PATCH] fix: get rid of annoying "File already contains basis" warning in cplex_interface --- optlang/cplex_interface.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/optlang/cplex_interface.py b/optlang/cplex_interface.py index 76a325b3..4b2c00ca 100644 --- a/optlang/cplex_interface.py +++ b/optlang/cplex_interface.py @@ -602,13 +602,14 @@ def __getstate__(self): def __setstate__(self, repr_dict): tmp_file = tempfile.mktemp(suffix=".sav") open(tmp_file, 'wb').write(repr_dict['cplex_binary']) - problem = cplex.Cplex(tmp_file) + problem = cplex.Cplex() + # turn off logging completely, get's configured later + problem.set_error_stream(None) + problem.set_warning_stream(None) + problem.set_log_stream(None) + problem.set_results_stream(None) + problem.read(tmp_file) if repr_dict['status'] == 'optimal': - # turn off logging completely, get's configured later - problem.set_error_stream(None) - problem.set_warning_stream(None) - problem.set_log_stream(None) - problem.set_results_stream(None) problem.solve() # since the start is an optimal solution, nothing will happen here self.__init__(problem=problem) self.configuration = Configuration.clone(repr_dict['config'], problem=self)