File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Original file line number Diff line number Diff line change 44### Added
55- Added method for adding piecewise linear constraints
66- Add SCIP function SCIPgetTreesizeEstimation and wrapper getTreesizeEstimation
7- - Add recipes sub-package
7+ - New test for model setLogFile
88### Fixed
9+ - Fixed model.setLogFile(None) error
10+ - Add recipes sub-package
911- Fixed "weakly-referenced object no longer exists" when calling dropEvent in test_customizedbenders
1012- Fixed incorrect writing/printing when user had a non-default locale
1113### Changed
Original file line number Diff line number Diff line change @@ -4974,8 +4974,11 @@ cdef class Model:
49744974 """ sets the log file name for the currently installed message handler
49754975 :param path: name of log file, or None (no log)
49764976 """
4977- c_path = str_conversion(path) if path else None
4978- SCIPsetMessagehdlrLogfile(self ._scip, c_path)
4977+ if path:
4978+ c_path = str_conversion(path)
4979+ SCIPsetMessagehdlrLogfile(self ._scip, c_path)
4980+ else :
4981+ SCIPsetMessagehdlrLogfile(self ._scip, NULL )
49794982
49804983 # Parameter Methods
49814984
Original file line number Diff line number Diff line change 11import pytest
2+ import os
23
34from pyscipopt import Model , SCIP_STAGE
45
@@ -300,6 +301,39 @@ def test_getTreesizeEstimation():
300301 m .optimize ()
301302
302303 assert m .getTreesizeEstimation () > 0
304+
305+ def test_setLogFile ():
306+ m = Model ()
307+ x = m .addVar ("x" , vtype = "I" )
308+ y = m .addVar ("y" , vtype = "I" )
309+ m .addCons (x + y == 1 )
310+ m .setObjective (2 * x + y )
311+
312+ log_file_name = "test_setLogFile.log"
313+ m .setLogfile (log_file_name )
314+ assert os .path .exists (log_file_name )
315+
316+ m .optimize ()
317+ del m
318+ assert os .path .getsize (log_file_name ) > 0
319+ os .remove (log_file_name )
320+
321+ def test_setLogFile_none ():
322+ m = Model ()
323+ x = m .addVar ("x" , vtype = "I" )
324+ y = m .addVar ("y" , vtype = "I" )
325+ m .addCons (x + y == 1 )
326+ m .setObjective (2 * x + y )
327+
328+ log_file_name = "test_setLogfile_none.log"
329+ m .setLogfile (log_file_name )
330+ assert os .path .exists (log_file_name )
331+
332+ m .setLogfile (None )
333+ m .optimize ()
334+ del m
335+ assert os .path .getsize (log_file_name ) == 0
336+ os .remove (log_file_name )
303337
304338def test_locale ():
305339 import locale
@@ -315,4 +349,3 @@ def test_locale():
315349
316350 with open ("model.cip" ) as file :
317351 assert "1,1" not in file .read ()
318-
You can’t perform that action at this time.
0 commit comments