This page was automatically generated by NetLogo 5.0.
The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Sun's Java site.
powered by NetLogo
view/download model file: honeycomb.nlogo
This is a modification of the “split Newtonian” (formation_newton.nlogo) physics-based model of a swarm, for the book entitled “Physicomimetics: Physics-Based Swarm Intelligence.”
Multiple particles use F = ma and a “split Newtonian” force law to self-organize into a honeycomb lattice.
As opposed to using two particle types to create a square lattice, the two particle types are used to create a honeycomb lattice. The honeycomb lattice is useful because, for a given separation distance, it provides the maximum area coverage of any regular lattice pattern. See Chapter 3 of the book for details.
The simulation automatically oscillates between a square lattice and a honeycomb lattice, in order to help remove the potential well at the center of each honeycomb cell. Since the honeycomb lattice is larger than the square lattice, the honeycomb cells are stable, whereas the square cells are not. Hence, the honeycomb lattice dominates the behavior.
In addition, the simulation model has been simplified. The split Newtonian parameter p is set to 2, and the force maximum FMAX is set to 1. The user can adjust the desired separation distance, and the code automatically computes the proper value for the gravitational constant G, using the theory established in Chapter 3.
Click SETUP AGENTS to initialize the particles, and click MOVE AGENTS to have them move.
The CLEAR button will clear the graphics, which becomes handy when particles have their pens down (more on this below).
The NUMBER_OF_PARTICLES slider allows you to control the number of particles created at initialization. Changing this slider while the simulation is running will have no effect.
All other sliders will affect the simulation when it is running.
Particles are initialized in a random cluster in the middle of the graphics pane, and self-organize into a honeycomb lattice. The lattice is not perfect, but that is OK because we are interested in “satisficing systems,” as opposed to “optimal systems.”
The DESIRED_SEPARATION is the desired distance between neighboring particles.
Again, FRICTION is enabled. This allows the system to stabilize.
Unlike the prior simulations, this model has been simplified by removing the computations of linear and angular momenta. This speeds up the simulation so that you can run it with a larger number of particles (e.g., 200).
See how the FRICTION changes behavior. Click SETUP AGENTS, lower the FRICTION, and click MOVE AGENTS. What happens?
Change the DESIRED_SEPARATION while the system is running. Try changing it slowly and then change it quickly. What happens?
If a particle is in the middle of a honeycomb cell, or some square cells remain, try reducing FRICTION temporarily.
In this model all particles have the same mass. What happens if particles have different masses? What happens when you change the sensor view (which requires a change in the code)? What other formations can you create by extending the code to include more types of particles?
Add the features and capabilities of the prior simulations to this model.
Note, in order to change any NetLogo simulation, you must have the source code (i.e., “honeycomb.nlogo”) downloaded to your computer, as well as NetLogo itself. You can not change the code when you are running the simulation with your browser.
This simulation draws edges between neighboring particles by cloning a particle, putting its pen down, and moving it to the neighboring particle. This is similar to a “virtual particle” in physics, which exists for a limited amount of time. After the cloned particle has drawn the edge, it dies.
If the graphics pane becomes too cluttered with drawn edges, click on the “CLEAR” button.
This is a modification to our second physics-based swarm simulation, which uses the generalized split Newtonian force law.
A different (but related) honeycomb model has been created by James McLurkin of Rice University. The title of the technical report is given below.
McLurkin, J.: Hexagonal lattice formation in multi-robot systems. Technical Report, Rice
University (2011).
If you mention this model in an academic publication, we ask that you include these citations for the model itself and for the NetLogo software:
- Spears, W. M. and Spears, D. F. (eds.) Physicomimetics: Physics-Based Swarm Intelligence, Springer-Verlag, (2011).
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
Copyright 2011 William M. Spears. All rights reserved.
Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed:
a) this copyright notice is included, and
b) this model will not be redistributed for profit without permission from William M. Spears. Contact William M. Spears for appropriate licenses for redistribution for profit.
; William M. Spears September 2011 ; Honeycomb Lattice Using the Split Newtonian Force Law ; For research and educational use only breed [particles particle] ; Introduce the "particle" breed globals [G p FR D FMAX DeltaT] turtles-own [hood deltax deltay r F Fx Fy v vx vy dvx dvy mass view square? counter] to setup clear-all ; Clear everything set p 2 set FMAX 1 ; Initialize force parameters ; Create and initialize particles create-particles Number_of_Particles [setup-particles] update-info reset-ticks end to run-and-monitor if (count turtles < 1) [user-message "Please click HALT and then SETUP AGENTS first" stop] update-info ask particles [ap-particles] ask turtles [move] tick end to setup-particles ; Set up the particles set square? false set counter 0 setxy (random-normal 0 20) (random-normal 0 20) ; Start in a cluster set heading random 360 ; Everyone has a random heading set vx 0 set vy 0 set mass 1 ; Start with no motion and mass = 1 set shape "circle" set size 5 ifelse ((who mod 2) = 0) [set color white] [set color yellow] ; Different colors for honeycomb formations end to ap-particles ; Run artificial physics set Fx 0 set Fy 0 ; Initialize force components to zero set vx (1 - FR) * vx ; Slow down according to friction set vy (1 - FR) * vy let edge false ; Flag to draw honeycomb edge set to false set hood [who] of other particles ; Get the IDs of everyone else foreach hood [ if (counter = 0) [set square? true] ; Occasionally switch between square and honeycomb if (counter > 100) [set square? false set counter -100] set counter counter + 1 set deltax (([xcor] of particle ?) - xcor) set deltay (([ycor] of particle ?) - ycor) set r sqrt (deltax * deltax + deltay * deltay) ifelse (square?) ; For square lattices [ifelse ((who mod 2) = (? mod 2)) [set view 1.3 set r (r / (sqrt 2))] [set view 1.7 set edge true] ; Set edge flag to true ] [ifelse ((who mod 2) = (? mod 2)) ; For honeycomb lattices [set view 1.3 set r (r / (sqrt 3))] [set view 1.7 set edge true] ; Set edge flag to true ] if (r < view * D) [ if (edge and (r < 1.1 * D) and (r > 0.9 * D)) ; Draw edge between neighbors [if ((ticks > 200) and (ticks mod 100 = 0)) [hatch 1 [pd set heading (atan deltax deltay) fd r die]]] ; The generalized split Newtonian law set F (G * mass * ([mass] of turtle ?) / (r ^ p)) if (F > FMAX) [set F FMAX] ; Bounds check on force magnitude ifelse (r > D) [set Fx (Fx + F * (deltax / r)) ; Attractive force, x-component set Fy (Fy + F * (deltay / r))] ; Attractive force, y-component [set Fx (Fx - F * (deltax / r)) ; Repulsive force, x-component set Fy (Fy - F * (deltay / r))] ; Repulsive force, y-component ] set edge false ] set dvx DeltaT * (Fx / mass) set dvy DeltaT * (Fy / mass) set vx (vx + dvx) ; The x-component of velocity set vy (vy + dvy) ; The y-component of velocity set v sqrt (vx * vx + vy * vy) set deltax DeltaT * vx set deltay DeltaT * vy if ((deltax != 0) or (deltay != 0)) [set heading (atan deltax deltay)] end to move ; Move the particle fd (sqrt (deltax * deltax + deltay * deltay)) end to update-info ; Update information from the sliders set FR Friction set DeltaT Time_Step set D Desired_Separation set G (FMAX * (D ^ p) / (2 * sqrt(3))) ; Compute best G from theory! end