Skip to content

Commit

Permalink
add script to package
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmilten committed Apr 8, 2021
1 parent af42b61 commit b0662df
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 17 deletions.
40 changes: 40 additions & 0 deletions bin/treed
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python

from treed import TreeD
import argparse

desc = """Draw a visual representation of the branch-and-cut tree of SCIP for
a particular instance using spatial dissimilarities of the node LP solutions.
"""

parser = argparse.ArgumentParser(description=desc)

parser.add_argument("model", type=str, help="path to model")
parser.add_argument(
"--transformation",
"-t",
type=str,
default="mds",
help="2D transformation algorithm for node LP solutions ('mds' or 'tsne')",
)
parser.add_argument(
"--hidecuts",
action="store_true",
help="hide cutting rounds and only show final node LP solutions",
)

parser.add_argument(
"--nodelimit", type=int, default=500, help="node limit for solving the model"
)

args = parser.parse_args()

treed = TreeD(
probpath=args.model,
transformation=args.transformation,
showcuts=~args.hidecuts,
nodelimit=args.nodelimit,
)

treed.main()
treed.draw()
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="treed",
version="0.0.1",
version="0.0.2",
author="Matthias Miltenberger",
author_email="[email protected]",
description="3D Visualization of Branch-and-Cut Trees using PySCIPOpt",
Expand All @@ -21,4 +21,5 @@
],
install_requires=["pyscipopt", "scikit-learn", "pandas", "plotly", "networkx"],
python_requires=">=3.6",
scripts=['bin/treed'],
)
21 changes: 5 additions & 16 deletions src/treed/treed.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ class TreeD:
- pandas to organize the collected data
"""

def __init__(self, probpath=""):
self.probpath = probpath
self.scip_settings = [("limits/totalnodes", 500)]
self.transformation = "mds"
self.showcuts = True
def __init__(self, **kwargs):
self.probpath = kwargs.get("probpath", "")
self.scip_settings = [("limits/totalnodes", kwargs.get("nodelimit", 500))]
self.transformation = kwargs.get("transformation", "mds")
self.showcuts = kwargs.get("showcuts", True)
self.color = "age"
self.colorscale = "Portland"
self.colorbar = False
Expand Down Expand Up @@ -440,14 +440,3 @@ def distance(p1, p2):
dist += (p1.get(k, 0) - p2.get(k, 0)) ** 2
return math.sqrt(dist)


if __name__ == "__main__":

treed = TreeD()
if len(sys.argv) == 1:
print(treed.__doc__)
print("usage: {} <MIP-instance>".format(sys.argv[0]))
else:
treed.probpath = sys.argv[1]
treed.main()
treed.draw()

0 comments on commit b0662df

Please sign in to comment.