-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from venaturum/GH51_pretree_solutions
[#GH51] Parsing heuristic solutions found prior to nodelog (but not by NoRel)
- Loading branch information
Showing
15 changed files
with
318 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import re | ||
|
||
from gurobi_logtools.parsers.util import typeconvert_groupdict | ||
|
||
|
||
class PretreeSolutionParser: | ||
pretree_solution_regex = re.compile( | ||
r"Found heuristic solution:\sobjective\s(?P<Incumbent>[^\s]+)" | ||
) | ||
|
||
def __init__(self): | ||
"""Initialize the pre-tree solutions parser (does not include NoRel solutions). | ||
The PresolveParser extends beyond the lines associated with the presolved | ||
model. Specifically, it includes information for all lines appearing between | ||
the HeaderParser and the NoRelParser or the RelaxationParser. | ||
""" | ||
self._progress = [] | ||
self._summary = {} | ||
# self._started = False | ||
|
||
def parse(self, line: str) -> bool: | ||
"""Parse the given log line to populate summary data. | ||
Args: | ||
line (str): A line in the log file. | ||
Returns: | ||
bool: Return True if the given line is matched by some pattern. | ||
""" | ||
match = self.pretree_solution_regex.match(line) | ||
if match: | ||
self._progress.append(typeconvert_groupdict(match)) | ||
return True | ||
return False | ||
|
||
def get_summary(self) -> dict: | ||
"""Return the current parsed summary.""" | ||
return {"PreTreeSolutions": len(self._progress)} | ||
|
||
def get_progress(self) -> list: | ||
"""Return the progress of the search tree.""" | ||
return self._progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
Gurobi 9.5.0 (mac64[x86], gurobi_cl) logging started Fri Jul 5 19:18:47 2024 | ||
|
||
Set parameter LogFile to value "multiknapsack.log" | ||
Using license file /Users/riley.clement/gurobi.lic | ||
|
||
Gurobi Optimizer version 9.5.0 build v11.0.2rc0 (mac64[x86] - Darwin 23.5.0 23F79) | ||
Copyright (c) 2021, Gurobi Optimization, LLC | ||
|
||
Read MPS format model from file multiknapsack.mps.bz2 | ||
Reading time = 2.31 seconds | ||
: 1000 rows, 1000 columns, 1000000 nonzeros | ||
|
||
CPU model: Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz | ||
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads | ||
|
||
Optimize a model with 1000 rows, 1000 columns and 1000000 nonzeros | ||
Model fingerprint: 0x1dcb478a | ||
Variable types: 0 continuous, 1000 integer (0 binary) | ||
Coefficient statistics: | ||
Matrix range [8e-07, 1e+00] | ||
Objective range [3e-04, 1e+00] | ||
Bounds range [0e+00, 0e+00] | ||
RHS range [2e+00, 1e+04] | ||
Found heuristic solution: objective 2.6508070 | ||
Presolve removed 751 rows and 0 columns | ||
Presolve time: 0.63s | ||
Presolved: 249 rows, 1000 columns, 249000 nonzeros | ||
Variable types: 0 continuous, 1000 integer (0 binary) | ||
|
||
Starting NoRel heuristic | ||
Found heuristic solution: objective 15.6561779 | ||
Found heuristic solution: objective 20.2661725 | ||
Found heuristic solution: objective 21.6309598 | ||
Found heuristic solution: objective 23.7055101 | ||
Found heuristic solution: objective 24.1081356 | ||
Elapsed time for NoRel heuristic: 8s (best bound 24.6734) | ||
Elapsed time for NoRel heuristic: 15s (best bound 24.6734) | ||
Elapsed time for NoRel heuristic: 21s (best bound 24.6734) | ||
Elapsed time for NoRel heuristic: 29s (best bound 24.6734) | ||
|
||
Root relaxation: objective 2.467344e+01, 32 iterations, 0.02 seconds (0.01 work units) | ||
|
||
Found heuristic solution: objective 15.5735142 | ||
|
||
Nodes | Current Node | Objective Bounds | Work | ||
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time | ||
|
||
0 0 24.67344 0 5 15.57351 24.67344 58.4% - 0s | ||
H 0 0 23.8510977 24.67344 3.45% - 0s | ||
H 0 0 24.1081356 24.67344 2.34% - 0s | ||
0 0 24.54405 0 7 24.10814 24.54405 1.81% - 1s | ||
0 0 24.54405 0 5 24.10814 24.54405 1.81% - 1s | ||
0 0 24.54405 0 7 24.10814 24.54405 1.81% - 1s | ||
0 0 24.49025 0 6 24.10814 24.49025 1.59% - 1s | ||
0 0 24.48961 0 7 24.10814 24.48961 1.58% - 1s | ||
0 0 24.45227 0 8 24.10814 24.45227 1.43% - 1s | ||
0 0 24.40551 0 8 24.10814 24.40551 1.23% - 1s | ||
0 2 24.40551 0 8 24.10814 24.40551 1.23% - 1s | ||
|
||
Cutting planes: | ||
Gomory: 8 | ||
Lift-and-project: 1 | ||
|
||
Explored 838 nodes (2566 simplex iterations) in 1.27 seconds (0.53 work units) | ||
Thread count was 8 (of 8 available processors) | ||
|
||
Solution count 5: 24.1081 23.8511 15.5735 ... 2.65081 | ||
|
||
Optimal solution found (tolerance 1.00e-04) | ||
Best objective 2.410813557868e+01, best bound 2.410813557868e+01, gap 0.0000% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.