File size: 3,018 Bytes
ed7a615
 
 
 
 
 
 
 
 
 
 
 
e0c4dd6
 
 
 
 
 
 
ed7a615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e0c4dd6
ed7a615
 
 
e0c4dd6
ed7a615
 
 
 
 
 
 
 
 
e0c4dd6
ed7a615
e0c4dd6
ed7a615
 
 
e0c4dd6
 
ed7a615
e0c4dd6
 
 
 
 
ed7a615
 
 
 
 
e0c4dd6
 
ed7a615
 
 
 
 
 
 
e0c4dd6
 
ed7a615
 
 
 
 
 
 
e0c4dd6
 
ed7a615
 
e0c4dd6
ed7a615
 
 
 
 
 
 
 
 
 
e0c4dd6
 
 
 
ed7a615
 
 
 
e0c4dd6
ed7a615
 
e0c4dd6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from webworld_lib import *

pn.extension("tabulator")

ACCENT = "indigo"

styles = {
    "box-shadow": "rgba(50, 50, 93, 0.25) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px",
    "border-radius": "4px",
    "padding": "10px",
}

CSS = """
div.card-margin:nth-child(1) {
    max-height: 280px;
}
}
"""

fixed_data = fixed_parameters()
global Nt, SN;
Nt =0.0; Tn = 0.0
MS = fixed_data[0]
R = fixed_data[1]
c= fixed_data[2]
ld = fixed_data[3]
Ng = fixed_data[4]
L = fixed_data[5]
K = fixed_data[6]
b = fixed_data[7]

Running = False

# Parameter Values
t_comp = pn.widgets.FloatSlider(value= c ,start=0.1, 
                                end=0.9, step=0.1,
                                name='Competition')
t_res = pn.widgets.FloatSlider(value= R ,start=1e4, 
                                end=1e6, step=1e4,
                                name='Resources')

figa = (
  pd.DataFrame([],columns=['SN'])
).hvplot(
    title="Number of Species",
    ylabel="Number of Species",
    xlabel="Evolutionary event",
    #xlim=(0, Ng),
    autorange = "y",
    color=ACCENT,
)
#print(figa)
FW = nx.DiGraph()
figb = hvnx.draw(FW, with_labels=True) 

pr1 = pn.pane.Str(
        'Static parameters (K,L):'+str(K)+' '+str(L)
    )
pr2 = pn.pane.Str('Max number of allowed species: '+str(MS))
pr3 = pn.pane.Str('Number of evolutionary steps: '+str(Ng))
pr4 = pn.pane.Str('b: '+str(b))
#pr3 = pn.pane.Str('Ready')
button = pn.widgets.Button(name='\u25b6',description='Run')
#print(button.name)
 
# Display Data
indicators = pn.FlexBox(
    

    pn.indicators.Number(
        value=t_res, name="External Resources", 
        format="{value:,.1E}",
        font_size = "5",
        title_size = "6", 
        styles=styles
    ),
    pn.indicators.Number(
        value=t_comp,
        name="Competition parameter",
        format="{value:,.1f}",
        font_size = "5",
        title_size = "6",
        styles=styles,
    ),

    pn.indicators.Number(
        value=Tn,
        name="Time",
        format="{value:,.1f}",
        font_size = "5",
        title_size = "6",
        styles=styles,
    ),


        pn.indicators.Number(
        value=Nt,
        name="Number of Species",
        font_size = "5",
        title_size = "6",
        format="{value:,.1f}",
        styles=styles,
    ),    
)

Pt = np.array([MS,t_res.value,t_comp.value,ld,Ng,L,K,b,indicators[3],indicators[2]])
plotns = pn.pane.HoloViews(figa, sizing_mode="stretch_both", name="PlotNS")
plotfw = pn.pane.HoloViews(figb, sizing_mode="stretch_both", name="PlotFW")

tabs = pn.Tabs(
    plotns, plotfw, styles=styles, sizing_mode="stretch_width", height=500, margin=10
)


ly1 = pn.Column(pr1, pr2, pr3, pr4,t_comp,t_res, button, sizing_mode="stretch_both")
ly2 = pn.Column(indicators, tabs, sizing_mode="stretch_both")

button.on_click(partial(start_sim,Pt,[t_res,t_comp],button,tabs))

pn.template.FastListTemplate(
    title="Webworld Model Demo",
    main=[ly1,ly2],
    main_layout=None,
    accent=ACCENT,
    raw_css=[CSS]
).servable()