In [1]:
from __future__ import print_function
%matplotlib inline
%load_ext autoreload
%autoreload 2
import matplotlib.pyplot as plt
import numpy as np
import tables as t
from collections import defaultdict
import os
from cyclopts import tools
In [2]:
prefix = '../../exec/run_results/small'
fname = 'combined.h5'
f = t.open_file(os.path.join(prefix, fname), mode='r')
props = f.root.Instances.ExchangeInstProperties
samplers = f.root.ReactorRequestSampler
grps = f.root.Instances.ExchangeGroups
results = f.root.Results.General
flows = f.root.Instances.ExchangeInstSolutions
In [3]:
import operator
import uuid
max_key = lambda d: max(d.iteritems(), key=operator.itemgetter(1))[0]
name = 'Arc'
handle = 'n_arcs'
vals = {x['instid']: x[handle] for x in props.iterrows() if x['excl_frac'] == 1}
k = max_key(vals)
print("UUID with max number of arc and all exclusive:", uuid.UUID(bytes=k).hex, "({0} arcs)".format(vals[k]))
print("{0} total instances in this database.")
In [4]:
name = 'Arc'
handle = 'n_arcs'
vals = {x['instid']: x[handle] for x in props.iterrows()}
n, bins, patches = plt.hist([x for _, x in vals.iteritems()], 30)
plt.xlabel('Number of {0}s'.format(name))
plt.ylabel('Number of Instances')
Out[4]:
In [5]:
name = 'Constraint'
handle = 'n_constrs'
vals = {x['instid']: x[handle] for x in props.iterrows()}
n, bins, patches = plt.hist([x for _, x in vals.iteritems()], 30)
plt.xlabel('Number of {0}s'.format(name))
plt.ylabel('Number of Instances')
Out[5]:
In [7]:
name = 'Request Group'
handle = 'n_u_grps'
vals = {x['instid']: x[handle] for x in props.iterrows()}
n, bins, patches = plt.hist([x for _, x in vals.iteritems()], 30)
plt.xlabel('Number of {0}s'.format(name))
plt.ylabel('Number of Instances')
Out[7]:
In [8]:
name = 'Request Node'
handle = 'n_u_nodes'
vals = {x['instid']: x[handle] for x in props.iterrows()}
n, bins, patches = plt.hist([x for _, x in vals.iteritems()], 30)
plt.xlabel('Number of {0}s'.format(name))
plt.ylabel('Number of Instances')
Out[8]:
In [9]:
name = 'Supply Group'
handle = 'n_v_grps'
vals = {x['instid']: x[handle] for x in props.iterrows()}
n, bins, patches = plt.hist([x for _, x in vals.iteritems()], 30)
plt.xlabel('Number of {0}s'.format(name))
plt.ylabel('Number of Instances')
Out[9]:
In [10]:
name = 'Supply Node'
handle = 'n_v_nodes'
vals = {x['instid']: x[handle] for x in props.iterrows()}
n, bins, patches = plt.hist([x for _, x in vals.iteritems()], 30)
plt.xlabel('Number of {0}s'.format(name))
plt.ylabel('Number of Instances')
Out[10]:
In [10]:
In [ ]: