Cyclopts Input Analysis

This notebook aides an analyst in visualizing input to a series of cyclopts executions.


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


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

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

Interesting Features


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.")


UUID with max number of arc and all exclusive: c68007fb911c4883890a7ed641f83464 (189540 arcs)
{0} total instances in this database.

Instance Characterization


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]:
<matplotlib.text.Text at 0x7ffd5c346690>

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]:
<matplotlib.text.Text at 0x7ffd5c1bd310>

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]:
<matplotlib.text.Text at 0x7ffd5c02c250>

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]:
<matplotlib.text.Text at 0x7ffd5c05f6d0>

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]:
<matplotlib.text.Text at 0x7ffd5bda3a50>

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]:
<matplotlib.text.Text at 0x7ffd5bc172d0>

In [10]:


In [ ]: