Skip to content

Commit c40df4b

Browse files
committed
Replaced with displayProblem
1 parent b8a9cd6 commit c40df4b

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
## Unreleased
44
### Added
5+
- Added displayProblem to print problem to stdout
56
- Added stage checks to presolve, freereoptsolve, freetransform
67
- Added primal_dual_evolution recipe and a plot recipe
78
### Fixed
89
### Changed
9-
- Allowed writeProblem to print to standard output
1010
### Removed
1111

1212
## 5.2.1 - 2024.10.29

src/pyscipopt/scip.pxi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,6 +2889,35 @@ cdef class Model:
28892889
if not onlyroot:
28902890
self.setIntParam("propagating/maxrounds", 0)
28912891

2892+
def displayProblem(self, ext='.cip', trans=False, genericnames=False):
2893+
"""
2894+
Write current model/problem to a file.
2895+
2896+
Parameters
2897+
----------
2898+
ext : str, optional
2899+
the extension to be used (Default value = '.cip').
2900+
Should have an extension corresponding to one of the readable file formats,
2901+
described in https://www.scipopt.org/doc/html/group__FILEREADERS.php.
2902+
trans : bool, optional
2903+
indicates whether the transformed problem is written to file (Default value = False)
2904+
genericnames : bool, optional
2905+
indicates whether the problem should be written with generic variable
2906+
and constraint names (Default value = False)
2907+
verbose : bool, optional
2908+
indicates whether a success message should be printed
2909+
2910+
"""
2911+
user_locale = locale.getlocale(category=locale.LC_NUMERIC)
2912+
locale.setlocale(locale.LC_NUMERIC, "C")
2913+
2914+
if trans:
2915+
PY_SCIP_CALL(SCIPwriteTransProblem(self._scip, NULL, str_conversion(ext)[1:], genericnames))
2916+
else:
2917+
PY_SCIP_CALL(SCIPwriteOrigProblem(self._scip, NULL, str_conversion(ext)[1:], genericnames))
2918+
2919+
locale.setlocale(locale.LC_NUMERIC,user_locale)
2920+
28922921
def writeProblem(self, filename='model.cip', trans=False, genericnames=False, verbose=True):
28932922
"""
28942923
Write current model/problem to a file.

tests/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_model():
6767

6868
s.writeProblem('model')
6969
s.writeProblem('model.lp')
70-
s.writeProblem(filename=False)
70+
s.displayProblem()
7171

7272
s.freeProb()
7373
s = Model()

0 commit comments

Comments
 (0)