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: dinos.nlogo

WHAT IS IT?

This model is an extension of the “split Newtonian” (formation_newton.nlogo) physics-based model of a swarm, for the book entitled “Physicomimetics: Physics-Based Swarm Intelligence.” We consider an application of autonomous surface vehicles (called “drones”) that float in the ocean and other bodies of water containing dinoflagellates. Dinoflagellates are single-celled organisms that are bioluminescent (i.e., they produce light when disturbed).

We focus on two real-world tasks. In the first task, a swarm of drones should move towards a goal location, while touching as few dinoflagellates as possible. This is useful for military applications where stealth is desired. A warship, submarine, or special forces team moving through a bioluminescent “hot spot” can easily generate enough light (by disturbing dinoflagellates) to be seen from high points on a nearby shoreline or via aircraft or satellite. The objective of the drones is to find a path through the dinoflagellates that a larger vehicle can follow, while minimally disturbing the organisms.

On the other hand, many dinoflagellate species are responsible for harmful algal blooms (HABs). HABs can produce neurotoxins that are dangerous to other marine organisms and to people swimming in the water. Hence, our second task is to find a path towards a goal that maximizes the collection of dinoflagellates along the way - for the sake of creating a dinoflagellate density map that can be used to forecast the movement of HABs and warn swimmers away from hazardous areas.

HOW IT WORKS

Multiple drones use F = ma and a “split Newtonian” force law to self-organize into a triangular lattice and move towards a goal. Depending on how the simulation is run, the drones can either seek to maximize or minimize their exposure to the dinoflagellates, while moving towards the goal.

WHAT IS NEW

There are two levels of “events” in the simulation. At the lower level are dinoflagellates that move and leave deposits of chemical toxins in the water. At the higher level there are aquatic drones that can detect, and track or avoid, the chemical traces.

This simulation allows you to control the random number “seed.” The seed uniquely determines the sequence of random events in the simulation. Hence, if you run the simulation twice with the same seed, the results will be identical. This is important when properly designing scientific experiments.

The code automatically computes the proper value for the gravitational constant G, using the theory established in Chapter 3. It also provides theoretical guidance for the magnitude of the force that pulls the swarm towards the goal.

HOW TO USE IT

Click SETUP to initialize the drones and the initial positions of the dinoflagellates. Then, click RUN DINOS to make the dinoflagellates move and produce a chemical toxin for 100 time steps. Finally, click MOVE DRONES to have them move through the environment towards the goal. The simulation ends when a drone makes it to the goal.

The NUMBER_OF_DRONES slider allows you to control the number of aquatic drones created at initialization. Changing this slider while the simulation is running will have no effect.

The RANDOM_SEED slider sets the random seed at the beginning of the simulation. If you always use the same random seed, the simulation will run the same way (assuming all other parameters are kept the same). Changing this slider while the simulation is running will have no effect.

The NUMBER_OF_DINOS slider allows you to control the number of dinoflagellates 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.

The TOGGLE GOAL button allows you to toggle the goal force on and off. The default is for it to be turned on.

The TOGGLE MIN/MAX button allows you to control whether the drones attempt to find a path to the goal that minimizes or maximizes exposure to the toxin. The default is to try to find the maximum path.

THINGS TO NOTICE

Drones are initialized in a cluster at the top right of the graphics pane, and self-organize into a triangular lattice. The goal is placed at the lower left, in order to make the drones move through as much of the environment as possible.

At each time step, the center of mass of the drones is computed and the location is shown as a red dot on the graphics pane. The sequence of red dots shows the trajectory of the center of mass of the drones.

The GOAL FORCE THEORY monitor provides an estimate of the strength of the goal force that is required to successfully pull the drones through the environment to the goal.

The AVERAGE CHEMICAL SEEN monitor reports the average amount of chemical toxin measured by the drones.

THINGS TO TRY

Run the simulation and note how much chemical was measured by the drones. Then, keeping the random seed the same, click the TOGGLE MIN/MAX button, and rerun the experiment. How much chemical is measured now?

Repeat the above experiment with different random seeds.

Try different values for the goal force. What happens?

Try different values for the DESIRED_SEPARATION.

Try different values for the NUMBER_OF_DRONES. Does varying the number of drones alter the robots’ effectiveness at the two tasks (i.e., maximization and minimization of chemical encountered on the way to the goal)?

Vary the NUMBER_OF_DINOS and determine how this affects performance on the two tasks.

What is the difference between the role played by virtual friction (which is set by the FRICTION slider) and real friction that would be encountered between a drone and the water?
How critical is virtual friction to mission success, and what level is needed for adequate performance?

In general, can you identify those parameter settings that result in (1) poor, (2) adequate, and (3) excellent performance at each of the two tasks? Explain why these parameter values lead to better/worse performance.

EXTENDING THE MODEL

Try adding obstacles, such as buoys to avoid, including obstacles of different sizes and shapes. See how this increases the difficulty of the tasks.

Introduce currents into the water that affect both the dinoflagellates and the drones. Run experiments that measure the drones’ performance as a function of the spatial and temporal extent, as well as the strength, of the currents.

Increase the number of agents beyond seven, and then test some of the hypotheses in Chapter 6 on your own. Create and then experimentally test new hypotheses that you invent based on your experiences with the simulator.

Note, in order to change any NetLogo simulation, you must have the source code (i.e., “dinos.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.

NETLOGO FEATURES

RELATED MODELS

This is an extension of our generalized split Newtonian force law model, for real-world applications.

This model provides insight into how we might apply artificial physics for function optimization, which will be shown in “apo.nlogo.”

CREDITS AND REFERENCES

For a discussion of a more real-world faithful simulation of the dinoflagellates and drones (as well as a description of the physical drone), see:

Frey, C. Zarzhitsky, D., Spears, W. M., Spears, D. F., Karlsson, C., Ramos, B., Hamann, J., and Widder, E. (2008) A physicomimetics control framework for swarms of autonomous vehicles. In Proceedings of the Oceans’08 Conference.

The NetLogo slime mold model is at:

Wilensky, U. (1997). NetLogo Slime model. http://ccl.northwestern.edu/netlogo/models/Slime. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

HOW TO CITE

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 NOTICE

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.

http://www.swarmotics.com

CODE

; William M. Spears and Christer Karlsson, September 2011
; Bioluminescence Tutorial Code
; The variable "dinos" refers to "dinoflagellates"
; For research and educational use only

; Version history
; Initial version of artificial physics by Brian Zuelke
; Extensive modifications by William M. Spears, September 2003
; Minor modifications to artificial physics by Christer Karlsson, February 2007
; Extensive modifications by Christer Karlsson, February - June 2007 

breed [drones drone]                                  ; Introduce the "drone" breed
breed [goals goal]                                    ; Introduce the "goal" breed
breed [dinos dino]                                    ; Introduce the "dinoflagellates" breed

globals [total_chemical G goal? goalF minimum? all_done? apoF 
         center_of_mass_x center_of_mass_y FR D FMAX DeltaT]

turtles-own [hood deltax deltay r F Fx Fy vx vy dvx dvy mass]

patches-own [chemical]

to setup
   clear-all                                          ; Clear everything 
   update-info
   random-seed Random_Seed                            ; Initialize the random number seed
                                                      ; Create and initialize drones
   create-drones Number_of_Drones [setup-drones]
                                                      ; Create the goal at lower left of graphics pane
   create-goals 1 [set color sky set size 2 set shape "circle" 
                   setxy (- world-width / 2.5) (- world-height / 2.5)]
                                                      ; Create and initialize dinoflagellates
   create-dinos Number_of_Dinos [set color yellow set shape "circle" set chemical 2
                                 setxy (random world-height) (random world-width)]
   ask patches [set chemical 0]                       ; Initialize with no toxin anywhere
      
   set goal? true                                     ; Goal force is on
   set minimum? false                                 ; Maximum or minumum chemical concentration?
   set all_done? false                                ; Not done yet!
   set total_chemical 0                               ; Initialize total amount of chemical seen
   set apoF 0.10                                      ; Set APO force to 0.1 (see Chapter 6)
                                                      ; Compute and display the center of mass of the drones
   set center_of_mass_x (sum [xcor * mass] of drones) / (sum [mass] of drones)
   set center_of_mass_y (sum [ycor * mass] of drones) / (sum [mass] of drones)
   ask patch (round center_of_mass_x) (round center_of_mass_y) [set pcolor red] 
   reset-ticks
end

to run-dinos                                          ; Runs dinoflagellates
   if (count turtles < 1) [user-message "Please click HALT and then SETUP first" stop]
   repeat 100 [                                       
      diffuse chemical 1                              ; For 100 steps, diffuse and evaporate the toxin
      ask patches [set chemical (chemical * 0.995) set pcolor (scale-color green chemical 0 6)]
      ask dinos [dino-life]                           ; Move the dinoflagellates
      tick
   ]
end

to run-and-monitor                                    ; Runs and monitors the drones
   if (count turtles < 1) [user-message "Please click HALT and then SETUP, and then RUN DINOS" stop]
   ifelse (not all_done?) [                           ; Run until the goal is reached
      update-info
      set G (0.9 * FMAX * (D ^ 2) / (2 * (sqrt 3)))   ; The gravitational constant is set according to theory
      ask drones [ap-drones]                          ; All drones compute where to move
      ask turtles   [move]                            ; All drones move
     
                                                      ; Compute and display the center of mass of the drones
      set center_of_mass_x (sum [xcor * mass] of drones) / (sum [mass] of drones)
      set center_of_mass_y (sum [ycor * mass] of drones) / (sum [mass] of drones)
      ask patch (round center_of_mass_x) (round center_of_mass_y) [set pcolor red]
      tick
   ]
   [stop]
end

to setup-drones                                       ; Setup the drones
   setxy (world-width / 2.5) (world-height / 2.5)     ; Place at upper right of graphics pane
   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 color orange set size 2
   ifelse (who = 0) [] [                              ; Carefully initialize the placement of the drones
      ifelse (who = 1) [setxy (xcor - 1) (ycor + 1)] [
         ifelse (who = 2) [set xcor (xcor - 2)] [
            ifelse (who = 3) [setxy (xcor + 1) (ycor + 1)] [
               ifelse (who = 4) [setxy (xcor - 1) (ycor - 1)] [
                  ifelse (who = 5) [setxy (xcor + 1) (ycor - 1)] [
                     ifelse (who = 6) [set xcor (xcor + 2)] [
                  ]]]]]]]  
end

to ap-drones                                          ; Run artificial physics on the drones
   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 ncount 0
   
   set hood [who] of other drones                     ; Get the IDs of all other drones
   foreach hood [         
      set deltax (([xcor] of drone ?) - xcor) 
      set deltay (([ycor] of drone ?) - ycor) 
      set r sqrt (deltax * deltax + deltay * deltay)
    
      if (r < 1.5 * D) [                              ; The generalized split Newtonian law
         set ncount (ncount + 1)
         set F (G * mass * ([mass] of turtle ?) / (r ^ 2)) 
         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
            
         ; Move towards chemical minimum or maximum
         ifelse ((minimum? and (chemical < ([chemical] of drone ?))) or
                 ((not minimum?) and (chemical > ([chemical] of drone ?))))
            [set Fx (Fx - (apoF * (deltax / r)))
             set Fy (Fy - (apoF * (deltay / r)))]
            [set Fx (Fx + (apoF * (deltax / r)))
             set Fy (Fy + (apoF * (deltay / r)))]
      ]
   ]
   ; Now include goal force, if toggled on and more than one particle
   if (goal? and (ncount > 0)) [
      set hood [who] of goals                         ; Get the IDs of the goal
      foreach hood [         
         set deltax (([xcor] of goal ?) - xcor) 
         set deltay (([ycor] of goal ?) - ycor) 
         set r sqrt (deltax * deltax + deltay * deltay)
         if (r < 2) [set all_done? true]              ; Reached the goal
         set Fx (Fx + (goalF * (deltax / r)))         ; Attractive force, x-component
         set Fy (Fy + (goalF * (deltay / r)))         ; Attractive force, y-component
      ]
   ]
   
   set total_chemical (total_chemical + chemical)     ; Keep track of all chemical seen
   
   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 deltax DeltaT * vx
   set deltay DeltaT * vy 
   if ((deltax != 0) or (deltay != 0)) 
      [set heading (atan deltax deltay)] 
end

to move
   fd (sqrt (deltax * deltax + deltay * deltay))      ; Move the drone
end

to update-info                                        ; Update information from the sliders
   set FMAX Force_Maximum
   set FR Friction
   set DeltaT Time_Step
   set D Desired_Separation
   set goalF Goal_Force
end

; Moves dinoflagellates. Really, the same model as the original Starlogo slime mold at 
; http://education.mit.edu/starlogo/samples/slime.htm, which suffices for dinoflagellates.
to dino-life   
   turn-toward-max-chemical                           ; Turn towards maximum chemical concentration
   rt random 40                                       ; Make a random wiggle
   lt random 40
   fd 1                                               ; Forward one step
   set chemical chemical + 2                          ; Replenish chemical
end

; This portion of code is from the NetLogo code at http://ccl.northwestern.edu/netlogo/models/Slime
to turn-toward-max-chemical
   let ahead   [chemical] of patch-ahead 1
   let myright [chemical] of patch-right-and-ahead 45 1
   let myleft  [chemical] of patch-left-and-ahead 45 1
   ifelse ((myright >= ahead) and (myright >= myleft))
      [rt 45] 
      [if (myleft >= ahead) [lt 45]]
end

; Turn the goal force on or off
to toggle-goal
   if (goal? != 0) [set goal? not goal?]
end

; Are the drones searching for maximum or minimum toxin?
to toggle-minmax
   if (minimum? != 0) [set minimum? not minimum?]
end