From 04730de0b86d4b7027dab0f65a4b81277dd2aafa Mon Sep 17 00:00:00 2001 From: Ted Ralphs Date: Wed, 19 Feb 2020 14:32:49 -0500 Subject: [PATCH] Fixing up a few things and supporting changes to GiMPy --- setup.py | 6 ++++-- src/grumpy/BBTree.py | 9 ++++++--- src/grumpy/__main__.py | 7 ++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 09ca1ca..1e55a03 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import setuptools setup(name='coinor.grumpy', - version='0.9.1', + version='0.9.2', description='Graphics for Understanding Mathematical Programming (GrUMPy)', long_description='''GrUMPy is a class for visualizing various algorithm used in solving discrete optimization problem. It has a class for dynamically generating and visualizing branch-and-bound trees that is derived from the GiMPy graph class. Using the branch-and-bound class, a user can visualize the branch-and-bound process in a number of different ways either by building the tree dynamically through direct calls to Python from the solver or by piping the output of an instrumented solver to GrUMPy for parsing. The branch-and-bound class also includes a pure Python implementation of branch and bound that is targeted at educational use. @@ -23,7 +23,9 @@ license='Eclipse Public License', url='https://github.com/tkralphs/GrUMPy/', namespace_packages=['coinor'], - packages=['coinor.grumpy','coinor.grumpy.examples','coinor'], + packages=['coinor.grumpy','coinor'], + package_data={'':['*.vbc']}, + include_package_data=True, package_dir = {'coinor': 'src'}, install_requires=['coinor.gimpy>=2.0.0', 'pulp'] ) diff --git a/src/grumpy/BBTree.py b/src/grumpy/BBTree.py index 578bcb2..a26a92e 100644 --- a/src/grumpy/BBTree.py +++ b/src/grumpy/BBTree.py @@ -274,10 +274,13 @@ def set_display_mode(self, mode): self.attr['display'] = 'off' elif mode is 'file': self.attr['display'] = 'file' + elif mode is 'matplotlib': + self.attr['display'] = 'matplotlib' else: raise Exception('%s is not a valid display mode.' %mode) - def display(self, item = 'all', basename = 'graph', format='png', count=None): + def display(self, item = 'all', basename = 'graph', format='png', count=None, + pause=False, wait_for_click=True): ''' Displays/Saves images requested. BranchAndBound method calls this method to visualize the branch and bound tree. @@ -300,7 +303,7 @@ def display(self, item = 'all', basename = 'graph', format='png', count=None): n.attr['style'] = 'filled' else: n.attr['label'] = ' ' - BinaryTree.display(self) + BinaryTree.display(self, pause = pause, wait_for_click = wait_for_click) return if self.attr['display'] is 'off': return @@ -2082,7 +2085,7 @@ def parse_options(): T = BBTree() #T.set_layout('dot2tex') #T.set_display_mode('file') - T.set_display_mode('xdot') + T.set_display_mode('matplotlib') #T.set_display_mode('pygame') CONSTRAINTS, VARIABLES, OBJ, MAT, RHS = GenerateRandomMIP(rand_seed = 120) BranchAndBound(T, CONSTRAINTS, VARIABLES, OBJ, MAT, RHS, diff --git a/src/grumpy/__main__.py b/src/grumpy/__main__.py index f888b2f..923727f 100644 --- a/src/grumpy/__main__.py +++ b/src/grumpy/__main__.py @@ -1,7 +1,12 @@ from __future__ import print_function from future import standard_library standard_library.install_aliases() -from coinor.grumpy import BBTree +from .BBTree import * +from .BranchAndBound import * +try: + from .polyhedron2D import * +except ImportError: + pass import sys import io