;; Comment out the __includes line for NetLogo Web use. ;;__includes ["includes/behaviorspace-stats.nls" "includes/parameter-import.nls"] globals [ agent-display-size ; Display size of frogs. male-color ; Display color of unmated male frogs. female-color ; Display color of unmated female frogs. mated-color ; Display color of mated frogs, both male and female. max-placement-attempts ; Maximum times placement of a male should be attempted. seed ; Random number seed gaussian-sigma-x ; Standard deviation used for Gaussian placement. gaussian-sigma-y ; Standard deviation used for Gaussian placement. round-pulse-numbers? ; Flag controlling rounding of pulse numbers (used for ; validation against Java SwampNR model, or to add ; "fuzziness" to mate targeting). round-to-half? ; Flag controlling to (k + 0.5) values, where k is an ; integer, vs. rounding to nearest integer. skip-import-dialog? ; Flag controlling display of CSV import dialog. ;; One or more of the following must be uncommented if the corresponding ;; control in the Interface is removed (i.e. to remove the user's ability to ;; modify that inpupt parameter). Each of the UI controls implicitly defines a ;; global variable; if a control is deleted from **Interface**, a variable by ;; the same name (such as one of those below) must be defined in this block, ;; and a value assigned in the setup-globals procedure. See the commented ;; assignments in setup-globals for more information, and for suitable default ;; values. ; max-run-length ; phonotaxis-speed ; random-walk-speed ; num-males ; male-territory-radius ; stdev-pulse-number ; mating-radius ] breed [females female] breed [males male] turtles-own [ mated? ; Boolean flag indicating whether this agent has mated. act ; Procedure for acting (moving or mating). mate ; Reference to agent with which this agent mated. time-to-mate ; Tick value (seconds) when this agent mated. ] males-own [ territory-radius ; Radius of territory in meters. mate-proximity ; Maximum distance in meters to available female at which ; male will act to mate. pulse-number ; Number of pulses per call. ] females-own [ speed-phonotaxis ; Movement speed towards intended mate, in meters/second. speed-random ; Movement speed when no mate is sensed. strategy ; Name of mating sensing/selection strategy. strategy-parameter ; Value of key parameter in sensing/selection. strategy-pool ; Reporter procedure used to filter potential mates. strategy-selector ; Reporter procedure used to select intended mate. distance-traveled ; Total distance traveled, in meters. candidates ; Stack recording history of mates sensed/selected. ] ; Initializes on model load. to startup clear-all set skip-import-dialog? false end ;; Initializes swamp environment and male and female frog populations to setup clear-turtles clear-patches clear-all-plots let _global-overrides [[]] let _female-overrides [[]] let _male-overrides [[]] let _overrides load-overrides ifelse (empty? _overrides) [ set skip-import-dialog? true ] [ set _global-overrides (item 0 _overrides) set _female-overrides (item 1 _overrides) set _male-overrides (item 2 _overrides) ] setup-globals _global-overrides setup-females _female-overrides setup-males _male-overrides reset-ticks end ;; Performs one iteration of the simulation: ;; ;; 1. Checks stopping conditions and stops if appropriate. ;; 2. Asks unmated female frogs (shuffled) to sense. ;; 3. Asks all unmated frogs (shuffled) to act. to go let -male-pool (males with [not mated?]) let _female-pool (females with [not mated?]) if ( (not any? -male-pool) or (not any? (_female-pool with [ any? (runresult strategy-pool -male-pool strategy-parameter)])) or (ticks >= max-run-length) ) [ stop ] ask _female-pool [ sense -male-pool ] ask (turtle-set _female-pool -male-pool) [ run act ] tick end ;; If the necessary components have been loaded, prompt the user to specify a ;; data file from which variable override values are then loaded and reported. ;; ;; Reports: ;; list of lists of lists, containing override variable names and values. to-report load-overrides let _overrides [ [[]] [[]] [[]] ] if ((is-boolean? skip-import-dialog?) and (not skip-import-dialog?) and (not netlogo-web?)) [ carefully [ let _run-number (runresult "behaviorspace-run-number") if (_run-number = 0) [ set _overrides (runresult "import-data") ] ] [ set _overrides [] ] ] report _overrides end ;; Initializes values of global variables. ;; ;; Input parameters: ;; _overrides - list of lists; first embedded list contains variables names, ;; and the second contains corresponding values. to setup-globals [_overrides] let _override-variables [] let _override-values [] if (length _overrides > 1) [ set _override-variables (first _overrides) set _override-values (first but-first _overrides) ] set agent-display-size 0.5 set male-color yellow set female-color (lime + 1) set mated-color (red - 2) set-default-shape females "female gray tree frog" set-default-shape males "male gray tree frog" set max-placement-attempts 100 set seed new-seed set gaussian-sigma-x (world-width / 4) set gaussian-sigma-y (world-height / 4) set round-pulse-numbers? false ; Set to true to use rounded pulse numbers. set round-to-half? false ; Set to true to round to (k + 0.5), where ; k is an integer. set skip-import-dialog? ( (not is-boolean? skip-import-dialog?) or skip-import-dialog?) ;; Uncomment one (or more) of the following assignments if the corresponding ;; control is removed from the UI, and the associated global is uncommented ;; in the globals block. ; set max-run-length 3600 ; set phonotaxis-speed 1.86 ; set random-walk-speed 1.44 ; set num-males 25 ; set male-territory-radius 50 ; set stdev-pulse-number 2 ; set mating-radius 4 override _override-variables _override-values random-seed seed end ;; Creates female frogs and initializes their states. ;; ;; Input parameters: ;; _overrides - list of lists; first embedded list contains variables names, ;; subsequent lists contain corresponding values. to setup-females [_overrides] let _override-variables [] let _override-values (n-values num-females [(list)]) if (length _overrides > 1) [ set _override-variables (first _overrides) set _override-values (but-first _overrides) ] let _placement [[] -> place-edges] create-females num-females [ set color female-color set size agent-display-size set speed-phonotaxis (phonotaxis-speed / 100) set speed-random (random-walk-speed / 100) set act [ -> move-to-mate] set strategy female-strategy run _placement let _values [] if (not empty? _override-values) [ set _values (first _override-values) set _override-values (but-first _override-values) ] override _override-variables _values ( if-else (strategy = "best-of-n") [ set strategy-parameter best-of-n set strategy-pool [ [_pool _parameter] -> best-of-n-pool _pool _parameter ] set strategy-selector [ [_pool _parameter] -> select-best-of-n _pool _parameter ] ] (strategy = "min-threshold") [ set strategy-parameter min-threshold set strategy-pool [ [_pool _parameter] -> min-threshold-pool _pool _parameter ] set strategy-selector [ [_pool _parameter] -> select-min-threshold _pool _parameter ] ] (strategy = "uniform-random") [ set strategy-parameter 0 set strategy-pool [ [_pool _ignore] -> uniform-random-pool _pool _ignore ] set strategy-selector [ [_pool _ignore] -> select-uniform-random _pool _ignore ] ] ) set time-to-mate 0 set distance-traveled 0 set candidates [] set mated? false set mate nobody ] end ;; Creates male frogs and initializes their states. ;; ;; Input parameters: ;; _overrides - list of lists; first embedded list contains variables names, ;; subsequent lists contain corresponding values. to setup-males [_overrides] let _override-variables [] let _override-values (n-values num-males [(list)]) if (length _overrides > 1) [ set _override-variables (first _overrides) set _override-values (but-first _overrides) ] let _placement (word "place-" male-distribution) create-males num-males [ set color male-color set size agent-display-size set territory-radius (male-territory-radius / 100) set mate-proximity (mating-radius / 100) set act [-> mate-in-range] set pulse-number (random-normal mean-pulse-number stdev-pulse-number) if (round-pulse-numbers?) [ ifelse (round-to-half?) [ set pulse-number (0.5 + round (pulse-number - 0.5)) ] [ set pulse-number (round pulse-number) ] ] run _placement let _values [] if (not empty? _override-values) [ set _values (first _override-values) set _override-values (but-first _override-values) ] override _override-variables _values set mated? false set mate nobody ] end ;; Places a male frog in the swamp, following a uniform random distribution, ;; constrained to ensure that it is not too close to the edges or to another ;; male frog. to place-uniform-random let _initial-placement? true let _attempt-countdown max-placement-attempts while [_initial-placement? or close-to-edge? or close-to-another?] [ if (_attempt-countdown <= 0) [ error (word "Unable to satisfy specified spacing (male-territory-radius) " "when placing male frogs") ] setxy random-xcor random-ycor set _initial-placement? false set _attempt-countdown (_attempt-countdown - 1) ] end ;; Places a male frog in the swamp, following a Gaussian distribution, with mean ;; at the center of the swamp, and standard deviation as given in the ;; gaussian-sigma global. The sampled values are further constrained (using a ;; rejection method) to ensure that the frog is not placed too close to the ;; edges or to another male frog. to place-gaussian let _initial-placement? true let _attempt-countdown max-placement-attempts let _mean-x (world-width / 2) let _mean-y (world-height / 2) while [_initial-placement? or close-to-edge? or close-to-another?] [ if (_attempt-countdown <= 0) [ error (word "Unable to satisfy specified spacing (male-territory-radius) " "when placing male frogs") ] setxy (constrained (random-normal _mean-x gaussian-sigma-x) (lower-bound min-pxcor) (upper-bound max-pxcor)) (constrained (random-normal _mean-y gaussian-sigma-y) (lower-bound min-pycor) (upper-bound max-pycor)) set _initial-placement? false set _attempt-countdown (_attempt-countdown - 1) ] end ;; Places a male frog in the swamp, following one or four constrained Gaussian ;; distribution, with means at the corners of the swamps, all with stdev(x) = ;; swamp width / 4, stdev(y) = swamp height / 4. The distribution is constrained ;; to ensure that the frog is not placed too close to the edges or to another ;; male frog. ;; ;; Actually, rather than selecting one of 4 distributions, and then ;; sampling from the selected distribution, this is done by sampling from a ;; single unimodal Gaussian distribution, centered at (0, 0), then translating ;; each of the four quadrants of the distribution to the opposite corner of the ;; swamp. For example, a sampled value in the 1st quadrant (X >= 0, Y >= 0) is ;; translated to the lower-left corner of the swamp by shifting the X and Y ;; values, while a sampled value in the 3rd quadrant (X < 0, Y < 0) is ;; translated to the upper-right corner of the swamp. to place-inverse-gaussian let _initial-placement? true let _attempt-countdown max-placement-attempts while [_initial-placement? or close-to-edge? or close-to-another?] [ if (_attempt-countdown <= 0) [ error "Unable to maintain male-territory-radius when placing male frogs" ] let _x (random-normal 0 gaussian-sigma-x) let _y (random-normal 0 gaussian-sigma-y) set _x (ifelse-value (_x >= 0) [ _x + lower-bound min-pxcor ] [ _x + upper-bound max-pxcor ]) set _y (ifelse-value (_y >= 0) [ _y + lower-bound min-pycor ] [ _y + upper-bound max-pycor ]) setxy (constrained _x (lower-bound min-pxcor) (upper-bound max-pxcor)) (constrained _y (lower-bound min-pycor) (upper-bound max-pycor)) set _initial-placement? false set _attempt-countdown (_attempt-countdown - 1) ] end ;; Places a female frog at the edge of the swamp, by sampling from a uniform ;; random distribution in the interval [0, 2 * (world-width + world-height)), ;; and "wrapping" the result around the perimeter of the world. This results in ;; a probability of placement along a given edge proportionate to the length of ;; that edge. to place-edges let _selector random-float (2 * (world-width + world-height)) if (_selector < world-width) [ setxy (_selector + lower-bound min-pxcor) (lower-bound min-pycor) stop ] set _selector (_selector - world-width) if (_selector < world-height) [ setxy (upper-bound max-pxcor) (_selector + lower-bound min-pycor) stop ] set _selector (_selector - world-height) if (_selector < world-width) [ setxy (_selector + lower-bound min-pxcor) (upper-bound max-pycor) stop ] set _selector (_selector - world-width) setxy (lower-bound min-pxcor) (_selector + lower-bound min-pycor) end ;; Detects placement unacceptably close to the edge of the swamp, by comparing ;; the distance to the edges with the this male frog's territory-radius, and ;; reporting true if the former (for any edges) is less than the latter. ;; ;; Reports: ;; true if this frog is too close to the edge, false otherwise. to-report close-to-edge? report ( xcor - lower-bound min-pxcor < territory-radius or upper-bound max-pxcor - xcor < territory-radius or ycor - lower-bound min-pycor < territory-radius or upper-bound max-pycor - ycor < territory-radius ) end ;; Detects placement unacceptably close to another male frog by computing the ;; set of male frogs whose distance from this male frog is less than the sum of ;; the territory-radius of both, and returning true if the resulting set is not ;; empty. (Note: In the current model, male frogs are homogeneous in their ;; territorial radii: all have the same value of territorial-radius. However, ;; this procedure will still function as expected if the model is modified so ;; that male frogs are heterogeneous - that is, if different male frogs have ;; different values of territorial-radius.) ;; ;; Reports: ;; true if this frog is too close to the another male, false otherwise. to-report close-to-another? report (any? other males with [(distance myself) < territory-radius + [territory-radius] of myself]) end ;; Senses and selects (as appropriate) an unmated male frog as a potential mate ;; for this female frog. Depending on the strategy used, this may or may not ;; result in a change in the potential mate selected. ;; ;; Input parameter: ;; _raw-pool - agentset of all (presumably) unmated male frogs. to sense [_raw-pool] update-candidates (runresult strategy-selector _raw-pool strategy-parameter) end ;; Moves this female frog toward the currently selected potential mate; if no ;; potential mate has been sensed/selected, a random walk step is taken. to move-to-mate let _distance 0 ifelse (not empty? candidates) [ set _distance (speed-phonotaxis) face (first candidates) forward _distance ] [ let _x xcor let _y ycor set _distance (speed-random) set heading (random-float 360) forward _distance set _distance (distancexy _x _y) ] set distance-traveled (distance-traveled + _distance) end ;; Detects the presence of an unmated female in contact with (i.e. within the ;; mate-proximity threshold distance) this male frog; if one is found, mating ;; takes place, and both the male and female are removed from the mating pool. ;; In the unlikely event that more than one unmated female is in contact with ;; this male frog, one is selected at random. ;; ;; Note that this mating logic is independent of the female frog's sensing or ;; selection of a mate. So if a female, moving towards a sensed/selected mate, ;; comes into contact with a second unmated male along the way, the second male ;; will mate with that female, to mate-in-range let _available-females ((females in-radius mate-proximity) with [not mated?]) if (any? _available-females) [ set mate (one-of _available-females) set mated? true set time-to-mate (ticks + 1) set color mated-color ask mate [ set mate myself set mated? true set act [->] set time-to-mate (ticks + 1) set color mated-color ] ] end ;; Given a specified pool of unmated male frogs, selects and reports the n that ;; are closest (in Euclidean distance) to this female. If the pool contains n ;; members or fewer, then the entire pool is returned. ;; ;; Input parameters: ;; _raw-pool - agentset of all (presumably) unmated male frogs. ;; _n - maximum number of male frogs included in the result. ;; ;; Reports: ;; subset of _raw-pool containing the _n nearest to this female frog. to-report best-of-n-pool [_raw-pool _n] report ifelse-value (_n < count _raw-pool) [ min-n-of _n _raw-pool [distance myself] ] [ _raw-pool ] end ;; Given a specified pool of unmated male frogs, selects and reports the subset ;; with a pulse number greater than or equal to the specified value. ;; ;; Input parameters: ;; _raw-pool - agentset of all (presumably) unmated male frogs. ;; _threshold - minimum required pulse number. ;; ;; Reports: ;; subset of _raw-pool with a pulse number of at least _threshold. to-report min-threshold-pool [_raw-pool _threshold] report (_raw-pool with [pulse-number >= _threshold]) end ;; Given a specified pool of unmated male frogs, selects and reports the entire ;; pool (i.e. all are eligible for selection under the uniform-random strategy). ;; ;; Input parameters: ;; _raw-pool - agentset of all (presumably) unmated male frogs. ;; _ignore - strategy parameter (ignored). ;; ;; Reports: ;; _raw-pool, unfiltered. to-report uniform-random-pool [_raw-pool _ignore] report _raw-pool end ;; Given a specified pool of unmated male frogs, selects and reports the male ;; frog that is one of the n closest (in Euclidean distance) to this female, and ;; which has the maximum (within the n closest subset) pulse number. If more ;; then one of the n closest unmated males has this maximum pulse number ;; (extremely unlikely, unless pulse numbers are rounded), the closest of these ;; is chosen. Note that since the set of n closest may change as this female ;; frog moves, this selection does not depend on whether a potential mate has ;; been selected previously, or whether that mate is still available; thus, this ;; female may change the selected potential mate as better (presumably fitter) ;; candidates are sensed. ;; ;; Input parameters: ;; _raw-pool - agentset of all (presumably) unmated male frogs. ;; _n - maximum number of male frogs included in the subset. ;; ;; Reports: ;; member of subset of _raw-pool nearest to this female frog with the maximum ;; pulse number. to-report select-best-of-n [_raw-pool _n] report (min-one-of ( (runresult strategy-pool _raw-pool _n) with-max [pulse-number]) [distance myself]) end ;; Given a specified pool of unmated male frogs, selects and reports the nearest ;; one to this female frog with a pulse number greater than or equal to the ;; specified threshold value. Note that if a potential mate was previously ;; identified, this procedure will continue to report the same potential mate as ;; long as it is still available (unmated). ;; ;; Input parameters: ;; _raw-pool - agentset of all (presumably) unmated male frogs. ;; _threshold - minimum required pulse number. ;; ;; Reports: ;; member of subset (with sufficiently high pulse number) nearest to this ;; female frog. to-report select-min-threshold [_raw-pool _threshold] let _selected nobody ifelse (empty? candidates or [mated?] of first candidates) [ let _filtered-pool (runresult strategy-pool _raw-pool _threshold) set _selected ( ifelse-value (any? _filtered-pool) [ min-one-of (runresult strategy-pool _raw-pool _threshold) [distance myself] ] [ nobody ] ) ] [ set _selected (first candidates) ] report _selected end ;; Given a specified pool of unmated male frogs, selects and reports member of ;; the pool at random, with all members having equal probability of selection. ;; Note that if a potential mate was previously identified, and if that mate is ;; still available, this procedure will continue to report the same potential ;; mate as long as it is still available (unmated). ;; ;; Input parameters: ;; _raw-pool - agentset of all (presumably) unmated male frogs. ;; _ignore - strategy parameter (ignored). ;; ;; Reports: ;; male selected at random from _raw-pool, with equal likelihood, or the ;; previously selected male (if a selection was made previously, and the ;; previously selected male is still unmated). to-report select-uniform-random [_raw-pool _ignore] report (ifelse-value (empty? candidates or [mated?] of first candidates) [ one-of _raw-pool ] [ first candidates ]) end ;; Updates the stack of selected potential mates, if the specified candidate is ;; not already at the top of the stack. ;; ;; Input parameter: ;; _candidate - male selected (at least for now) as a potential mate by this ;; female. to update-candidates [_candidate] if (is-agent? _candidate and (empty? candidates or first candidates != _candidate)) [ set candidates (fput _candidate candidates) ] end ;; Reports a numeric value constrained within specified limits. ;; ;; Input parameters: ;; _val - value to constrain. ;; _min - lower bound of range within which _val will be constrained. ;; _max - upper bound of range within which _val will be constrained. ;; ;; Reports: ;; _min if _val < _min, _max if _val > _max, _val otherwise. to-report constrained [_val _min _max] report (max (list _min (min (list _val _max)))) end ;; Reports a type of rounded value, based on patch coordinates - specifically, ;; the lower bound of one of a patch's coordinates, given a value within that ;; patch. For example, the patch centered at (10, -20) contains X values in the ;; half-closed interval [9.5, 10.5), and Y values in the half-closed interval ;; [-20.5, -19.5); thus, invoking this method with a value in the interval ;; [9.5, 10.5) reports 9.5, while invoking it with a value in the interval ;; [-20.5, -19.5) reports -20.5. ;; ;; This is a particularly useful operation when placing agents at the extreme ;; lower bounds (bottom or left) of the NetLogo world, since those bounds ;; coincide with the lower bounds of the patches along those edges of the world. ;; ;; Input parameter: ;; _val - value to round. ;; ;; Reports: ;; _val rounded down to the next lower value of the form n + 0.5, where n is an ;; integer. to-report lower-bound [_val] report (-0.5 + round _val) end ;; Reports a type of rounded value, based on patch coordinates - specifically, ;; the (approximate) upper bound of one of a patch's coordinates, given a value ;; within that that patch. For example, the patch centered at (10, -20) contains ;; X values in the half-closed interval [9.5, 10.5), and Y values in the ;; half-closed interval [-20.5, -19.5); thus, invoking this method with a value ;; in the interval [9.5, 10.5) reports 10.499999999999, while invoking it with a ;; value in the interval [-20.5, -19.5) reports -19.499999999999. ;; ;; Note that this is an approximate value for two reasons: First, the extreme ;; value at the open end of a half-closed interval, but still within the ;; interval, is not defined (since the endpoint itself is not within the ;; interval); second, the maximum number of digits in the fractional portion of ;; an IEEE double-precision floating point value depends on the magnitude of the ;; value. Here, we're using 12 digits for the fraction portion; this supports ;; operations on values in (at least) the interval (-10000, 10000). ;; ;; This is a particularly useful operation when placing agents at the extreme ;; upper bounds (top or right) of the NetLogo world, since those bounds ;; coincide with the upper bounds of the patches along those edges of the world, ;; and since - when wrapping is disabled - attempting to place an agent outside ;; the world bounds results in an error. ;; ;; Input parameter: ;; _val - value to round. ;; ;; Reports: ;; _val rounded up to the next lower value of the form n + 0.499999999999, ;; where n is an integer. to-report upper-bound [_val] report (0.499999999999 + round _val) end ;; Reports the number of mated females - which is, by definition, equal to the ;; number of mated males, and thus to the number of mated pairs. ;; ;; Reports: ;; number of mated male/female pairs. to-report mated-pairs report (count females with [mated?]) end ;; Computes and reports the average time between the start of the simulation and ;; the time when mating occurred, for all mated females. ;; ;; Reports: ;; observed average time to mate, for all mated females. to-report avg-time-to-mate let _pool (females with [mated?]) report (ifelse-value (any? _pool) [mean [time-to-mate] of _pool] [0]) end ;; Computes and reports the actual average (not the theoretical mean, which is a ;; control parameter to the model itself) pulse number for males, using an input ;; parameter to specify whether this average should be computed for all males, ;; or only mated males. ;; ;; Input parameter: ;; _mated-only? - flag specifying inclusion of mated males only (true) or ;; all males. ;; ;; Reports: ;; average pulse number for the specified subset of males. to-report avg-pulse-number [_mated-only?] let _pool males if (_mated-only?) [ set _pool (_pool with [mated?]) ] report (ifelse-value (any? _pool) [mean [pulse-number] of _pool] [0]) end ;; Computes and reports the average distance traveled by females, using an input ;; parameter to specify whether this average should be computed for all females, ;; or only mated females. ;; ;; Input parameter: ;; _mated-only? - flag specifying inclusion of mated females only (true) or ;; all females. ;; ;; Reports: ;; average distanced traveled by the specified subset of females. to-report avg-distance-traveled [_mated-only?] let _pool females if (_mated-only?) [ set _pool (_pool with [mated?]) ] report ( 100 * ifelse-value (any? _pool) [mean [distance-traveled] of _pool] [0]) end ;; Computes and reports the average number of males targeted, using an input ;; input parameter to specify whether this average should be computed for all ;; females, or only mated females. If the same male is targeted multiple times ;; by a given female, the inclusion of multiple targetings of that male (beyond ;; the first) is controlled by the _distinct? parameter. ;; ;; Input parameter: ;; _mated-only? - flag specifying inclusion of mated females only (true) or ;; all females. ;; _distinct? - flag specifying rejection of more than one targeting of the ;; the same male by any given female. ;; ;; Reports: ;; average number of males targeted by the specified subset of females. to-report avg-mates-selected [_mated-only? _distinct?] let _pool females if (_mated-only?) [ set _pool (_pool with [mated?]) ] report (ifelse-value (any? _pool) [mean [length (ifelse-value (_distinct?) [remove-duplicates candidates] [candidates])] of _pool] [0]) end ;; Sets a number of variable values, based on the variables names specified in ;; the first input parameter, and the values specified in the second. The ;; intended purpose is to set global and agent variables to simple values read ;; read from a file. (In general, agent and agentset references can't be set in ;; this fashion, except for the agent value nobody.) If the 2 input lists are ;; not of the same length, the number of variable values set will be the minimum ;; of the 2 lengths. ;; ;; Input parameter: ;; _variables - list of variables names to be set. ;; _values - list of variable values. to override [_variables _values] let _length (min list (length _variables) (length _values)) set _variables (sublist _variables 0 _length) set _values (sublist _values 0 _length) (foreach _variables _values [[_var _val] -> if (is-string? _val) [ set _val (word "\"" _val "\"") ] let _command (word "set " _var " " _val) run _command ]) end ;; Credits and references ;; ;; 1. The original model was developed in the SimWorld environment by Matthias ;; Scheutz (Tufts University) and colleagues. Scheutz M, Harris J. "An ;; overview of the SimWorld agent-based grid experimentation system". In: ;; Werner DF, Kurowski K, Schott B, editors. Large-Scale Computing Techniques ;; for Complex System Simulations: Wiley; 2011. ;; https://onlinelibrary.wiley.com/doi/10.1002/9781118130506.ch4 ;; ;; 2. The model and initial research findings are described in: Ferreira GBS, ;; Scheutz M, and Boyd SK (2018) "Mate choice strategies in a ;; spatially-explicit model environment". PLoS ONE 13(8): e0202680. ;; https://doi.org/10.1371/journal.pone.0202680 ;; ;; 3. Datasets from the original model implementation are available at Dryad: ;; doi:10.5061/dryad.2350931 and the University of Notre Dame repository: ;; doi:10.7274/R08S4N0S. ;; ;; 4. This model was implemented in NetLogo by Nicholas Bennett & Sunny Boyd. ;; ;; 5. If you use or refer to this model in a publication, we ask that you cite ;; the model itself, the source publication and the NetLogo software: ;; ;; For the model itself: ;; ;; * Boyd, S. and Bennett, N. (2018). NetLogo Treefrog Mating Model. (INSERT ;; URL HERE). Department of Biological Sciences, University of Notre Dame, ;; Notre Dame, IN. CNM Ingenuity, Central New Mexico Community College, ;; Albuquerque, NM. ;; ;; For the source publication: ;; ;; * Ferreira GBS, Scheutz M, and Boyd SK (2018) Mate choice strategies in a ;; spatially-explicit model environment. PLoS ONE 13(8): e0202680. ;; ;; Please cite the NetLogo software as: ;; ;; * Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. ;; Center for Connected Learning and Computer-Based Modeling, Northwestern ;; University, Evanston, IL. ;; ;; 6. Copyright 2018 Nicholas Bennett, Sunny Boyd, and the University of Notre ;; Dame. ;; ;; 7. This work is licensed under a Creative Commons ;; Attribution-NonCommercial-ShareAlike 4.0 International License ;; (http://creativecommons.org/licenses/by-nc-sa/4.0/). ;; ;; 8. We gratefully acknowledge the support of the National Science Foundation ;; (IOS # 0725187, 1257777, 1257815). @#$#@#$#@ GRAPHICS-WINDOW 210 10 968 319 -1 -1 30.0 1 10 1 1 1 0 0 0 1 0 24 0 9 1 1 1 seconds 60.0 CHOOSER 975 110 1165 155 male-distribution male-distribution "gaussian" "uniform-random" "inverse-gaussian" 0 SLIDER 975 30 1165 63 num-males num-males 0 50 25.0 1 1 NIL HORIZONTAL BUTTON 10 365 100 398 Setup setup NIL 1 T OBSERVER NIL S NIL NIL 1 SLIDER 10 30 200 63 num-females num-females 0 50 20.0 1 1 NIL HORIZONTAL SLIDER 975 70 1165 103 male-territory-radius male-territory-radius 0 100 50.0 5 1 cm HORIZONTAL CHOOSER 10 70 200 115 female-strategy female-strategy "best-of-n" "min-threshold" "uniform-random" 0 SLIDER 975 165 1165 198 mean-pulse-number mean-pulse-number 1 40 18.0 1 1 NIL HORIZONTAL SLIDER 975 205 1165 238 stdev-pulse-number stdev-pulse-number 0 5 2.0 1 1 NIL HORIZONTAL TEXTBOX 980 10 1170 28 Male parameters (yellow agents) 11 0.0 1 TEXTBOX 15 10 235 28 Female parameters (green agents) 11 0.0 1 SLIDER 10 125 200 158 best-of-n best-of-n 1 5 3.0 1 1 NIL HORIZONTAL SLIDER 10 165 200 198 min-threshold min-threshold 0 24 12.0 1 1 NIL HORIZONTAL SLIDER 10 205 200 238 phonotaxis-speed phonotaxis-speed 1 2 1.86 0.01 1 cm/sec HORIZONTAL SLIDER 10 245 200 278 random-walk-speed random-walk-speed 1 2 1.44 0.01 1 cm/sec HORIZONTAL SLIDER 975 245 1165 278 mating-radius mating-radius 0 10 4.0 0.1 1 cm HORIZONTAL BUTTON 110 365 200 398 Go go T 1 T OBSERVER NIL G NIL NIL 0 PLOT 450 325 685 470 Pulse Numbers Pulse Number Male Frogs 0.0 10.0 0.0 10.0 true false "let _pulse-numbers ([pulse-number] of males)\nlet _excess ifelse-value ((ceiling max _pulse-numbers) = (max _pulse-numbers)) [1] [0]\nset-plot-x-range (floor min _pulse-numbers) (_excess + ceiling max _pulse-numbers)\nset-current-plot-pen \"All males\"\nset-plot-pen-color male-color\nhistogram _pulse-numbers" "\n" PENS "All males" 1.0 1 -987046 true "set-plot-pen-color male-color" "let _pulse-numbers ([pulse-number] of males)\nif (not empty? _pulse-numbers) [\n set-plot-y-range 0 1\n histogram _pulse-numbers\n]" "Mated" 1.0 1 -7500403 true "set-plot-pen-color mated-color" "let _pulse-numbers ([pulse-number] of males with [mated?])\nif (not empty? _pulse-numbers) [\n histogram _pulse-numbers\n]" MONITOR 585 475 685 520 Average (Mated) avg-pulse-number true 2 1 11 PLOT 690 325 925 470 Distance Traveled Centimeters Female Frogs 0.0 10.0 0.0 10.0 true false "" "" PENS "All females" 1.0 1 -16777216 true "set-plot-pen-color female-color\nset-plot-pen-interval 100" "let _distances ([100 * distance-traveled] of females)\nif (not empty? _distances) [\n let _excess ifelse-value ((ceiling max _distances) = (max _distances)) [1] [0]\n set-plot-x-range (100 * floor ((min _distances) / 100)) (100 * (_excess + ceiling ((max _distances) / 100)))\n set-plot-y-range 0 1\n histogram _distances\n]" "Mated" 1.0 1 -7500403 true "set-plot-pen-color mated-color\nset-plot-pen-interval 100" "let _distances ([100 * distance-traveled] of females with [mated?])\nif (not empty? _distances) [\n histogram _distances\n]" MONITOR 825 475 925 520 Average (Mated) avg-distance-traveled true 2 1 11 MONITOR 110 425 200 470 Mated Pairs mated-pairs 17 1 11 SLIDER 10 325 200 358 max-run-length max-run-length 0 10000 3600.0 100 1 seconds HORIZONTAL PLOT 930 325 1165 470 Mates Targeted NIL NIL 0.0 10.0 0.0 10.0 true false "" "" PENS "All females" 1.0 1 -10899396 true "set-plot-pen-color female-color" "let _candidate-count ([length candidates] of females)\nif (not empty? _candidate-count) [\n set-plot-x-range 0 (1 + max _candidate-count)\n set-plot-y-range 0 1\n histogram _candidate-count\n]" "Mated" 1.0 1 -7500403 true "set-plot-pen-color mated-color" "let _candidate-count ([length candidates] of females with [mated?])\nif (not empty? _candidate-count) [\n histogram _candidate-count\n]" MONITOR 930 475 1030 520 Average avg-mates-selected false false 2 1 11 MONITOR 1065 475 1165 520 Average (Mated) avg-mates-selected true false 2 1 11 MONITOR 690 475 790 520 Average avg-distance-traveled false 2 1 11 MONITOR 450 475 550 520 Average avg-pulse-number false 2 1 11 PLOT 210 325 445 470 Time to Mate Minutes Pairs 0.0 10.0 0.0 10.0 true false "" "" PENS "default" 1.0 1 -16777216 true "set-plot-pen-color mated-color" "let _mate-times [time-to-mate / 60] of females with [mated?]\nif (not empty? _mate-times) [\n let _max-time (max _mate-times)\n let _excess (1 - (ceiling _max-time - floor _max-time))\n set-plot-x-range 0 (_excess + ceiling _max-time)\n set-plot-y-range 0 1\n histogram _mate-times\n]" MONITOR 280 475 380 520 Average avg-time-to-mate / 60 2 1 11 @#$#@#$#@ ## What is it? Choice of a mate can impact ultimate fitness of individual organisms and the evolution of species. This model explores the decision-making process of female frogs engaged in the task of choosing a male mate. Two classic theories for female decision-making in this task—the _best-of-n_ and the _minimum-threshold_ theories—are compared (along with the availability of a "null" model consisting of random choice). ## How it works The model includes male and female treefrog agents engaged in the mate choice task. The world is a two-dimensional "swamp" with realistic dimensions of 10 m by 25 m. Female agents seek male mates according to their mate choice strategy—the _best-of-n_, the _minimum-threshold_, or the random strategy. The first two strategies also include a strategy parameter, to specify the _N_ in the _best-of-n_ strategy or the threshold in the _minimum-threshold_ strategy. Female agents are initially randomly distributed (according to a continuous uniform probability distribution) around the edges of the swamp. Male agents advertise their quality (via the pulse number of their advertisement calls) and their location. Males are distributed on non-overlapping territories at initialization, from which they advertise but do not move (unless they mate). The spatial distributions available are Gaussian (males more clustered in the center of the swamp), inverse Gaussian (more males on the edges, as might occur around the edges of a pond), and random (a continuous uniform probability distribution over the area of the swamp). The model proceeds with female agents sampling the male agents, selecting a target male (according to her own strategy), and approaching him. Females using the _best-of-n_ strategy resample at each time step but females using the other strategies resample only if their initial target male is removed by mating. When females are within the pre-determined mating distance of a male, the pair mates and is removed from the simulation. ## How to use it ### Setup parameters Adjust the following controls before pressing the **Setup** button to initialize the model. #### Female frog parameters * **num-females** The number of female frogs created when the model is initialized. * **female-strategy** The mate sensing/targeting strategy employed by the female frogs. * _best-of-n_ At each step, the female frog senses the closest _N_ (set with the **best-of-n** slider) available (unmated) male frogs, and targets the one with the highest pulse number. Note that as the female moves toward the targeted male, the set of the _N_ closest available males sensed by the female may change, which can result in the female targeting a different male even if her previously selected target is still available. * _min-threshold_ The female frog senses the available males with a pulse number greater than or equal to the value of the **min-threshold** parameter, and targets the nearest of those males. If another female reaches the targeted male first, then another male is targeted, using the same strategy. * _uniform-random_ The female frog senses all available males in the swamp, and selects one at random, where each male has a uniform likelihood of selection. If another female reaches the targeted male first, then another male is targeted, using the same strategy. * **best-of-n** The control parameter (number of nearby male frogs sensed) for the _best-of-n_ mating strategy. * **min-threshold** The control parameter (minimum pulse number threshold) for the _min-threshold_ mating strategy. * **phonotaxis-speed** The distance traveled (in cm) each second by a female frog toward the currently targeted male. * **random-walk-speed** The distance traveled (in cm) each second, in a random direction, by a female frog that does not currently have a male targeted. #### Male frog parameters * **num-males** The number of male frogs created when the model is initialized. * **male-territory-radius** Radius of circular territory occupied by each male. No male's territory is allowed by the model to overlap with another male's territory, nor is any male's territory allowed to extend beyond the edges of the swamp. * **male-distribution** The distribution of male frogs on initialization. (Placement is always subject to the territorial radius constraint, as described above: any trial placement which violates the non-overlapping rule results in a resampling/re-placement of the male frog.) * _uniform-random_ Male frogs are placed by sampling from a 2-dimensional continuous uniform probability distribution. * _gaussian_ Male frogs are placed by sampling from a 2-dimensional Gaussian distribution, with the expected value located at the center of the swamp. This produces a higher concentration of males in the center of the swamp. * _inverse-gaussian_ Male frogs are placed by sampling from a 2-dimensional Gaussian distribution, where the 4 quadrants of the distribution are translated to the 4 corners of the swamp, resulting in a higher concentration of males in the corners and along the edges. * **mean-pulse-number** Mean of the Gaussian distribution from which male pulse numbers are sampled. * **stdev-pulse-number** Standard deviation of the Gaussian distribution from which male pulse numbers are sampled. * **mating-radius** Distance between the centers of male and female frog agents within which mating occurs. (In general, this should be set to the distance between centers at which 2 frog bodies would be in contact.) ### General simulation controls * **max-run-length** Maximum length (in simulated seconds) of a simulation run. Note that a simulation may end before this time has elapsed, if no more mating is possible—if all males and/or all females have mated. Also, note that this value can be changed while a simulation is in progress, and it will take effect immediately. * **Setup** Initialize the simulation model, using the parameter values set in the selectors and sliders described in **Setup parameters** (above). Note that changing those controls has no effect on the simulation until the *Setup* button is pressed. When not running in NetLogo Web, pressing **Setup** also gives the user the option to import global and agent variable values from a file; any values so imported will override values specified in the user interface. (See **File format for importing global and agent variable values**, below, for more information on this feature.) ![Import](images/import.png) If the "No" option is selected, no data will be imported in the current run. If the "Skip for this session" option is selected, this prompt will not be displayed for any subsequent runs, until the model is closed and re-opened. * **Go** Run a simulation using the initialized model. ## Things to notice when using the model ### General display When the model is initialized, and as it is running, unmated male frogs are colored yellow, unmated female frogs are green, and mated pairs are colored red. In the plots listed below, the same colors (yellow, green, and red) are used for the respective groups (unmated males, unmated females, and mated frogs). ### Monitors and plots The following are updated continuously as the model runs. * **Mated Pairs** (monitor) Displays the number of male/female pairs that have mated so far in the current run. * **Time to Mate** (plot and monitor) Displays a histogram and average of elapsed simulated time (in minutes) between the model start and the time of mating, for all mated pairs. * **Pulse Numbers** (plot and monitors) Displays 2 (overlayed) histograms, along with average values, of pulse numbers for all males (plotted in yellow) and mated males (in red). * **Distance Traveled** (plot and monitors) Displays 2 (overlayed) histograms, along with average values, of total distance traveled (in cm) for all females (plotted in green) and mated females (in red). * **Mates Targeted** (plot and monitors) Displays 2 (overlayed) histograms, along with average values, of males targeted by all females (plotted in green) and mated females (in red). Note that in the _best-of-n_ mating strategy, a female may end up targeting the same male more than once. These will be counted as separately targeted males in the plotted histograms and computed averages. ## Things to try 1. Systematic changes in the number of males and females on setup can dramatically change the sex ratio. Explore cases where males are rare versus those where females are rare. How does this influence the quality of mates that frogs find? 2. The choice of N (for the _best-of-n_ strategy) or the threshold (for the _minimum-threshold_ strategy) can create populations of females with very high standards. Does this always result in females acquiring the “best” mates? How do these choices interact with the mean quality of the available males? 3. One might hypothesize that a larger territory would be better for males. Change the territory radius and observe the final mate quality. Do larger or smaller territory sizes maximize the average pulse number of mated males? Does this depend on male and female densities or the sex ratio? 4. Female frogs provide tasty morsels for many predators. The smaller the distance females travel, the less time they spend exposed to predators. What combinations of conditions minimize distance traveled by females? ## File format for importing global and agent variable values In order to import global and agent variable values, the source file must contain the variable names and values in a specific format. The format is basically a "multi-section CSV" format: there are multiple comma-separated CSV sections, and each section is preceded by a section identifier, indicating whether the subsequent lines should be applied to global variables, female agent variables, or male agent variables. One or more sections may be omitted from the file; no overriding of the values set in the UI for such sections will be performed. When imported values override values set in **Interface** controls, the values indicated by those controls will be changed to match the overriding values. Note that the section names are case-sensitive, and must be enclosed in square brackets. #### `[globals]` If present, this section should include 2 lines of CSV data. The first line contains 1 or more global variable names, separated by commas. (Each variable name may optionally be enclosed in quotes.) The second line contains the values for the variables specified in the first line, in the same order; again, these values must be separated by commas, and string values may be enclosed in quotes. The following variable names are recognized in this section. (For those variables corresponding to controls by the same names in **Interface**, details may be found in the descriptions of those controls, above.) * `seed` Random number generator seed value. (The default seed is generated automatically from the system clock.) * `max-run-length` * `num-females` * `female-strategy` * `best-of-n` * `min-threshold` * `phonotaxis-speed` * `random-walk-speed` * `num-males` * `male-territory-radius` * `male-distribution` * `gaussian-sigma-x` Standard deviation of Gaussian distribution used to generate the male frogs' _X_ positions when **male-distribution** is set to "gaussian" or "inverse-gaussian". * `gaussian-sigma-y` Standard deviation of Gaussian distribution used for generating the male frogs' _Y_ position when **male-distribution** is set to "gaussian" or "inverse-gaussian". * `mean-pulse-number` * `stdev-pulse-number` * `round-pulse-numbers?` * `round-to-half?` If the value of `round-pulse-numbers?` (which is `false` by default) is overridden with a value of `true`, randomly generated male frog agent pulse numbers will be rounded. If `round-to-half?` is `false` (the default value), rounding will be to the nearest integer; otherwise, rounding is to the nearest value of the form _k_ + 0.5, where _k_ is an integer. * `mating-radius` #### `[females]` This section should contain 2 or more lines of CSV data. The first line contains 1 or more female agent variable names, optionally enclosed in quotes and separated by commas. Subsequent lines specify values corresponding to the names in the first line; these values override agent-specific variable values, 1 line per agent. If there are fewer value lines than female frog agents, some of the agents will keep the values originally assigned; if there are more value lines than female frog agents, excess value lines are ignored. The following variable names are recognized in this section. Note that most of these are taken from population-wide **Interface** controls (with slightly different names); overriding these can be used to configure the agents with heterogeneous, rather than homogenous, values for these variables. * `xcor` Starting _X_ position of agent, in the interval [-0.5 24.5), overriding the randomly generated value. * `ycor` Starting _Y_ position of agent, in the interval [-0.5 9.5), overriding the randomly generated value. * `strategy` Overrides the value assigned from the **female-strategy** selector. * `strategy-parameter` Overrides the value assigned from either the **best-of-n** slider or the **min-threshold** slider, depending on the value of **female-strategy**. If the latter is overridden, whether globally or individually (by specifying a value for `strategy`), this variable should be assigned a value as well. * `speed-phonotaxis` Overrides the value assigned from the **phonotaxis-speed** slider. * `speed-random` Overrides the value assigned from the **random-walk-speed** slider. #### `[males]` This section should contain 2 or more lines of CSV data. The first line contains 1 or more male agent variable names, optionally enclosed in quotes and separated by commas. Subsequent lines specify values corresponding to the names in the first line; these values override agent-specific variable values, 1 line per agent. If there are fewer value lines than male frog agents, some of the agents will keep the values originally assigned; if there are more value lines than male frog agents, excess value lines are ignored. The following variable names are recognized in this section. Note that some of these are taken from population-wide **Interface** controls (with slightly different names); overriding these can be used to configure the agents with heterogeneous, rather than homogenous, values for these variables. * `xcor` Starting _X_ position of the agent, in the interval [-0.5 24.5), overriding the randomly generated value. * `ycor` Starting _Y_ position of the agent, in the interval [-0.5 9.5), overriding the randomly generated value. * `pulse-number` Overrides the value assigned randomly based on the **mean-pulse-number** and **stdev-pulse-number** controls. * `territory-radius` Radius of the agent's territory in meters. Unless overridden, this is taken as the value of the **male-territory-radius** slider, divided by 100.[1] * `mate-proximity` Distance in meters within which the male frog agent can mate with an available female frog agent. Unless overridden, this is taken as the value of the **mating-radius** slider, divided by 100.[1] 1. The units of distance employed in the UI are centimeters (cm); however, in the model code—and in the import files—distances are expressed in meters (m). #### Comments To include comments in an import file, simply place them before any section marker, or after a section marker that doesn't match one of the 3 listed above (`[globals]`, `[females]`, `[males]`). #### Data import example Assume we have a file named `sample-import.csv`, with these contents: ```ini [globals] seed,num-females,num-males,female-strategy,best-of-n,mean-pulse-number 13,14,20,best-of-n,5,15 [females] xcor,ycor 2,-0.5 7,-0.5 12,-0.5 17,-0.5 22,-0.5 2,9.499999 7,9.499999 12,9.499999 17,9.499999 22,9.499999 -0.5,2 -0.5,7 24.499999,2 24.499999,7 [males] pulse-number 10 11 12 13 14 15 16 17 18 19 20 ``` After pressing **Setup** and importing `sample-import.csv`, we have this result: Results of importing sample-import.csv Note that the **num-females**, **num-males**, **female-strategy**, **best-of-n**, and **mean-pulse-number** controls in the **Interface** match the corresponding values in the `[globals]` section of `sample-import.csv`. Also, the female frogs are distributed at regular intervals around the edge of the swamp (with no apparent randomness), as specified in the `[females]` section. Finally, if we inspect the male frogs, we'll see that 11 of them have `pulse-number` values matching those in the `[males]` section, while the other 9 have randomly generated values. ## Running the model with BehaviorSpace Currently, the model has a number of BehaviorSpace experiments pre-configured for use. These perform repeated trials across ranges of input parameter values, capturing the output to comma-separated values (CSV) files. To view, edit, or run these experiments, select the **Tools/BehaviorSpace** menu command; a selection list of defined experiments will be displayed: ![BehaviorSpace](images/behaviorspace.png) For information on creating and editing BehaviorSpace experiments, see [BehaviorSpace Guide](https://ccl.northwestern.edu/netlogo/docs/behaviorspace.html). When an experiment is selected and the **Run** button pressed, the **Run options** window is displayed. ![Run options](images/run-options.png) It is recommended to select the **Table output** checkbox option, but not the **Spreadsheet output** checkbox, and to leave the **Simultaneous runs in parallel** field set to the default value (which is taken from the detected number of processing cores on the computer). After clicking the **OK** button in the **Run options** window, you'll be given a chance to select an output location and file name. (The default output file name is composed of the model name, experiment name, and output layout option.) After clicking **Save**, the BehaviorSpace experiment starts to run. While it's running, a status window is displayed: ![Running](images/running.png) In most cases, it's a good idea to un-check the **Update view** and **Update plots and monitors** checkboxes; otherwise, the BehaviorSpace trials will be slowed down as their progress is animated in the NetLogo view. ## Running the model on NetLogo Web As currently implemented, some features described above—including BehaviorSpace, extensions, and file I/O (used by the data import feature)—are not supported in NetLogo Web. As of May 11, 2022, a NetLogo Web version of this model can be accessed [here](https://netlogoweb.org/web?https://nick-bennett.github.io/mate-choice-model/netlogo/tree-frog-mate-choice-web.nlogo). In general, in order to run in NetLogo Web, 1 line in the **Code** page of the full version of the model must be commented out, to prevent NetLogo Web from failing when attempting to load the extensions used by the data import feature. (It's always a good idea to save a working NetLogo model file under a new name, before making any changes to the **Code** or **Interface** pages.) To prepare the model for use in NetLogo Web, change the first few lines of the **Code** page, from ``` ;; Comment out the __includes line for NetLogo Web use. __includes ["includes/behaviorspace-stats.nls" "includes/parameter-import.nls"] ``` to ``` ;; Comment out the __includes line for NetLogo Web use. ; __includes ["includes/behaviorspace-stats.nls" "includes/parameter-import.nls"] ``` (Note the addition of a semicolon to the line that starts with `__includes`. This change turns the line into a comment, which NetLogo Web will not execute.) For more information on using NetLogo Web, see the [NetLogo Web site](https://netlogoweb.org/). ## Modifying and extending the model * Arguably, some of the more useful modifications to the model would include reducing the controls available in the **Interface** page, to simplify the user experience for those not expert in behavioral ecology. To that end, a number of comments are included in the `globals` section and the `setup-globals` procedure (both in the **Code** page), with basic instructions on the changes needed to allow removal of one or more of the controls in the **Interface** page. Please see those comments for more information. * It would also be straightforward to extend the model in several other ways. * Currently, the threshold is the same (according to input) for all females within a single simulation population. In the field, it is likely that individual females vary in their choosiness. One can extend the model by generating threshold values (for the _min-threshold_ strategy) according to a probability distribution. This extension could be implemented by adding the necessary controls (or global variables) to set the parameters for a distribution of threshold values, and then referencing those parameters in the `setup-females` procedure, prior to the invocation of `override`. * The current model includes “perfect” perception by females of male signals and a direct approach of females toward males. The real world includes errors in perception and execution by females. Models that incorporate such uncertainty would be valuable. One can thus extend the model by limiting the sensing and/or targeting accuracy of female frogs. Extensions to the sensing, target selection, or movement logic—such as adding "fuzziness", "wiggling", or other types of less-than-perfect perception or movement—would generally require multiple changes to the UI and the code. First, additional controls or global variables would probably be needed, to parameterize the level of uncertainty; new agent variables might also be required (in the `females-own` block) to store agent-specific parameters. These added variables would then be referenced by modified code in the `best-of-n-pool`, `min-threshold-pool`, and `uniform-random-pool`, sensing procedures; the `select-best-of-n`, `select-min-threshold`, and `select-uniform-random` target selection procedures; and/or the `move-to-mate` procedure. ## Credits and references 1. The original model was developed in the SimWorld environment by Matthias Scheutz (Tufts University) and colleagues. Scheutz M, Harris J. An overview of the SimWorld agent-based grid experimentation system. In: Werner DF, Kurowski K, Schott B, editors. Large-Scale Computing Techniques for Complex System Simulations: Wiley; 2011. https://onlinelibrary.wiley.com/doi/10.1002/9781118130506.ch4 ) 2. The model and initial research findings are described in: Ferreira GBS, Scheutz M, and Boyd SK (2018) Mate choice strategies in a spatially-explicit model environment. PLoS ONE 13(8): e0202680. https://doi.org/10.1371/journal.pone.0202680 . 3. Datasets from the original model implementation are available at Dryad: doi:10.5061/dryad.2350931 and the University of Notre Dame repository: doi:10.7274/R08S4N0S. 4. This model was implemented in NetLogo by Nicholas Bennett & Sunny Boyd. 5. If you use or refer to this model in a publication, we ask that you cite the model itself, the source publication and the NetLogo software: For the model itself: * Boyd, S. and Bennett, N. (2018). NetLogo Treefrog Mating Model. (INSERT URL HERE). Department of Biological Sciences, University of Notre Dame, Notre Dame, IN. CNM Ingenuity, Central New Mexico Community College, Albuquerque, NM. For the source publication: * Ferreira GBS, Scheutz M, and Boyd SK (2018) Mate choice strategies in a spatially-explicit model environment. PLoS ONE 13(8): e0202680. Please cite the NetLogo software as: * Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. 6. Copyright 2018 Nicholas Bennett, Sunny Boyd, and the University of Notre Dame 7. This work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/). [![CC BY-NC-SA 4.0](https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png)](https://creativecommons.org/licenses/by-nc-sa/4.0/) 8. We gratefully acknowledge the support of the National Science Foundation (IOS # 0725187, 1257777, 1257815). * v1.0.0, 2018-02-22, Nicholas Bennett: * Initial project delivery. * Validation checks. * v1.0.1, 2018-02-25, Nicholas Bennett: * Data importing. * Expanded **Info** content. * Use of include files. * Creation of separate NetLogo Web version. * v1.0.2, 2022-05-10, Sunny Boyd: * Updated credits and license information. * v1.0.3, 2022-05-11, Nicholas Bennett: * Successive `if` statements replaced by multi-branch `if-else` statement (aka `if-else` ladder) in `setup-females` procedure. * Clarification of some instructions in **Info** tab. * CC BY-NC-SA image link in **Info** tab fixed. * Credits & licenses in **Code** tab reformatted for readability. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 female gray tree frog true 0 Polygon -7500403 true true 146 18 135 30 119 42 105 90 90 150 105 195 135 225 165 225 195 195 210 150 195 90 180 41 165 30 155 18 Polygon -7500403 true true 91 176 67 148 70 121 66 119 61 133 59 111 53 111 52 131 47 115 42 120 46 146 55 187 80 237 106 269 116 268 114 214 135 225 Polygon -7500403 true true 185 62 234 84 223 51 226 48 234 61 235 38 240 38 243 60 252 46 255 49 244 95 188 92 Polygon -7500403 true true 115 62 66 84 77 51 74 48 66 61 65 38 60 38 57 60 48 46 45 49 56 95 112 92 Polygon -7500403 true true 200 186 233 148 230 121 234 119 239 133 241 111 247 111 248 131 253 115 258 120 254 146 245 187 220 237 194 269 184 268 186 214 165 225 Circle -16777216 true false 157 38 18 Circle -16777216 true false 125 38 18 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 frog top true 0 Polygon -7500403 true true 146 18 135 30 119 42 105 90 90 150 105 195 135 225 165 225 195 195 210 150 195 90 180 41 165 30 155 18 Polygon -7500403 true true 91 176 67 148 70 121 66 119 61 133 59 111 53 111 52 131 47 115 42 120 46 146 55 187 80 237 106 269 116 268 114 214 131 222 Polygon -7500403 true true 185 62 234 84 223 51 226 48 234 61 235 38 240 38 243 60 252 46 255 49 244 95 188 92 Polygon -7500403 true true 115 62 66 84 77 51 74 48 66 61 65 38 60 38 57 60 48 46 45 49 56 95 112 92 Polygon -7500403 true true 200 186 233 148 230 121 234 119 239 133 241 111 247 111 248 131 253 115 258 120 254 146 245 187 220 237 194 269 184 268 186 214 169 222 Circle -16777216 true false 157 38 18 Circle -16777216 true false 125 38 18 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 male gray tree frog true 0 Polygon -7500403 true true 146 18 135 30 119 42 105 90 90 150 105 195 135 225 165 225 195 195 210 150 195 90 180 41 165 30 155 18 Polygon -7500403 true true 91 176 67 148 70 121 66 119 61 133 59 111 53 111 52 131 47 115 42 120 46 146 55 187 80 237 106 269 116 268 114 214 135 225 Polygon -7500403 true true 185 62 234 84 223 51 226 48 234 61 235 38 240 38 243 60 252 46 255 49 244 95 188 92 Polygon -7500403 true true 115 62 66 84 77 51 74 48 66 61 65 38 60 38 57 60 48 46 45 49 56 95 112 92 Polygon -7500403 true true 200 186 233 148 230 121 234 119 239 133 241 111 247 111 248 131 253 115 258 120 254 146 245 187 220 237 194 269 184 268 186 214 165 225 Circle -16777216 true false 157 38 18 Circle -16777216 true false 125 38 18 Polygon -1184463 true false 185 269 185 269 185 209 210 225 195 255 185 269 Polygon -1184463 true false 115 269 115 269 115 209 90 225 105 255 115 269 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 15 Circle -1 true true 203 65 88 Circle -1 true true 70 65 162 Circle -1 true true 150 105 120 Polygon -7500403 true false 218 120 240 165 255 165 278 120 Circle -7500403 true false 214 72 67 Rectangle -1 true true 164 223 179 298 Polygon -1 true true 45 285 30 285 30 240 15 195 45 210 Circle -1 true true 3 83 150 Rectangle -1 true true 65 221 80 296 Polygon -1 true true 195 285 210 285 210 240 240 210 195 210 Polygon -7500403 true false 276 85 285 105 302 99 294 83 Polygon -7500403 true false 219 85 210 105 193 99 201 83 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 wolf false 0 Polygon -16777216 true false 253 133 245 131 245 133 Polygon -7500403 true true 2 194 13 197 30 191 38 193 38 205 20 226 20 257 27 265 38 266 40 260 31 253 31 230 60 206 68 198 75 209 66 228 65 243 82 261 84 268 100 267 103 261 77 239 79 231 100 207 98 196 119 201 143 202 160 195 166 210 172 213 173 238 167 251 160 248 154 265 169 264 178 247 186 240 198 260 200 271 217 271 219 262 207 258 195 230 192 198 210 184 227 164 242 144 259 145 284 151 277 141 293 140 299 134 297 127 273 119 270 105 Polygon -7500403 true true -1 195 14 180 36 166 40 153 53 140 82 131 134 133 159 126 188 115 227 108 236 102 238 98 268 86 269 92 281 87 269 103 269 113 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 6.2.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ setup go mated-pairs avg-time-to-mate sum-time-to-mate sum-squared-time-to-mate avg-pulse-number false ; (All males.) sum-pulse-number false ; (All males.) sum-squared-pulse-number false ; (All males.) avg-pulse-number true ; (Mated males only.) sum-pulse-number true ; (Mated males only.) sum-squared-pulse-number true ; (Mated males only.) avg-distance-traveled false ; (All females.) sum-distance-traveled false ; (All females.) sum-squared-distance-traveled false ; (All females.) avg-distance-traveled true ; (Mated females only.) sum-distance-traveled true ; (Mated females only.) sum-squared-distance-traveled true ; (Mated females only.) avg-mates-selected false false ; (All females, without re-targeted males removed.) sum-mates-selected false false ; (All females, without re-targeted males removed.) sum-squared-mates-selected false false ; (All females, without re-targeted males removed.) avg-mates-selected false true ; (All females, with re-targeted males removed.) sum-mates-selected false true ; (All females, with re-targeted males removed.) sum-squared-mates-selected false true ; (All females, with re-targeted males removed.) avg-mates-selected true false ; (Mated females only, without re-targeted males removed.) sum-mates-selected true false ; (Mated females only, without re-targeted males removed.) sum-squared-mates-selected true false ; (Mated females only, without re-targeted males removed.) avg-mates-selected true true ; (Mated females only, with re-targeted males removed.) sum-mates-selected true true ; (Mated females only, with re-targeted males removed.) sum-squared-mates-selected true true ; (Mated females only, with re-targeted males removed.) setup go mated-pairs avg-time-to-mate sum-time-to-mate sum-squared-time-to-mate avg-pulse-number false ; (All males.) sum-pulse-number false ; (All males.) sum-squared-pulse-number false ; (All males.) avg-pulse-number true ; (Mated males only.) sum-pulse-number true ; (Mated males only.) sum-squared-pulse-number true ; (Mated males only.) avg-distance-traveled false ; (All females.) sum-distance-traveled false ; (All females.) sum-squared-distance-traveled false ; (All females.) avg-distance-traveled true ; (Mated females only.) sum-distance-traveled true ; (Mated females only.) sum-squared-distance-traveled true ; (Mated females only.) avg-mates-selected false false ; (All females, without re-targeted males removed.) sum-mates-selected false false ; (All females, without re-targeted males removed.) sum-squared-mates-selected false false ; (All females, without re-targeted males removed.) avg-mates-selected false true ; (All females, with re-targeted males removed.) sum-mates-selected false true ; (All females, with re-targeted males removed.) sum-squared-mates-selected false true ; (All females, with re-targeted males removed.) avg-mates-selected true false ; (Mated females only, without re-targeted males removed.) sum-mates-selected true false ; (Mated females only, without re-targeted males removed.) sum-squared-mates-selected true false ; (Mated females only, without re-targeted males removed.) avg-mates-selected true true ; (Mated females only, with re-targeted males removed.) sum-mates-selected true true ; (Mated females only, with re-targeted males removed.) sum-squared-mates-selected true true ; (Mated females only, with re-targeted males removed.) setup go mated-pairs avg-time-to-mate sum-time-to-mate sum-squared-time-to-mate avg-pulse-number false ; (All males.) sum-pulse-number false ; (All males.) sum-squared-pulse-number false ; (All males.) avg-pulse-number true ; (Mated males only.) sum-pulse-number true ; (Mated males only.) sum-squared-pulse-number true ; (Mated males only.) avg-distance-traveled false ; (All females.) sum-distance-traveled false ; (All females.) sum-squared-distance-traveled false ; (All females.) avg-distance-traveled true ; (Mated females only.) sum-distance-traveled true ; (Mated females only.) sum-squared-distance-traveled true ; (Mated females only.) avg-mates-selected false false ; (All females, without re-targeted males removed.) sum-mates-selected false false ; (All females, without re-targeted males removed.) sum-squared-mates-selected false false ; (All females, without re-targeted males removed.) avg-mates-selected false true ; (All females, with re-targeted males removed.) sum-mates-selected false true ; (All females, with re-targeted males removed.) sum-squared-mates-selected false true ; (All females, with re-targeted males removed.) avg-mates-selected true false ; (Mated females only, without re-targeted males removed.) sum-mates-selected true false ; (Mated females only, without re-targeted males removed.) sum-squared-mates-selected true false ; (Mated females only, without re-targeted males removed.) avg-mates-selected true true ; (Mated females only, with re-targeted males removed.) sum-mates-selected true true ; (Mated females only, with re-targeted males removed.) sum-squared-mates-selected true true ; (Mated females only, with re-targeted males removed.) @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 1 @#$#@#$#@