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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

11.3. SIMULATING CELLULAR AUTOMATA 197nextconfig[x, y] = 1 if count >= 4 else 0config, nextconfig = nextconfig, configimport pycxsimula<strong>to</strong>rpycxsimula<strong>to</strong>r.GUI().start(func=[initialize, observe, update])When you run this code, you see <strong>the</strong> results like those shown in Fig. 11.7. As youcan see, with <strong>the</strong> initial configuration with p = 0.1, most <strong>of</strong> <strong>the</strong> panicky states disappearquickly, leaving only a few self-sustaining clusters <strong>of</strong> panicky people. They may look likecondensed water droplets, hence <strong>the</strong> name <strong>of</strong> <strong>the</strong> model (droplet rule).t = 0 t = 20Figure 11.7: Visual output <strong>of</strong> Code 11.5. Left: Initial configuration with p = 0.1. Right:Final configuration after 20 time steps.Exercise 11.3 Modify Code 11.5 <strong>to</strong> implement a simula<strong>to</strong>r <strong>of</strong> <strong>the</strong> Game <strong>of</strong> LifeCA. Simulate <strong>the</strong> dynamics from a r<strong>and</strong>om initial configuration. Measure <strong>the</strong> density<strong>of</strong> state 1’s in <strong>the</strong> configuration at each time step, <strong>and</strong> plot how <strong>the</strong> densitychanges over time. This can be done by creating an empty list in <strong>the</strong> initializefunction, <strong>and</strong> <strong>the</strong>n making <strong>the</strong> measurement <strong>and</strong> appending <strong>the</strong> result <strong>to</strong> <strong>the</strong> list in<strong>the</strong> observe function. The results s<strong>to</strong>red in <strong>the</strong> list can be plotted manually after <strong>the</strong>simulation, or <strong>the</strong>y could be plotted next <strong>to</strong> <strong>the</strong> visualization using pylab’s subplotfunction during <strong>the</strong> simulation.

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

Saved successfully!

Ooh no, something went wrong!