Exemplo n.º 1
0
    from src.grumpy import BBTree
import sys
import io
from PIL import Image as PIL_Image

bt = BBTree()
bt.set_display_mode('pygame')
line_number = 1
file_ = open('p0201_GLPK.vbc', 'r')
#for line in sys.stdin:
for line in file_:
    bt.ProcessLine(line)
    #To print out snapshots of the tree
    if line_number % 100000 != 0:
        continue
    imagefile = open('tree-' + str(line_number) + '.png', 'w')
    imagefile.write(bt.GenerateTreeImage())
    imagefile.close()

#gnuplot_image = bt.GenerateHistogram()
gnuplot_image = io.StringIO(bt.GenerateTreeImage())
#gnuplot_image = bt.GenerateScatterplot()
#gnuplot_image = bt.GenerateIncumbentPath()
#gnuplot_image = bt.GenerateForecastImages()
im = PIL_Image.open(gnuplot_image)
im.show()
#bt.display_all()

bt.set_display_mode('file')
bt.display()
Exemplo n.º 2
0
                                    "$"+str(branch_var) + " \leq " + str(rhs) + "$")
            else:
                T.set_edge_attr(parent, cur_index, 'label',
                                str(branch_var) + sense + str(rhs))
        if ETREE_INSTALLED and display_mode == 'svg':
            T.write_as_svg(filename = "node%d" % iter_count,
                           prevfile = "node%d" % (iter_count - 1),
                           nextfile = "node%d" % (iter_count + 1),
                           highlight = cur_index)
    iter_count += 1

    if ((PYGAME_INSTALLED and display_mode == 'pygame')
         or (XDOT_INSTALLED and display_mode == 'xdot')):
        numNodes = len(T.get_node_list())
        if numNodes % display_interval == 0 and not layout != 'ladot':
            T.display(highlight = [cur_index])
    elif gexf_installed and display_mode == 'gexf':
        T.write_as_dynamic_gexf("graph")

    if status == 'C':

        # Branching:
        # Choose a variable for branching
        branching_var = -1
        if branch_strategy == FIXED:
            #fixed order
            for i in VARIABLES:
                frac = min(var[i].varValue-math.floor(var[i].varValue),
                           math.ceil(var[i].varValue) - var[i].varValue)
                if (frac > 0):
                    min_frac = frac
Exemplo n.º 3
0
    from src.grumpy import BBTree
import sys
import io
from PIL import Image as PIL_Image

bt = BBTree()
bt.set_display_mode('pygame')
line_number = 1
file_ = open('p0201_GLPK.vbc', 'r')
#for line in sys.stdin:
for line in file_:
    bt.ProcessLine(line)
    #To print out snapshots of the tree
    if line_number%100000 != 0:
        continue
    imagefile = open('tree-'+str(line_number)+'.png','w')
    imagefile.write(bt.GenerateTreeImage())
    imagefile.close()

#gnuplot_image = bt.GenerateHistogram()
gnuplot_image = io.StringIO(bt.GenerateTreeImage())
#gnuplot_image = bt.GenerateScatterplot()
#gnuplot_image = bt.GenerateIncumbentPath()
#gnuplot_image = bt.GenerateForecastImages()
im = PIL_Image.open(gnuplot_image)
im.show()
#bt.display_all()

bt.set_display_mode('file')
bt.display()
Exemplo n.º 4
0
                        "$" + str(branch_var) + " \leq " + str(rhs) + "$")
            else:
                T.set_edge_attr(parent, cur_index, 'label',
                                str(branch_var) + sense + str(rhs))
        if ETREE_INSTALLED and display_mode == 'svg':
            T.write_as_svg(filename="node%d" % iter_count,
                           prevfile="node%d" % (iter_count - 1),
                           nextfile="node%d" % (iter_count + 1),
                           highlight=cur_index)
    iter_count += 1

    if ((PYGAME_INSTALLED and display_mode == 'pygame')
            or (XDOT_INSTALLED and display_mode == 'xdot')):
        numNodes = len(T.get_node_list())
        if numNodes % display_interval == 0 and not layout != 'ladot':
            T.display(highlight=[cur_index])
    elif gexf_installed and display_mode == 'gexf':
        T.write_as_dynamic_gexf("graph")

    if status == 'C':

        # Branching:
        # Choose a variable for branching
        branching_var = -1
        if branch_strategy == FIXED:
            #fixed order
            for i in VARIABLES:
                frac = min(var[i].varValue - math.floor(var[i].varValue),
                           math.ceil(var[i].varValue) - var[i].varValue)
                if (frac > 0):
                    min_frac = frac
Exemplo n.º 5
0
except ImportError:
    from src.grumpy import BBTree
from inspect import getfile
from os.path import join, dirname
import sys
import io

bt = BBTree()
line_number = 0
#for line in sys.stdin:
instance = join(dirname(getfile(coinor.grumpy.examples)), 'p0201_GLPK.vbc')
with open(instance, 'r') as file_:
    bt.set_display_mode('file')
    for line in file_:
        line_number += 1
        bt.ProcessLine(line)
        #To print out snapshots of the tree
        if line_number % 100 != 0:
            continue
        bt.display('tree', 'tree-' + str(line_number))

#bt.write_image(bt.GenerateHistogram())
bt.set_display_mode('matplotlib')
bt.display('tree')
#bt.write_image(bt.GenerateScatterplot())
#bt.write_image(bt.GenerateIncumbentPath())
#bt.write_image(bt.GenerateForecastImages())

bt.set_display_mode('file')
bt.display('tree', 'tree-final')