In [23]:
from __future__ import print_function

%matplotlib inline
%load_ext autoreload
%autoreload 2

import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
import tables as t
from collections import defaultdict
import os
from cyclopts import tools as tools
from cyclopts import cyclopts_io as cycio
from cyclopts import analysis as sis


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

In [24]:
# configurable input
mod_kind = 'reqr' # rxtr or reqr or rand
frxtr = 0
n = 100
#dirname = 'base_{kind}_1'.format(kind=mod_kind)
dirname = 'nreal_{n}_{kind}_{frxtr}'.format(kind=mod_kind, frxtr=frxtr, n=n)
dirname += '_loc'
fname = 'combined.h5'

dirname='tmp'
fname = 'combined_fc.h5'

xchange = {'reqr': 'Reactor Supply', 'rxtr': 'Reactor Demand'}

base = '~/phd/cyclopts/structured_runs/'

if mod_kind == 'rxtr':
    species_module = "cyclopts.structured_species.request"
    species_class = "StructuredRequest"
elif mod_kind == 'reqr':
    species_module = "cyclopts.structured_species.supply"
    species_class = "StructuredSupply"  
elif mod_kind == 'rand':
    species_module = "cyclopts.random_request_species"
    species_class = "RandomRequest"   

family_module = "cyclopts.exchange_family"
family_class = "ResourceExchange"

fullpath = os.path.join(os.path.expanduser(base), dirname)
h5file = os.path.join(fullpath, fname)

# context driver object
save = True
ctx = sis.Context(h5file, 
                  family_module, family_class, species_module, species_class,
                  save=save, savepath=fullpath)
print('directory: {0}, file: {1}'.format(dirname, fname))
print('n_arcs:', ctx.data[0]['n_arcs'], 'n_constrs:', ctx.data[0]['n_constrs'],)


directory: tmp, file: combined_loc.h5
n_arcs: 390 n_constrs: 76

In [25]:
s = 'cbc'
colorby = 'f_loc'
title = '{0} {1} Exchanges, f_rxtr={2}, N={3}'.format(s.capitalize(), xchange[mod_kind], frxtr, n)
fig, ax = ctx.solver_hist(s, 'time', bins=50, title=title, colorby=colorby, alpha=0.5)
ax.legend(loc=0)


Out[25]:
<matplotlib.legend.Legend at 0x7f1d86e12d50>

In [27]:
s = 'cbc'
title = '{0} {1} Exchanges, f_rxtr={2}, N={3}'.format(s.capitalize(), xchange[mod_kind], frxtr, n)
fig, ax = ctx.avg_std(s, 'time', title=titlecombined_loc)



In [28]:
fig, ax = ctx.avg_std(s, 'time', title=title, data=sis.reduce_eq(ctx.data, colorby, 0))



In [29]:
fig, ax = ctx.avg_std(s, 'time', title=title, data=sis.reduce_eq(ctx.data, colorby, 1))



In [30]:
fig, ax = ctx.avg_std(s, 'time', title=title, data=sis.reduce_eq(ctx.data, colorby, 2))



In [30]:


In [ ]:


In [ ]: