Skip to content

Commit

Permalink
Merge pull request #62 from ronaldvdv-gurobi/feature/memlimit
Browse files Browse the repository at this point in the history
Support for MemLimit and WorkLimit
  • Loading branch information
mattmilten authored Dec 19, 2024
2 parents 782c644 + 1262fb0 commit 3690ae4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG
## Unreleased
### Fixed
- Logs ending with memory or work limit reached, will now return a corresponding status
### Changed
- If logfiles are not found when parsing then a FileNotFoundError is raised
### Removed
Expand Down
4 changes: 4 additions & 0 deletions src/gurobi_logtools/parsers/termination.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class TerminationParser:
re.compile(
r"Thread count was (?P<Threads>\d+) \(of (?P<Cores>\d+) available processors\)"
),
re.compile(r"(?P<WORK_LIMIT>Work limit reached)"),
re.compile(r"(?P<MEM_LIMIT>Memory limit reached)"),
]

status = [
Expand All @@ -45,6 +47,8 @@ class TerminationParser:
"CUTOFF",
"USER_OBJ_LIMIT",
"INTERRUPTED",
"MEM_LIMIT",
"WORK_LIMIT",
]

def __init__(self):
Expand Down
44 changes: 44 additions & 0 deletions tests/parsers/test_termination.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,40 @@
"ErrorCode": None,
}

memlimit_log = """
Explored 66258 nodes (470922 simplex iterations) in 18.39 seconds (16.82 work units)
Thread count was 8 (of 8 available processors)
Solution count 10: 1.50001e+09 1.50001e+09 1.50001e+09 ... 1.66668e+09
Memory limit reached
Best objective 1.500012100000e+09, best bound 1.000006566284e+09, gap 33.3334%
"""

memlimit_summary = {
"Status": "MEM_LIMIT",
"SolCount": 10,
"Threads": 8,
"Cores": 8,
}

worklimit_log = """
Explored 30881 nodes (135045 simplex iterations) in 19.60 seconds (10.00 work units)
Thread count was 8 (of 8 available processors)
Solution count 10: 1.50001e+09 1.50001e+09 1.50001e+09 ... 1.66668e+09
Work limit reached
Best objective 1.500012100000e+09, best bound 8.997791698421e+08, gap 40.0152%
"""

worklimit_summary = {
"Status": "WORK_LIMIT",
"SolCount": 10,
"Threads": 8,
"Cores": 8,
}


class TestTermination(TestCase):
def setUp(self):
Expand All @@ -61,6 +95,16 @@ def test_interrupted(self):
parse_block(parser, interrupted_log)
self.assertEqual(parser.get_summary(), interrupted_summary)

def test_memlimit(self):
parser = TerminationParser()
parse_block(parser, memlimit_log)
self.assertEqual(parser.get_summary(), memlimit_summary)

def test_worklimit(self):
parser = TerminationParser()
parse_block(parser, worklimit_log)
self.assertEqual(parser.get_summary(), worklimit_summary)


if __name__ == "__main__":
main()

0 comments on commit 3690ae4

Please sign in to comment.