コード例 #1
0
ファイル: README_plots.py プロジェクト: benmaier/epipack
def MHRN_network_vis():
    import epipack as epk
    from epipack.vis import visualize
    import netwulf as nw

    network, _, __ = nw.load('../cookbook/readme_vis/MHRN.json')
    N = len(network['nodes'])
    links = [(l['source'], l['target'], 1.0) for l in network['links']]

    model = epk.StochasticEpiModel(["S","I","R"],N,links)\
                .set_link_transmission_processes([ ("I", "S", 1.0, "I", "I") ])\
                .set_node_transition_processes([ ("I", 1.0, "R") ])\
                .set_random_initial_conditions({ "S": N-5, "I": 5 })

    visualize(model, network, sampling_dt=0.1)
コード例 #2
0
import netwulf as nw

from epipack.vis import visualize
from epipack import StochasticEpiModel

# load network
network, config, _ = nw.load('./MHRN.json')

# get the network properties
N = len(network['nodes'])
edge_list = [(link['source'], link['target'], 1.0)
             for link in network['links']]

# define model
model = StochasticEpiModel(
    list("SIRXTQ"),
    N=N,
    edge_weight_tuples=edge_list,
)
k0 = model.out_degree.mean()
R0 = 5
recovery_rate = 1 / 8
quarantine_rate = 1.5 * recovery_rate
infection_rate = R0 * (recovery_rate) / k0

R0 = 3
recovery_rate = 1 / 8
quarantine_rate = 1 / 16
tracing_rate = 1 / 2
waning_immunity_rate = 1 / 14
infection_rate = R0 * (recovery_rate) / k0
コード例 #3
0
import netwulf as nw

from epipack.vis import visualize
from epipack import StochasticEpiModel
from epipack.colors import palettes, colors, bg_colors, hex_bg_colors

# load network
network, config, _ = nw.load('/Users/bfmaier/pythonlib/facebook/FB.json')

# get the network properties
N = len(network['nodes'])
edge_list = [(link['source'], link['target'], 1.0)
             for link in network['links']]

# define model
model = StochasticEpiModel(
    list("SIRX"),
    N=N,
    edge_weight_tuples=edge_list,
)
k0 = model.out_degree.mean()
R0 = 5
recovery_rate = 1 / 8
quarantine_rate = 1.5 * recovery_rate
infection_rate = R0 * (recovery_rate) / k0

# usual infection process
model.set_link_transmission_processes([("I", "S", infection_rate, "I", "I")])

# standard SIR dynamic with additional quarantine of symptomatic infecteds
model.set_node_transition_processes([
コード例 #4
0
B = 10
L = 3
N = B**L
k = 12
mus = [-1, -.5, -.05, 1]

for imu, mu in enumerate(mus):
    path = Path('data') / ('kleinberg_1d_imu_{}.json'.format(imu))
    if not path.exists():
        G = sixd.to_networkx_graph(
            *sixd.random_geometric_kleinberg_network(N, k, mu))
        nw, cfg = wulf.visualize(G,
                                 config={
                                     'node_fill_color': '#efefef',
                                     'node_collision': False,
                                     'wiggle_nodes': False,
                                     'scale_node_size_by_strength': True,
                                     'node_size': 8,
                                     'node_stroke_width': 2,
                                     'node_stroke_color': '#000000',
                                 })
        wulf.save(str(path), nw, cfg, G)
    else:
        nw, cfg, G = wulf.load(str(path))

    plt.figure()
    fig, ax = wulf.draw_netwulf(nw)

plt.show()
コード例 #5
0
import epipack as epk
import epipack.vis as vis
import netwulf as nw

network, cfg, g = nw.load('MHRN.json')
N = len(network['nodes'])
links = [ (l['source'], l['target'], 1.0) for l in network['links'] ]

model = epk.StochasticEpiModel(["S","I","R"],N,links)\
            .set_link_transmission_processes([ ("I", "S", 1.0, "I", "I") ])\
            .set_node_transition_processes([ ("I", 1.0, "R") ])\
            .set_random_initial_conditions({ "S": N-5, "I": 5 })

vis.visualize(model, network, sampling_dt=0.1)