15.08.2015 Views

Introduction to the Modeling and Analysis of Complex Systems

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

444 CHAPTER 19. AGENT-BASED MODELSn = 1000 # number <strong>of</strong> agentsw = 100 # number <strong>of</strong> rows/columns in spatial arrayk = 1 # rate <strong>of</strong> cAMP decayDc = 0.001 # diffusion constant <strong>of</strong> cAMPDh = 0.01 # spatial resolution for cAMP simulationDt = 0.01 # time resolution for cAMP simulationf = 1 # rate <strong>of</strong> cAMP secretion by an agentclass agent:passdef initialize():global agents, env, nextenvagents = []for i in xrange(n):ag = agent()ag.x = r<strong>and</strong>int(w)ag.y = r<strong>and</strong>int(w)agents.append(ag)env = zeros([w, w])nextenv = zeros([w, w])def observe():global agents, env, nextenvcla()imshow(env, cmap = cm.binary, vmin = 0, vmax = 1)axis(’image’)x = [ag.x for ag in agents]y = [ag.y for ag in agents]plot(y, x, ’b.’) # x <strong>and</strong> y are swapped <strong>to</strong> match <strong>the</strong> orientation <strong>of</strong> envdef update():global agents, env, nextenv

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!