breed [males male] breed [females female] globals [ ; The following are all controled by sliders/switches on the interface tab: ; carrying-capacity ; The number of individuals in the population ; mutant-proportion ; The proportion of individuals that carry one new mutation in their genome, every generation ; genome-length ; The number of loci in each chromosome ; preference-strength ; The factor determining the addition of each preference mutation to the strength of the preference (i.e the slope of the probability to mate function) ; recombination ; Determines whether or not the genome goes through recombination ; selection-coefficient ; Determines selection force against the AB genotype. Equals the proportion of individuals with an AB genotype that die during selection. ; max-matching-attempts ; The maximum number of females that a male can refuse to mate with before he is taken out of the mating pool. ;This variable is included to prevent the simulations from getting stuck because none of the females are suitable for a single male. genotyped-AA ; An agentset that holds all turtles with an AA genotype genotyped-AB ; An agentset that holds all turtles with an AB genotype genotyped-BB ; An agentset that holds all turtles with a BB genotype ; Creating agent sets comprised of all turtles that have at least one nuetral / preference locus in their genome, separately for each genotype and locus type (Pa-preference for AA; Pb-preference for BB): AA-turtles-with-Pa-loci AA-turtles-with-Pb-loci AA-turtles-with-nuetral-loci BB-turtles-with-Pa-loci BB-turtles-with-Pb-loci BB-turtles-with-nuetral-loci AB-turtles-with-Pa-loci AB-turtles-with-Pb-loci AB-turtles-with-nuetral-loci ; For analysing the simulation results: how-many-AA-mated-with-AA ; Holds a new value every generation how-many-BB-mated-with-BB ; -"- how-many-mating-pairs ; -"- proportion-unmated-males; -"- ] patches-own [] turtles-own [ homolog1 homolog2 mating-status ; Can be one of: 'unmated', 'mated' or 'no mate found' genotype ; Determined based on the letters at the first locus of homolog1 and homolog2 (either: AA, AB or BB) mating-preference ; Determined by the sum of Pa and Pb mutations in the genome. ; Pa mutations (preference for AA genotype) are summed positively and Pb mutations (preference for BB genotype) are summed negatively ; For example, if an individual has 1 Pa and 1 Pb in his genome, they cancel each other out and his mating preference will equal zero (no mating preference) prob-AA ; The probability to mate with an AA genotyped individual. Calculated from the values of mating-preference and preference strength. prob-BB ; The probability to mate with a BB genotyped individual. -"- Pa-count ; Counts the number of Pa mutations in the entire genome (both chromosomes) Pb-count ; Counts the number of Pb mutations in the entire genome (both chromosomes) nuetral-count ; Counts the number of nuetral mutations in the entire genome (both chromosomes) Pa-average-distance ; holds the average distance of all preference for AA loci from the trait locus in both chromosomes Pb-average-distance ; holds the average distance of all preference for BB loci from the trait locus in both chromosomes nuetral-average-distance ; holds the average distance of all nuetral loci from the trait locus in both chromosomes ; subpopulation ; Removed. Used only for the non-spatial model version. Can be either: '1' or '2'. Divides the individuals into two subpopulations. Selection favors A alleles in subpopulation '1' and B alleles in subpopulation '2'. ] to setup ca set how-many-AA-mated-with-AA [] set how-many-BB-mated-with-BB [] set how-many-mating-pairs [] set proportion-unmated-males [] ask patches [if pxcor > (max-pxcor - 1) / 2 [set pcolor white]] ; Splits the arena into two separate habitats. Selection gives an advantage to the AA genotype in the white habitat and to the BB genotype in the black habitat create-turtles carrying-capacity [setxy random-xcor random-ycor set size 1.5 set mating-status "unmated" ; Setting each of the two homologous chromosomes so that the first gene, controling the trait, will be randomly assigned one of the triat alleles (A or B): set homolog1 n-values genome-length ["-"] set homolog1 replace-item 0 homolog1 (one-of (list "A" "B")) set homolog2 n-values genome-length ["-"] set homolog2 replace-item 0 homolog2 (one-of (list "A" "B")) set genotype word (item 0 homolog1) (item 0 homolog2) if genotype = "BA" [set genotype "AB"] ; Unifies all heterozygotes under the genotype AB ; Homozygotes for A will be blue, homozygotes for B will be yellow, and heterozygotes will be green (intermediate between blue and yellow): if genotype = "AA" [set color blue] if genotype = "AB" [set color green] if genotype = "BB" [set color yellow] ] set genotyped-AA turtles with [genotype = "AA"] set genotyped-AB turtles with [genotype = "AB"] set genotyped-BB turtles with [genotype = "BB"] ; output-print word "number of A alleles on homolog1: " count turtles with [(item 0 homolog1) = "A"] ; output-print word "number of B alleles on homolog1: " count turtles with [(item 0 homolog1) = "B"] ; output-print word "number of A alleles on homolog2: " count turtles with [(item 0 homolog2) = "A"] ; output-print word "number of B alleles on homolog2: " count turtles with [(item 0 homolog2) = "B"] ;Initializing the population to be half males half females: ask n-of (carrying-capacity / 2) turtles [set breed males] ask turtles with [breed != males] [set breed females] ; Adding mutations that are either random ("0") or that control mating preferences (Pa, preference for A or Pb, preference for B): ; The mutations occur in random individuals, at random places throughout the genome, at a rate derived from the 'mutant-proportion' variable (see 'globals') ; A mutation can occur in all loci except the first locus, that controls the trait ask n-of (carrying-capacity * mutant-proportion) turtles [let mutation-place ((random (genome-length - 1)) + 1) ; randomly choosing a locus within the chromosome, excluding the first locus, that controls the trait. ; ('genome-length' - 1) reduces the number of places from which to choose by one, and then +1 shifts the places to exclude zero but include the last place in the list. ; randomly choosing one of the two chromosomes to add the mutation to: ifelse (random 2) = 0 ; randomly chooses 0 or 1, then if equals 0 adds the mutation to homolog1 and if equals 1 adds it to homolog2 [set homolog1 replace-item mutation-place homolog1 (one-of (list "0" "Pa" "Pb")) ; output-print (word "ind. " who ", homolog 1: " homolog1) ] [set homolog2 replace-item mutation-place homolog2 (one-of (list "0" "Pa" "Pb")) ; output-print (word "ind. " who ", homolog 2: " homolog2) ] ] ; output-print word "number of females: " count females ; output-print word "number of males: " count males ask turtles [ set nuetral-count (length (filter [i -> i = "0"] homolog1) + length (filter [i -> i = "0"] homolog2)) set Pa-count (length (filter [i -> i = "Pa"] homolog1) + length (filter [i -> i = "Pa"] homolog2)) set Pb-count (length (filter [i -> i = "Pb"] homolog1) + length (filter [i -> i = "Pb"] homolog2)) set mating-preference (Pa-count - Pb-count) set prob-AA (1 / (1 + e ^ (- preference-strength * mating-preference))) ; Calculate the Probability to mate with an AA genotype female set prob-BB (1 - prob-AA) ; Calculate the Probability to mate with a BB genotype female ; Creating a list that holds the distances of all nuetral mutations from the trait locus in both chromosomes, and then calculating the average for the list: let nuetral-distances (list) ifelse nuetral-count > 0 [let locus 0 foreach homolog1 [i -> ifelse i = "0" [ifelse empty? nuetral-distances [set nuetral-distances (list locus)] [set nuetral-distances fput locus nuetral-distances] set locus locus + 1 ] [set locus locus + 1] ] set locus 0 foreach homolog2 [i -> ifelse i = "0" [ifelse empty? nuetral-distances [set nuetral-distances (list locus)] [set nuetral-distances fput locus nuetral-distances] set locus locus + 1 ] [set locus locus + 1] ] set nuetral-average-distance mean nuetral-distances ] [set nuetral-average-distance []] ; Creating a list that holds the distances of all preference for AA loci from the trait locus in both chromosomes, and then calculating the average for the list: let Pa-distances (list) ifelse Pa-count > 0 [let locus 0 foreach homolog1 [i -> ifelse i = "Pa" [ifelse empty? Pa-distances [set Pa-distances (list locus)] [set Pa-distances fput locus Pa-distances] set locus locus + 1 ] [set locus locus + 1] ] set locus 0 foreach homolog2 [i -> ifelse i = "Pa" [ifelse empty? Pa-distances [set Pa-distances (list locus)] [set Pa-distances fput locus Pa-distances] set locus locus + 1 ] [set locus locus + 1] ] set Pa-average-distance mean Pa-distances ] [set Pa-average-distance []] ; Creating a list that holds the distances of all preference for BB loci from the trait locus in both chromosomes, and then calculating the average for the list: let Pb-distances (list) ifelse Pb-count > 0 [let locus 0 foreach homolog1 [i -> ifelse i = "Pb" [ifelse empty? Pb-distances [set Pb-distances (list locus)] [set Pb-distances fput locus Pb-distances] set locus locus + 1 ] [set locus locus + 1] ] set locus 0 foreach homolog2 [i -> ifelse i = "Pb" [ifelse empty? Pb-distances [set Pb-distances (list locus)] [set Pb-distances fput locus Pb-distances] set locus locus + 1 ] [set locus locus + 1] ] set Pb-average-distance mean Pb-distances ] [set Pb-average-distance []] ; output-print homolog1 ; output-print homolog2 ; output-print genotype ; output-print mating-preference ] set AA-turtles-with-Pa-loci genotyped-AA with [Pa-count > 0] set AA-turtles-with-Pb-loci genotyped-AA with [Pb-count > 0] set AA-turtles-with-nuetral-loci genotyped-AA with [nuetral-count > 0] set BB-turtles-with-Pa-loci genotyped-BB with [Pa-count > 0] set BB-turtles-with-Pb-loci genotyped-BB with [Pb-count > 0] set BB-turtles-with-nuetral-loci genotyped-BB with [nuetral-count > 0] set AB-turtles-with-Pa-loci genotyped-AB with [Pa-count > 0] set AB-turtles-with-Pb-loci genotyped-AB with [Pb-count > 0] set AB-turtles-with-nuetral-loci genotyped-AB with [nuetral-count > 0] reset-ticks end to go tick find-mate reproduce end-generation recombinate mutate select regulate-population-size ; Outputing the genomes of all individuals: ; if ticks = 250 ; or ticks = 800 ; [ ; output-print word "ticks: " ticks ; output-print word "average distance of Pa mutations to A: " mean [Pa-average-distance] of AA-turtles-with-Pa-loci ; output-print word "average distance of Pb mutations to B: " mean [Pb-average-distance] of BB-turtles-with-Pb-loci ; ask turtles ; [let place 0 ; while [place < 100] ; [ifelse place = 99 ; [output-print item place homolog1] ; [output-type word item place homolog1 ","] ; set place place + 1 ; ] ; set place 0 ; while [place < 100] ; [ifelse place = 99 ; [output-print item place homolog2] ; [output-type word item place homolog2 ","] ; set place place + 1 ; ] ; ] ; if ticks = 250 [stop] ; ] ; output-print "" ; to make a clear separation between generations in the output window end to find-mate ;;; THIS IS THE MOST TIME CONSUMING PROCEDURE ;;; ; reset-timer ; used to test which procedures are slowing the model down set how-many-mating-pairs 0 let unmated-males males with [mating-status = "unmated"] let unmated-females females with [mating-status = "unmated"] while [(count unmated-males > 0) and (count unmated-females > 0)] ; Continue matching males with females until either males or females have all found or attempted to find a mate [ask one-of unmated-males [let non-matches 0 while [mating-status = "unmated"] [let female-candidate one-of unmated-females set prob-AA (1 / (1 + e ^ (- preference-strength * mating-preference))) ; Calculate the Probability to mate with an AA genotype female set prob-BB (1 - prob-AA) ; Calculate the Probability to mate with a BB genotype female if [genotype] of female-candidate = "AA" [ ifelse random-float 1 < prob-AA [create-link-with female-candidate set mating-status "mated" set unmated-males unmated-males with [mating-status = "unmated"] ; quicker than filtering through the entire male angentset ask female-candidate [set mating-status "mated"] set unmated-females unmated-females with [mating-status = "unmated"] ; quicker than filtering through the entire female agentset set how-many-mating-pairs how-many-mating-pairs + 1 ; For testing: ; output-print (word "female genotype" ";" [genotype] of female-candidate ";" "mating preference" ";" mating-preference ";" "chosen") ] [set non-matches non-matches + 1 if non-matches = max-matching-attempts [set mating-status "no mate found"] ; After reaching the maximum number of matching attempts, the male is taken out of the mating pool, to prevent the simulation run from getting stuck set unmated-males unmated-males with [mating-status = "unmated"] ; For testing: ; output-print (word "female genotype" ";" [genotype] of female-candidate ";" "mating preference" ";" mating-preference ";" "rejected") ] ] if [genotype] of female-candidate = "BB" [ ifelse random-float 1 < prob-BB [create-link-with female-candidate set mating-status "mated" set unmated-males unmated-males with [mating-status = "unmated"] ask female-candidate [set mating-status "mated"] set unmated-females unmated-females with [mating-status = "unmated"] set how-many-mating-pairs how-many-mating-pairs + 1 ; For testing: ; output-print (word "female genotype" ";" [genotype] of female-candidate ";" "mating preference" ";" mating-preference ";" "chosen") ] [set non-matches non-matches + 1 if non-matches = max-matching-attempts [set mating-status "no mate found"] ; After reaching the maximum number of matching attempts, the male is taken out of the mating pool, to prevent the simulation run from getting stuck set unmated-males unmated-males with [mating-status = "unmated"] ; For testing: ; output-print (word "female genotype" ";" [genotype] of female-candidate ";" "mating preference" ";" mating-preference ";" "rejected") ] ] if [genotype] of female-candidate = "AB" [ ifelse random-float 1 < 0.5 [create-link-with female-candidate set mating-status "mated" set unmated-males unmated-males with [mating-status = "unmated"] ask female-candidate [set mating-status "mated"] set unmated-females unmated-females with [mating-status = "unmated"] set how-many-mating-pairs how-many-mating-pairs + 1 ; For testing: ; output-print (word "female genotype" ";" [genotype] of female-candidate ";" "mating preference" ";" mating-preference ";" "chosen") ] [set non-matches non-matches + 1 if non-matches = max-matching-attempts [set mating-status "no mate found"] ; After reaching the maximum number of matching attempts, the male is taken out of the mating pool, to prevent the simulation run from getting stuck set unmated-males unmated-males with [mating-status = "unmated"] ; For testing: ; output-print (word "female genotype" ";" [genotype] of female-candidate ";" "mating preference" ";" mating-preference ";" "rejected") ] ] ; output-print (word "no. of Pa mutations" ";" Pa-count ";" "no. of Pb mutations" ";" Pb-count ";" "mating preference" ";" mating-preference ";" "Prob-AA" ";" Prob-AA ";" "Prob-BB" ";" Prob-BB) ] ] ] ; output-print word "mated males: " count males with [mating-status = "mated"] ; output-print word "mated females: " count females with [mating-status = "mated"] ; output-print word "unmated males: " count males with [mating-status = "unmated"] ; output-print word "unmated females: " count females with [mating-status = "unmated"] ; output-print word "males without a match: " count males with [mating-status = "no mate found"] ask turtles [if mating-status = "unmated" [set mating-status "no mate found"]] ; To make sure the mating status of the entire generation is either "mated" or "no mate found" ; so that when the new generation is produced (and are all "unmated") they can be distinguished from the old generation ; For testing the proportion of non-mated males: set proportion-unmated-males (count males with [mating-status = "no mate found"]) / count males ; To test which procedures are slowing down the model: ; output-print word "find-mate procedure duration: " timer end to reproduce ; reset-timer ; used to test which procedures are slowing the model down set how-many-AA-mated-with-AA 0 ; For model result analysis set how-many-BB-mated-with-BB 0 ; -"- let mating-male [] let mating-female [] ask males with [mating-status = "mated"] [set mating-male self ask my-links [set mating-female other-end] ; setting the female partner to be the female at the other end of the link, i.e. the female the male chose to mate with during the 'find-mate' procedure ; For testing that the pairs are found successfully: ; let new-color random 140 ; set color new-color ; ask mating-female [set color new-color] ; For model result analysis: if [genotype] of mating-male = "AA" and [genotype] of mating-female = "AA" [set how-many-AA-mated-with-AA (how-many-AA-mated-with-AA + 1)] if [genotype] of mating-male = "BB" and [genotype] of mating-female = "BB" [set how-many-BB-mated-with-BB (how-many-BB-mated-with-BB + 1)] ; Each pair produces 4 offspring, two males and two females: hatch-males 2 [set homolog1 one-of list ([homolog1] of mating-male) ([homolog2] of mating-male) ; homolog1 will be from paternal origin (randomly chosen from the father's two homologous chromosomes) set homolog2 one-of list ([homolog1] of mating-female) ([homolog2] of mating-female) ; homolog2 will be from maternal origin (randomly chosen from the mother's two homologous chromosomes) set mating-status "unmated" ; set subpopulation one-of list "1" "2" ; setxy random-xcor random-ycor ; cancelled, to keep the offspring in the same habitat as the male set size 1.5 ; For testing that the offspring are produced properly: ; output-print word "male homolog1: " [homolog1] of mating-male ; output-print word "male homolog2: " [homolog2] of mating-male ; output-print word "female homolog1: " [homolog1] of mating-female ; output-print word "female homolog2: " [homolog2] of mating-female ; output-print word "offspring homolog1: " homolog1 ; output-print word "offspring homolog2: " homolog2 ; output-print word "offspring mating-preference: " mating-preference ; output-print " " ] hatch-females 2 [set homolog1 one-of list ([homolog1] of mating-male) ([homolog2] of mating-male) ; homolog1 will be from paternal origin (randomly chosen from the father's two homologous chromosomes) set homolog2 one-of list ([homolog1] of mating-female) ([homolog2] of mating-female) ; homolog2 will be from maternal origin (randomly chosen from the mother's two homologous chromosomes) set mating-status "unmated" ; set subpopulation one-of list "1" "2" ; setxy random-xcor random-ycor ; cancelled, to keep the offspring in the same habitat as the male set size 1.5 ] ] ; To test which procedures are slowing down the model: ; output-print word "reproduce procedure duration: " timer end to end-generation ; reset-timer ; used to test which procedures are slowing the model down ask turtles [if mating-status = "mated" or mating-status = "no mate found" [die]] ; Ends the previous generation, as only the offspring now have the status "unmated" ; To test which procedures are slowing down the model: ; output-print word "end-generation procedure duration: " timer end to recombinate ;;; THIS IS THE THIRD MOST TIME CONSUMING PROCEDURE ;;; ; reset-timer ; used to test which procedures are slowing the model down if recombination = true [ask turtles [let cross-over-point random genome-length let temp-list homolog2 ; sets the temporary list to be a copy of homolog2 ; For testing the recombination proccess: ; output-print word "initial homolog1: " homolog1 ; output-print word "initial homolog2: " homolog2 ; Transfer of first chromosome genes, beyond the cross-over point, to the temporary list for storage. ; The temporary list will then hold the future homolog2 sequence: let current-gene 0 foreach temp-list [ ifelse current-gene < cross-over-point [set current-gene current-gene + 1] [set temp-list replace-item current-gene temp-list (item current-gene homolog1) set current-gene current-gene + 1] ] ; Transfer of second chromosome genes, beyond the cross-over point, to the first chromosome: set current-gene 0 foreach homolog1 [ ifelse current-gene < cross-over-point [set current-gene current-gene + 1] [set homolog1 replace-item current-gene homolog1 (item current-gene homolog2) set current-gene current-gene + 1] ] ; Transfer of first chromosome genes, that are stored in the temporary list, to the second chromosome: set homolog2 temp-list ; For testing the recombination proccess: ; output-print word "cross-over point: " cross-over-point ; output-print word "final homolog1: " homolog1 ; output-print word "final homolog2: " homolog2 ; output-print " " ] ] set genotyped-AA turtles with [genotype = "AA"] set genotyped-AB turtles with [genotype = "AB"] set genotyped-BB turtles with [genotype = "BB"] ; To test which procedures are slowing down the model: ; output-print word "recombinate procedure duration: " timer end to mutate ; reset-timer ; used to test which procedures are slowing the model down ask n-of (count turtles * mutant-proportion) turtles [let mutation-place ((random (genome-length - 1)) + 1) ; randomly choosing a locus within the chromosome, excluding the first locus, that controls the trait. ; ('genome-length' - 1) reduces the number of places from which to choose by one, and then +1 shifts the places to exclude zero but include the last place in the list. ; output-print word "old homolog1: " homolog1 ; output-print word "old homolog2: " homolog2 ; randomly choosing one of the two chromosomes to add the mutation to: ifelse (random 2) = 0 ; randomly chooses 0 or 1, then if equals 0 adds the mutation to homolog1 and if equals 1 adds it to homolog2 [set homolog1 replace-item mutation-place homolog1 (one-of (list "0" "Pa" "Pb"))] [set homolog2 replace-item mutation-place homolog2 (one-of (list "0" "Pa" "Pb"))] ; output-print word "new homolog1: " homolog1 ; output-print word "new homolog2: " homolog2 ; output-print " " ] ask turtles [set genotype word (item 0 homolog1) (item 0 homolog2) if genotype = "BA" [set genotype "AB"] ; Unifies all heterozygotes under the genotype AB if genotype = "AA" [set color blue] if genotype = "AB" [set color green] if genotype = "BB" [set color yellow] set nuetral-count (length (filter [i -> i = "0"] homolog1) + length (filter [i -> i = "0"] homolog2)) set Pa-count (length (filter [i -> i = "Pa"] homolog1) + length (filter [i -> i = "Pa"] homolog2)) set Pb-count (length (filter [i -> i = "Pb"] homolog1) + length (filter [i -> i = "Pb"] homolog2)) set mating-preference (Pa-count - Pb-count) ; Creating a list that holds the distances of all nuetral mutations from the trait locus in both chromosomes, and then calculating the average for the list: let nuetral-distances (list) ifelse nuetral-count > 0 [let locus 0 foreach homolog1 [i -> ifelse i = "0" [ifelse empty? nuetral-distances [set nuetral-distances (list locus)] [set nuetral-distances fput locus nuetral-distances] set locus locus + 1 ] [set locus locus + 1] ] set locus 0 foreach homolog2 [i -> ifelse i = "0" [ifelse empty? nuetral-distances [set nuetral-distances (list locus)] [set nuetral-distances fput locus nuetral-distances] set locus locus + 1 ] [set locus locus + 1] ] set nuetral-average-distance mean nuetral-distances ] [set nuetral-average-distance []] ; Creating a list that holds the distances of all preference for AA loci from the trait locus in both chromosomes, and then calculating the average for the list: let Pa-distances (list) ifelse Pa-count > 0 [let locus 0 foreach homolog1 [i -> ifelse i = "Pa" [ifelse empty? Pa-distances [set Pa-distances (list locus)] [set Pa-distances fput locus Pa-distances] set locus locus + 1 ] [set locus locus + 1] ] set locus 0 foreach homolog2 [i -> ifelse i = "Pa" [ifelse empty? Pa-distances [set Pa-distances (list locus)] [set Pa-distances fput locus Pa-distances] set locus locus + 1 ] [set locus locus + 1] ] set Pa-average-distance mean Pa-distances ] [set Pa-average-distance []] ; Creating a list that holds the distances of all preference for BB loci from the trait locus in both chromosomes, and then calculating the average for the list: let Pb-distances (list) ifelse Pb-count > 0 [let locus 0 foreach homolog1 [i -> ifelse i = "Pb" [ifelse empty? Pb-distances [set Pb-distances (list locus)] [set Pb-distances fput locus Pb-distances] set locus locus + 1 ] [set locus locus + 1] ] set locus 0 foreach homolog2 [i -> ifelse i = "Pb" [ifelse empty? Pb-distances [set Pb-distances (list locus)] [set Pb-distances fput locus Pb-distances] set locus locus + 1 ] [set locus locus + 1] ] set Pb-average-distance mean Pb-distances ] [set Pb-average-distance []] ] set AA-turtles-with-Pa-loci genotyped-AA with [Pa-count > 0] set AA-turtles-with-Pb-loci genotyped-AA with [Pb-count > 0] set AA-turtles-with-nuetral-loci genotyped-AA with [nuetral-count > 0] set BB-turtles-with-Pa-loci genotyped-BB with [Pa-count > 0] set BB-turtles-with-Pb-loci genotyped-BB with [Pb-count > 0] set BB-turtles-with-nuetral-loci genotyped-BB with [nuetral-count > 0] set AB-turtles-with-Pa-loci genotyped-AB with [Pa-count > 0] set AB-turtles-with-Pb-loci genotyped-AB with [Pb-count > 0] set AB-turtles-with-nuetral-loci genotyped-AB with [nuetral-count > 0] ; To test which procedures are slowing down the model: ; output-print word "mutate procedure duration: " timer end to select ; reset-timer ; used to test which procedures are slowing the model down ; if ticks = 1 [output-print "pcolor;pre-AA;pre-AB;pre-BB;post-AA;post-AB;post-BB" ] ; output-type (word "black;" count turtles with [genotype = "AA" and pcolor = black] ";" count turtles with [genotype = "AB" and pcolor = black] ";" count turtles with [genotype = "BB" and pcolor = black] ";" ) ask n-of (selection-coefficient * count turtles with [genotype = "AA" and pcolor = black]) turtles with [genotype = "AA" and pcolor = black] [die] ask n-of (selection-coefficient * count turtles with [genotype = "AB" and pcolor = black]) turtles with [genotype = "AB" and pcolor = black] [die] ; output-print (word count turtles with [genotype = "AA" and pcolor = black] ";" count turtles with [genotype = "AB" and pcolor = black] ";" count turtles with [genotype = "BB" and pcolor = black] ) ; output-type (word "white;" count turtles with [genotype = "AA" and pcolor = white] ";" count turtles with [genotype = "AB" and pcolor = white] ";" count turtles with [genotype = "BB" and pcolor = white] ";" ) ask n-of (selection-coefficient * count turtles with [genotype = "BB" and pcolor = white]) turtles with [genotype = "BB" and pcolor = white] [die] ask n-of (selection-coefficient * count turtles with [genotype = "AB" and pcolor = white]) turtles with [genotype = "AB" and pcolor = white] [die] ; output-print (word count turtles with [genotype = "AA" and pcolor = white] ";" count turtles with [genotype = "AB" and pcolor = white] ";" count turtles with [genotype = "BB" and pcolor = white] ) ; To test which procedures are slowing down the model: ; output-print word "select procedure duration: " timer end to regulate-population-size ; Kills turtles in excess of the carrying capacity, in each of the two habitats seperately ; reset-timer ; used to test which procedures are slowing the model down let white-habitat-pop-size count turtles with [pcolor = white] if white-habitat-pop-size >= (carrying-capacity / 2) [let chance-to-die-white (white-habitat-pop-size - (carrying-capacity / 2)) / white-habitat-pop-size ask turtles with [pcolor = white] [if random-float 1 < chance-to-die-white [die] ] ] ; output-print word "white habitat pop size: " count turtles with [pcolor = white] let black-habitat-pop-size count turtles with [pcolor = black] if black-habitat-pop-size >= (carrying-capacity / 2) [let chance-to-die-black (black-habitat-pop-size - (carrying-capacity / 2)) / black-habitat-pop-size ask turtles with [pcolor = black] [if random-float 1 < chance-to-die-black [die] ] ] ; output-print word "black habitat pop size: " count turtles with [pcolor = black] ; To test which procedures are slowing down the model: ; output-print word "regulate-population-size procedure duration: " timer end @#$#@#$#@ GRAPHICS-WINDOW 33 15 457 440 -1 -1 13.0 1 10 1 1 1 0 1 1 1 0 31 0 31 1 1 1 ticks 30.0 BUTTON 1075 35 1138 68 NIL setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 1159 35 1222 69 NIL go T 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 1248 36 1311 69 step go NIL 1 T OBSERVER NIL NIL NIL NIL 1 SLIDER 1109 93 1281 126 carrying-capacity carrying-capacity 2 10000 10000.0 2 1 NIL HORIZONTAL SLIDER 1109 183 1281 216 genome-length genome-length 0 100 100.0 1 1 NIL HORIZONTAL SLIDER 1108 136 1280 169 mutant-proportion mutant-proportion 1 / carrying-capacity 1 0.01 1 / carrying-capacity 1 NIL HORIZONTAL SLIDER 1111 227 1283 260 preference-strength preference-strength 0 6 0.3 0.1 1 NIL HORIZONTAL SLIDER 1109 478 1290 511 max-matching-attempts max-matching-attempts 0 100 2.0 1 1 NIL HORIZONTAL SWITCH 1128 282 1261 315 recombination recombination 0 1 -1000 SLIDER 1112 324 1284 357 selection-coefficient selection-coefficient 0 1 0.5 0.1 1 NIL HORIZONTAL PLOT 490 526 750 676 Histogram - mating preference mating preference Number of individuals 0.0 10.0 0.0 70.0 true false "set-plot-x-range -20 20\nset-plot-y-range 0 70" "" PENS "default" 1.0 0 -13345367 true "" "histogram [mating-preference] of turtles with [genotype = \"AA\"]" "pen-1" 1.0 0 -1184463 true "" "histogram [mating-preference] of turtles with [genotype = \"BB\"]" PLOT 487 326 793 506 Mating Preference Number of Generations Average mating preference 0.0 3.0 0.0 1.0 true false "" "" PENS "default" 1.0 0 -13345367 true "" "plot mean [mating-preference] of turtles with [genotype = \"AA\"]" "pen-1" 1.0 0 -10899396 true "" "plot mean [mating-preference] of turtles with [genotype = \"AB\"]" "pen-2" 1.0 0 -1184463 true "" "plot mean [mating-preference] of turtles with [genotype = \"BB\"]" PLOT 506 11 706 161 Genotype abundance Number of generations Genotype abundance 0.0 10.0 0.0 10.0 true false "" "" PENS "default" 1.0 0 -13345367 true "" "plot count turtles with [genotype = \"AA\"]" "pen-1" 1.0 0 -10899396 true "" "plot count turtles with [genotype = \"AB\"]" "pen-2" 1.0 0 -1184463 true "" "plot count turtles with [genotype = \"BB\"]" PLOT 722 10 973 160 How many genotype-matching matings? Number of generations Number of inter-trait matings 0.0 10.0 10.0 20.0 true false "" "" PENS "AA mating with AA" 1.0 0 -13345367 true "" "plot how-many-AA-mated-with-AA" "BB mating with BB" 1.0 0 -1184463 true "" "plot how-many-BB-mated-with-BB" PLOT 552 171 946 321 Average distance of Preference loci Number of generations Number of individuals with preference for AA 0.0 10.0 0.0 10.0 true false "" "" PENS "AA" 1.0 0 -13345367 true "" "plot mean [Pa-average-distance] of AA-turtles-with-Pa-loci " "BB" 1.0 0 -1184463 true "" "plot mean [Pb-average-distance] of BB-turtles-with-Pb-loci " OUTPUT 1340 37 1761 508 11 @#$#@#$#@ ## How to use the model Sliders/switches on the interface tab: * carrying-capacity - the number of individuals in the population. * mutant-proportion - the proportion of individuals that carry one new mutation in their genome, every generation * genome-length - the number of loci in each chromosome. * preference-strength - the factor determining the addition of each preference mutation to the strength of the preference (i.e the slope of the probability to mate function). * recombination - determines whether or not the genome goes through recombination. * selection-coefficient - determines selection force against maladaptive genotypes. Equals the proportion of maladaptive individuals that die during selection. * max-matching-attempts - the maximum number of females that a male can refuse to mate with before he is taken out of the mating pool. This variable is included to prevent the simulations from getting stuck because none of the females are suitable for a single male. ## Comparison to the physical_linkage_one_trait_locus model This model is an extention of the physical_linkage_one_trait_locus model, in which the ecological trait is controlled by a single locus. In this model, the ecological trait is controlled by two separate loci with epistatic interactions. The model description specified below is of the one trait locus model (see ODD below). The differences in the current model compared to the one trait locus model are specified here: The genetic basis of the trait in the model is similar to that of wing colour pattern in the two sympatric species Heliconius melpomene and H. cydno, where the optix and cortex loci control red and white forewing bands respectively (Naisbit et al., 2003) . To simplify the model description, we hereafter refer to colour pattern as the ecological trait, but the model could equally apply to a wide range of ecological traits. The two colour loci in this model are located at opposite ends of the chromosome. The ‘Red’ locus is located at the first position within the chromosome and the ‘White’ locus is located at the last position within the chromosome. The colour loci each have two possible alleles which account for the presence (‘R’ and ‘W’ alleles) and absence (‘r’ and ‘w’ alleles) of a red and white band in the forewing, respectively. The alleles for presence of colour bands are dominant over those for absence. The presence of one colour band does not replace the presence of the other, resulting in a possible intermediate red-white band, characteristic of hybrids of H. melpomene and H. cydno. Together, there are nine possible genotypes at the two colour loci, and four possible colour phenotypes. The representation of genotypes and phenotypes in the model are based on descriptions of the genetic basis of forewing colour pattern in H. melpomene, H. cydno and their hybrids (Naisbit et al., 2003). Similar to the previous model, selection favours the red phenotype in one habitat and the white phenotype in the other, reflecting separate predators in each habitat, that learn to avoid different wing colour patterns (Mallet and Barton, 1989). The intermediate red-white phenotype and the no-colour phenotype are maladaptive in both habitats. Randomly placed mutations cause mating preferences for either red or white phenotypes, similar to the preference for AA or A’A’ phenotypes in the model with one locus controlling the ecological trait. Neutral mutations, which do not contribute to mating preferences, are added as a reference. The probability of mating with an individual of red or white phenotype is dependent on the number of preference loci and is calculated in the same way as in the model with one locus controlling the ecological trait. All individuals exhibit an intermediate mating preference for the red-white and no-colour phenotypes with a constant mating probability of 0.5. All other processes were identical to the model with one locus controlling the ecological trait. ## Complete model description following the ODD (Overview, Design concepts and Details) protocol for individual-based models (Grimm et al., 2006, 2010): ## Purpose The model was designed to explore evolutionary changes in the relative location of loci contributing to reproductive isolation, as a result of selection pressure against intermediate phenotypes. The model is inspired by the colour patterns and mating behaviours of Heliconius butterflies but applies for a wide range of biological systems. ## Entities, state variables, and scales The model consists of 10000 individuals with an even male:female ratio. Individuals are diploid with a single pair of homologous chromosomes, each containing a sequence of 100 loci, defined together as the “genome”. The first locus controls an ecological trait, for which there are two possible alleles, with an initially equal frequency in the population: A or A’. The alleles are codominant and therefore the three possible genotypes produce three separate phenotypes: AA, A’A’ homozygotes or an intermediate, heterozygote AA’ phenotype. The ecological trait is subject to selection, but also serves as a mating cue and can therefore be considered a “magic trait” (Servedio et al. 2011). Mutations that cause a preference to mate with either AA or A’A’ phenotypes (preference loci), as well as neutral mutations for comparison, occur at random across the 100 loci in one percent of individuals every generation. The higher the number of preference loci for AA in the genome, compared to the number of A’A’ preference loci, the higher the probability to mate with an individual of AA phenotype (see Submodels section for detailed description). The modelled environment comprises two habitats, such that selection favours AA genotype in one habitat and A’A’ genotype in the other. Both habitats are maladaptive for the heterozygote AA’ phenotype. Selection is modelled to reflect a scenario of two separate phenotypic optima, with sub-optimal hybrid phenotypes. Habitats are represented in the model in a non-spatial manner. Individuals remain in the habitat to which they are initially assigned. Time steps in the model correspond to discrete, non-overlapping generations. Each simulation was run for 3000 generations. ## Process overview and scheduling Each generation, several stages are executed in the following order: (1) formation of mating pairs, (2) reproduction, (3) recombination of offspring chromosomes and addition of randomly placed neutral mutations or mutations causing mating preference, (5) ecological selection, and (6) density dependent regulation of population size. For details on each process see ‘Submodels’ section. ## Design concepts Basic principles. The model design is based on several Basic principles: (i) selection favours distinct phenotypes of the ecological trait and acts against intermediate phenotypes that arise when separate phenotypes mate, thereby promoting assortative mating based on the trait phenotype. Therefore the trait is regarded as a ‘magic trait’, which is subject to divergent ecological selection and also contributes to non-random mating (Servedio et al., 2011). Specifically,. (ii) Genetic elements that control the trait evolve first, followed by the evolution of genetic elements that control mating preferences, as is assumed to have occurred in Heliconius (Jiggins et al., 2004). The latter can potentially evolve at various places within the genome, and within various distances from trait loci. (iii) Recombination has the potential to break up associations between specific trait and preference alleles (Felsenstein, 1981). Therefore, the physical distance between trait and preference alleles within the genome plays an important role in the development of assortative mating. Emergence. Given the disadvantage of offspring with an intermediate phenotype, assortative mating is expected to emerge. Mutations that cause mating preference for the AA or A’A’ genotypes are expected to accumulate on chromosomes that carry the A or A’ allele, respectively. However, it is not straight forward under which conditions selection will favour genomes in which preference loci accumulate nearby the trait locus. Stochasticity. The model includes several procedures that are determined stochastically, to represent random events that take place in reality. These include matching of individuals with potential mating pairs, choice of two of the four parent chromosomes which will be passed on to each of their offspring separately, the cross-over point for recombination, individual genomes that undergo a mutation (either neutral or one that contributes to mating preference), and the location of each mutation within the genome. Alongside these central stochastic procedures, there are several components of the model that are determined stochastically to maintain events or behaviours at a specified frequency. These include the initial distribution of individuals among the two habitats, determining the trait locus alleles of initial individuals, the decision whether to mate with a potential mating partner, and death due to selection and due to density dependent population size regulation. Observation. The average distance of each type of preference loci and of neutral mutations from the trait locus is recorded for each individual across both chromosomes. The values are then averaged across all individuals, separately for individuals of AA and A’A’ phenotype, at every generation. The proportion of phenotypically matching mating pairs, in which both male and female are of AA phenotype or of A’A’ phenotype, is recorded every generation, as a measure of assortative mating. ## Initialization At the beginning of each simulation, 10000 individuals, half male and half female, are randomly assigned to one of the two habitats. The alleles at the trait locus on each of the two chromosomes of each individual are randomly chosen at an equal probability for the A and A’ alleles. Neutral mutations or ones that cause mating preferences are then randomly added to one percent of the population. ## Input data The model does not use input data to represent time-varying processes. ## Submodels Formation of mating pairs: Males and females from both habitats are mixed into the same mating pool and have an equal probability to be paired with each other, reflecting a scenario of unrestricted movement between habitats. The mating choice is made by the female, however since there are no other differences between males and females, the model can also reflect a scenario in which males make the mating choice. Each female is paired with a random male and will mate with him at a probability that depends on the strength of her preference for his phenotype (see below). If a female decides not to mate, she is paired sequentially with a maximum of ten random males until she mates. If she does not mate with the tenth male with which she is paired, she is taken out of the mating pool and does not reproduce. Limiting the number of males with which a female is paired avoids simulations from running endlessly. See supplementary material (???) for details on the sensitivity of model results to changes in the maximum number of males with which a female is paired. The probability of a female to mate with a male with which she is paired is described by the following equations: P_A=1/(1+e^(-d∙pf) ) P_A'=1-P_A Where PA and PA’ are the probabilities to mate with a male of phenotype AA and A’A’, respectively. d is the difference between the number of AA preference loci and the number of A’A’ preference loci in the genome. The higher the number of AA preference loci, compared to A’A’ preference loci, the larger the probability to mate with an AA phenotyped individual, and vice versa. A preference strength factor (pf) determines how strong the contribution of each additional preference locus is. The probability to mate with a male of AA’ phenotype is constant for all individuals and equals 0.5. This represents a case in which hybrids, represented by the heterozygotes in this model, exhibit intermediate phenotypes which are partially attractive to individuals who prefer to mate with one of the distinct phenotypes, represented as homozygotes in this model. Robustness of model results to changes in this basic assumption are detailed in the supplementary material (S3.1). The preference strength factor (pf) is used to control the rate at which strong mating preferences accumulate across the population. Varying the value of pf allows testing the influence of mating preference strength on the development of physical linkage between trait and preference loci. Reproduction: Only individuals who have found a mating partner in the previous procedure will reproduce. Each mating pair produces four offspring, two males and two females. The number of offspring was chosen to keep the size of the new generation above carrying capacity, before selection and density dependent regulation take place, to avoid population collapse. Each offspring receives one paternal and one maternal chromosome, randomly chosen from the two chromosomes of each parent. Offspring are assigned the same habitat as their mother, to ensure that the mating choice has a direct influence on the survival of offspring and is therefore subject to natural selection. Following reproduction, the parent generation dies. Offspring recombination and mutation: Each offspring genome undergoes recombination between the two homologous chromosomes. Recombination occurs at one, randomly chosen, cross-over point within the chromosomes. The content of the “genome” sequence after the cross-over point is exchanged between the two homologous chromosomes. Recombination can break apart linkage disequilibrium between traits and mating preferences, both in the model and in reality. It is therefore the force that drives physical linkage between loci controlling the trait and loci controlling mating preferences. After recombination is completed, one percent of individuals in the population undergo a mutation at a single position within their genome. The mutations cause a preference to mate with either AA or A’A’ phenotypes (preference loci), or do not have any influence on mating preferences (neutral loci). The mutations are placed at random locations within the genome and therefore within random distances from the first locus that controls the ecological trait. See supplementary material (S2.3) for details on the sensitivity of model results to changes in the percent of individuals that undergo mutations every generation. We chose to add randomly placed mutations that cause mating preferences based on the assumption that physical linkage is formed by co-option of genes that are already within physical linkage with the trait locus, rather than by transposition of genetic elements that control preference from other regions in the genome. In Heliconius, for example, there is no evidence of transposition around colour pattern genes, or chromosomal inversions that might be involved in maintaining species barriers among Heliconius melpomene and H. cydno (The Heliconius Genome Consortium, 2012; Davey et al., 2017). Ecological selection: Selection favours AA phenotype in one habitat and A’A’ phenotype in the second habitat. Phenotypes that are not favoured in each of the habitats are subject to selection. Selection is modelled to reflect a scenario of two separate phenotypic optima, with sub-optimal hybrid phenotypes. The strength of selection is fixed per simulation and controlled by a selection coefficient (s), which determines the proportion of maladapted individuals that will die due to selection. Robustness of model results to changes in the relative selection level against heterozygote, intermediate, phenotypes are detailed in the supplementary material (S3.2). Density dependent regulation: Each of the two habitats has a carrying capacity of 5000 individuals. The probability of each individual to die due to density dependent regulation equals the number of access individuals in the respective habitat divided by the total number of individuals in that habitat. Separate density dependent regulation of population size in each habitat is based on the assumption that individuals depend on separate, limited, resources in each habitat. @#$#@#$#@ 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 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 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 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.1.1 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ setup go how-many-AA-mated-with-BB + how-many-BB-mated-with-AA < 0.01 * how-many-mating-pairs count genotyped-AA count genotyped-AB count genotyped-BB how-many-AA-mated-with-BB how-many-BB-mated-with-AA how-many-mating-pairs mean [prob-AA] of genotyped-AA mean [prob-BB] of genotyped-BB mean [Pa-count] of genotyped-AA mean [Pa-count] of genotyped-BB mean [Pb-count] of genotyped-AA mean [Pb-count] of genotyped-BB population-mean-distance-of-closest-Pa population-mean-distance-of-closest-Pb population-mean-average-distance-of-Pa population-mean-average-distance-of-Pb minimum-population-average-distance-of-Pa minimum-population-average-distance-of-Pb step-of-minimum-distance-of-Pa step-of-minimum-distance-of-Pb setup go count genotyped-AA count genotyped-AB count genotyped-BB how-many-mating-pairs how-many-AA-mated-with-AA how-many-BB-mated-with-BB mean [prob-AA] of genotyped-AA mean [prob-BB] of genotyped-AA mean [prob-AA] of genotyped-BB mean [prob-BB] of genotyped-BB standard-deviation [prob-AA] of genotyped-AA standard-deviation [prob-BB] of genotyped-AA standard-deviation [prob-AA] of genotyped-BB standard-deviation [prob-BB] of genotyped-BB mean [Pa-count] of genotyped-AA mean [Pb-count] of genotyped-AA mean [nuetral-count] of genotyped-AA mean [Pa-count] of genotyped-BB mean [Pb-count] of genotyped-BB mean [nuetral-count] of genotyped-BB standard-deviation [Pa-count] of genotyped-AA standard-deviation [Pb-count] of genotyped-AA standard-deviation [nuetral-count] of genotyped-AA standard-deviation [Pa-count] of genotyped-BB standard-deviation [Pb-count] of genotyped-BB standard-deviation [nuetral-count] of genotyped-BB mean [Pa-average-distance] of AA-turtles-with-Pa-loci mean [Pb-average-distance] of AA-turtles-with-Pb-loci mean [nuetral-average-distance] of AA-turtles-with-nuetral-loci mean [Pa-average-distance] of BB-turtles-with-Pa-loci mean [Pb-average-distance] of BB-turtles-with-Pb-loci mean [nuetral-average-distance] of BB-turtles-with-nuetral-loci standard-deviation [Pa-average-distance] of AA-turtles-with-Pa-loci standard-deviation [Pb-average-distance] of AA-turtles-with-Pb-loci standard-deviation [nuetral-average-distance] of AA-turtles-with-nuetral-loci standard-deviation [Pa-average-distance] of BB-turtles-with-Pa-loci standard-deviation [Pb-average-distance] of BB-turtles-with-Pb-loci standard-deviation [nuetral-average-distance] of BB-turtles-with-nuetral-loci count AA-turtles-with-Pa-loci count AA-turtles-with-Pb-loci count AA-turtles-with-nuetral-loci count BB-turtles-with-Pa-loci count BB-turtles-with-Pb-loci count BB-turtles-with-nuetral-loci setup go count genotyped-AA count genotyped-AB count genotyped-BB how-many-AA-mated-with-BB how-many-BB-mated-with-AA how-many-mating-pairs mean [prob-AA] of genotyped-AA mean [prob-BB] of genotyped-BB count turtles with [prob-AA > 0.5] count turtles with [prob-AA > 0.9] count turtles with [prob-BB > 0.5] count turtles with [prob-BB > 0.9] mean A-chromosome-Pa-count standard-deviation A-chromosome-Pa-count mean B-chromosome-Pb-count standard-deviation B-chromosome-Pb-count mean [Pa-count] of genotyped-AA mean [Pa-count] of genotyped-BB mean [Pb-count] of genotyped-AA mean [Pb-count] of genotyped-BB population-mean-distance-of-closest-Pa population-mean-distance-of-closest-Pb population-mean-average-distance-of-Pa population-stdev-average-distance-of-Pa population-count-average-distance-of-Pa population-mean-average-distance-of-Pb population-stdev-average-distance-of-Pb population-count-average-distance-of-Pb setup go proportion-unmated-males count males @#$#@#$#@ @#$#@#$#@ 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 @#$#@#$#@ 0 @#$#@#$#@