Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
1
Designingarealisticvirtualbumblebee
TimMarsden
WorcesterPolytechnicInstitute
Advisors:
Dr.RobertJGegear
Dr.ElizabethRyder
2
TableofContentsAbstract...................….......................................................................................................3Introduction......................................................................................................................4Methods.............................................................................................................................6 ODD.........................................................................................................................6 TheOptimalDietModel...................................................................................9 SimulationParameters...................................................................................10Results...............................................................................................................................12 TheSimBeeModel.............................................................................................12 SimBeeProcedureOverview..........................................................................13 DeterminingEnvironments............................................................................14 PartialPreferenceinODM..............................................................................15 LimitedMemoryImpact..................................................................................16 HandlingTime....................................................................................................17 ValidatingtheModel........................................................................................19Discussion........................................................................................................................22References.......................................................................................................................24Appendix1:CodeStructure.......................................................................................28Appendix2:FullCode..................................................................................................30
FiguresFigure1:ODMEquations.............................................................................................10Figure2:SimBeeuserinterface.................................................................................12Figure3:Beedetectionradius.....................................................................................13Figure4:SimBeeProcedureOverview.....................................................................14Figure5:DeterminationofEnvironments..............................................................15Figure6:Percentageyellowflowersaccepted.......................................................16Figure7:Schematicofenvironmentvariability....................................................17Figure8:HandlingTimeinSimBee...........................................................................18Figure9:Environmentsbyhandlingtimemode...................................................19Figure10:ValidatingSimBeeinlabsetting...........................................................20
TablesTable1:StatevariablesforSimBeeAgents...........................................................6
3
Abstract
OptimalForagingTheoryisasetofmathematicalmodelsusedinthefieldofbehavioralecologytopredicthowanimalsshouldweighforagingcostsandbenefitsinordertomaximizetheirfoodintake.Onepopularmodel,referredtoastheOptimalDietModel(ODM),focusesonhowindividualsshouldrespondtovariationinfoodqualityinordertooptimizefoodselection.ThemainpredictionoftheODMisthatlowqualityfooditemsshouldonlybeacceptedwhenhigherqualityitemsareencounteredbelowapredictedthreshold.Yet,manyempiricalstudieshavefoundthatanimalsstillincludelowqualityitemsintheirdietabovesuchthresholds,indicatingasub-optimalforagingstrategy.Here,wetestthehypothesisthatsuch‘partialpreferences’areproducedasaconsequenceofincompleteinformationonpreydistributionsresultingfrommemorylimitations.Totestthishypothesis,weusedagent-basedmodelinginNetLogotocreateamodelofflowerchoicebehaviorinavirtualbumblebeeforager(SimBee).Weprogramvirtualbeeforagerswithanadaptivedecision-makingalgorithmbasedontheclassicODM,whichwehavemodifiedtoincludememory.Ourresultsshowthattheprobabilityofcorrectlyrejectingalowqualityfooditemincreaseswithmemorysize,suggestingthatmemorylimitationsplayasignificantroleindrivingpartialpreferences.WediscusstheimplicationsofthisfindingandfurtherapplicationsofourSimBeemodelinresearchandeducationalcontexts.
4
IntroductionAnimals routinely face the problem of deciding how and what to eat in complex
foraging environments. To gain a better understanding of how animals adaptively address these foraging-related problems, behavioral researchers have developed numerous optimization models derived from the field of economics, collectively referred to as Optimal Foraging Theory (OFT). The central assumption of OFT is that natural selection has shaped the behavioral system of animals to weigh foraging costs and benefits and adopt foraging strategies that maximize their net rate of energy gain and therefore their probability of survival (Darwinian fitness) [Charnov, 1976]. Thus, each model predicts how animals should respond in a particular foraging environment within a given specific set of constraints. Such predictions are then tested empirically to determine whether foraging decisions in a particular floral environment are optimal [Zhang, 2014; Pyke, 1984].
One of the most widely used models within the OFT framework deals with the problem of diet selection. In this ‘prey choice’ model, foragers randomly encounter prey items that vary in quality and must decide whether to consume the item or reject it and continue searching for an alternative item [Sih, 2001]. This scenario assumes that animals are ‘all-knowing’ and therefore have all of the prey information needed to make the optimal decision. Given this assumption, the diet model predicts that animals will develop a foraging strategy that always rejects a lower quality prey item if the abundance of a higher quality item is above a particular threshold [Holt, 2013; Gonzales-Varo, 2013; Sih, 2013; Beecher, 2014]. Yet, most empirical tests of the prey choice model have found that animals still accept low quality items to some extent even when high quality items are abundant, a phenomenon known as partial preference. Although there have been several explanations for partial preferences proposed over the years, its cause remains unknown [Arundel, 2013; Couvillon, 2015]. Here, we describe a series of virtual experiments designed to investigate the role of memory limitations in driving partial preferences in bumblebee foragers.
Bumblebees are an ideal behavioral system to study mechanisms of adaptive prey choice. As social insects, they form colonies comprised of a single queen and up to several hundred workers. A small subset of workers called ‘foragers’ have the sole task of finding and collecting food for the colony in the form of floral nectar and pollen rewards [Dyer, 2004; Goulson, 2009]. Each forager faces the daunting task of maximizing nectar delivery to the colony in habitats containing multiple flower types that vary in their reward quality [Dyer, 2004; Das, 2013; Lourenco, 2015]. Foragers are not pre-programmed with information on floral reward quality; rather, they must learn and remember the reward level and sensory cues (color, odor, shape) associated with each type of flower that they visit [Muth, 2015; Faruq, 2013]. Memory therefore plays a fundamental role in bumblebee survival and reproductive success [Muth, 2015; Zhang, 2014].
To investigate the relationship between memory capacity, floral choice behavior, and reward intake, we used the agent-based modelling (ABM) software NetLogo to develop a virtual bumblebee-plant system called ‘SimBee’. Many computational simulations rely largely on equation-based or analytical modeling, which does not allow for model flexibility at the individual level [Castello, 2013; Liu, 2015]. In contrast,
5
agent-based modelling allows variability by defining the behaviors of individuals with their own set of decision rules, allowing the user to study interconnections between the agents themselves, as well as modelling collective behaviors [Helbing, 2012; Janssen, 2014; Mills, 2015]. Additional characteristics of ABM that are important with respect to biological applications: the modular structure is useful by allowing the modification of existing agent rules or the addition of new agents into pre-existing model structure, emergent properties of higher level relationships are the result of individual agents’ local interactions, and abstraction of new behavior information can occur when there is incomplete knowledge about the target biological process based on known information [Politopoulos, 2007].
Other investigators have developed agent-based models simulating pollinator behavior. In particular, the ‘A-bees-see’ model simulates the differences in the scanning approaches of honeybees and bumblebees to targeting flowers, to develop a better understanding of the evolution of these behaviors [Bukovac, 2013]. The BEEHAVE model simulates multiple environmental stressors on honeybee colonies [Becher, 2014], while the EcoSimInGrid model explores the effects of multiple pollinators on plant communities [Qu, 2014]. Our SimBee model focuses on the behavior of an individual virtual bumblebee, which is programmed with the ability to learn the properties of a simulated floral environment and then use information stored in memory to make foraging decisions based on mathematical components contained in the classic prey selection model. Our long-term goal is to observe the collective impact of individual decisions using this foraging model on population dynamics over time.
In the work presented here, we describe the SimBee model, and use it to study the effects of limited memory capacity on behavioral choices of an individual bee interacting with varied floral environments. We show that partial preferences emerge from the optimal diet model as a natural consequence of bees with limited knowledge interacting with a random floral environment. We further show that how the virtual bee calculates the search time for a rewarding floral type has a large impact on its behavioral choices. Finally, we describe the ability of SimBee to generate environments that can be used to verify model predictions experimentally.
6
MethodsSimBeeModelOverview,Designconcepts,andDetails(ODD)TheODDisastandardmethodofdescribingABMmodels[Grimm,2010]. AcompletedescriptionforeachsubroutineprocessandislocatedintheCodeStructuresection(Appendix1),adetailedflowchartofthedecision-makingprocessislocatedintheresultssection(Figure4),andtheactualNetlogoprogramwithcommentdescriptionscanbefoundinAppendix2.PurposeThismodelisdesignedtoserveasanaccuraterepresentationofthebasicforagingbehaviorofbees.Itincludesthebehaviorsthatareinvolvedinthebeescollectingnectar,andbringingitbacktothehive.Thebee‘decides’whichflowerstovisitbasedontheoptimaldietmodel(ODM)thatwehavemodifiedtoincludealearningandmemorycomponent.Thereasonforcreatingthismodelistoprovideamorerealisticandconsistentbaseuponwhichmoreinvolvedmodelscanbebuilt,andtesthowindividualbeebehaviorhasbeenshapedbynaturaladaptivelyrespondinheterogeneousfloralenvironments.Entities,StateVariables,andScalesThemodelhasthreedifferentindividuals:bees,flowers,andhives.ThestatevariablesfortheagenttypesaresummarizedinTable1.Therearenospecialunitsorenvironmentinthissimulation.
Table1:StateVariablesforSimBeeAgents(ML=memorylist)Hive Flower BeeNectarAccumulated NectarContent Location HandlingTime Heading DetectedFlowers OnFlower? LastFlowerVisited NectarHeld NextFlower TimeofLastBlueflowervisited TimeofLastYellowflowervisited SampleMode? MLyellowhandlingtime MLbluehandlingtime MLyellowsearchtime MLbluesearchtime MLyellowenergycontent MLblueenergycontent
7
ProcessoverviewandSchedulingEachtick,thebeemovesforwardonepatchinarandomdirection(seestochasticitybelow)onwherethebeeis,itcallsdifferentfunctions.Eachtick,eachofthethreebreedsupdatestheirvariablevaluestoaccountfornectartransferifitoccurs.Eachtick,beesstoreandadjustinformationinmemorylistsifapplicable.Inthissimulation,10ticksareequivalentto1second.Abeeisexpectedtoremainonaflowerfortheflower’shandlingtime,defaultis2seconds(20ticks).Abeecanholdupto800unitsofnectarbydefault,andsincethedefaultnectaramountforblueflowersis40ulandyellowflowersis10ul,thebeeisexpectedtovisitbetween60and120flowersbeforereturningtohive.(20ifallbluevisits,80ifallyellowvisits)DesignConceptsBasicprinciples:SimBeemodelscontinuousforaging;thereisnoday/nightcycle.Whenahiveispresentandthebeehasthemaximumamountofnectarthattheycanhold,theybringitbacktothehive.Ifnohiveispresent,thebeewillcollectnectarindefinitelyuntilsimulationend.Objectives:Inthismodel,thebees’objectiveistocollectnectar,andifahiveispresent,tobringitbacktoitshive.Learning:Thebeesrememberthehandlingtimes,energycontent,andsearchtimesofthepastflowersencountered.Thenumberofpastflowersremembered(memorylength)isuser-defined,rangingfrom1to1000.Prediction:Thebeeschangewhethertheirnextflowerencounterwillbeacceptedornotbasedontheinformationfrompastflowervisitsstoredinmemorylists,usingtheODMequation:S1>((E1*h2)/E2)-h1.Therightsideofthisequationisreferredtoasthethreshold.S1=averagesearchtimeforpastblueflowersE1=averageenergycontentforpastblueflowersE2=averageenergycontentforpastyellowflowersh1=averagehandlingtimeforpastblueflowersh2=averagehandlingtimeforpastyellowflowersIfS1>threshold,thebeewillacceptbothflowertypesifencountered.IfS1<threshold,thebeewillacceptonlyblueflowersifencountered.Sensing:Thebeeshaveaconeofsight,whichtheyusetoseenearbyflowersinthedirectioninwhichtheyareheading.Theyareabletoselectarandomflowerwithinthiscone
8
ofdetection.Beesalsoknowthelocationofthelastflowervisitedsotheydon’timmediatelyreturntoit.Interaction:Whenthebeeisonthesamepatchastheflowerithaschosentoencounternext(fromthementionedabovedetectedflowers)thebee“lands”onthatflowerandgathersallofitsnectar,askingtheflowertochangeitsenergyvalueto0,andsetitsoccupied?variabletotrue.Thebeestaysonthatpatchforthehandlingtimecorrespondingtotheselectedflower,andthenectarquantitytransferringfromflowertobee.Oncethebeeleavesthislocation,theflowerdetectsnobeesarepresentandchangesitsoccupied?Booleanbacktofalse.Stochasticity:Thedirectioninwhichthebeetravelsisbasedonpseudorandomnumbers,thepseudorandomnumbergeneratorusedbyNetlogoalwaysusesJava’s“strictmath”libraryanddetailscanbefoundintheNetlogoUserManual[Wilensky,1999].Ifithasnotdetectedaflowertoencounter,thebee’sheadingisadjustedrandomlybetween30degreesrightto30degreesleft.Thisistoemulatethenatural‘drifting’flightpatternsbeesexhibitinreallife.TheflowerchosenbybeestobenextencounteredisalsoastochasticprocessbecauseaccordingtoODM,preyisrandomlyencounteredbeforetheacceptancedecisionoccurs. This means that if the bee has more than one flower in the detected range, the selection is based on pseudorandom numbers. Collectives:Thebeesareallpartofacolonyandallcoloniesarepartofthepopulation.Theactivityoftheindividualcontributestohowthewholepopulationisdoing.Inthismodeleachtrialonlyhasonebeeactiveatatime.Observation:Thedataoutputsneededtoobserveinternaldynamics,solvetheproblemthemodelwasdesignedfor,aswellassystem-levelbehaviorinclude:totalnectargathered,thetotalnumberofflowersencountered,thenumberoftimesthebee’saveragebluesearchtimefluctuatedrelativetothethreshold,Thenumberofyellowflowersencountered,thenumberofyellowflowersaccepted,thenumberofblueflowersencountered,thenumberofblueflowersaccepted,andthetimestampofwhensamplingphaseended.Outputofthebee’sinformationstoredinmemorylistsisalsorequiredtoconfirmcertainaspectsofbeebehaviorarecorrect,suchaskeepingsearchtimeandhandlingtimemutuallyexclusive.ThetoolsneededtoobtaintheseoutputsincludeExcelandBehaviorSpace.InitializationUponclickingthesetupbutton,anumberofblueflowersdeterminedbytheblue-flower-countslideraregeneratedinrandomlocations,andanumberofyellowflowersdeterminedbytheyellow-flower-countslideraregeneratedinrandomlocations.Theseflowershavevariablesdefinedbythefollowingsliders:blue-
9
handling-time,yellow-handling-time,blue-energy,yellow-energy.Abeeisalsogenerated,withmemorylengthdefinedbythebee-memory-lengthslider.Iftestingidenticalenvironmentswithvaryingbeememorylengths,the‘generate-worlds’buttonshouldfirstbeused.Thiswilloutputworldfileswiththesameuser-definedflowervariables,eachwithadifferingbeememorylength:1000,10,5,3,2,1.Theseworldscanbemanuallyimportedafterwardusingthe‘setup-imported’button,orautomaticallyusingBehaviorSpace.InputDataIftestingaspecificenvironment,orasetofidenticalenvironmentswithvaryingbeememorylengths,worldinputfilesareneeded(fromthe‘generate-worlds’buttondescribedabove).Thesefilesarenamedg(number).csv,rangingfromg0.csvtowhateverthenumberofworldsgeneratedendsat.TheOptimalDietModel(CharnovandOrians,1973) Theoptimaldietmodelassumesthatthepredatorencounterspreyitemsofdifferenttypessequentiallyandrandomly,andmustdecidewhethertoacceptorrejectthepreyitemonceencounteredinordertomaximizerateofenergeticgain.Theprofitability(P)ofeachpreyitemequalstheenergycontentofthepreyitemdividedbythehandlingtimeofthepreyitem(P=E/h).Forourmodel,thehandlingtimeistheamountoftimeittakesthebeetoconsumealltheavailablenectarfromaflower.SearchtimeandhandlingtimesareconsideredmutuallyexclusiveeventsintheODM,meaningthepredatorisalwayseithersearchingorconsumingprey,butneverboth.IntheSimBeemodel,onlytwopreytypesareconsidered.Fortheexperimentsconductedhere,themoreprofitablepreytypeisblueflowers,whichhaveanenergycontentof40Jandhandlingtimeof2s,whichequalsaprofitabilityof20J/s.Thelessprofitablepreytypeisyellowflowers,whichhaveanenergycontentof10Jandhandlingtimeof2s,whichequalsaprofitabilityof5J/s. Thebeemustdeterminewhetherspecialization(acceptingthemoreprofitablepreytype)orgeneralization(acceptingbothpreytypes)willoptimizetherateofenergygain,whichisthetotalenergygainedoverthetotaltimespentforaging,asshowninFigure1.Withbothspecialist(R1)andgeneralist(R1,2)ratescalculated,thebeewillspecializeifR1>R1,2,andgeneralizeifR1<=R1,2.Sincetheencounterrateistheinverseofthesearchtime,thisinequalityreducestoEqn3(Figure1).Thus,thedecisiontospecializeonlydependsonthesearchtimeforthemoreprofitablepreytype.Iftheblueflowersareplentiful(shortsearchtimes),thebeeshouldn’tspendtimeacceptinglessprofitableflowers;however,ifblueflowersarescarce,thebeeshouldacceptbothflowertypes.IfthepredatorhascompleteknowledgeoftheparametersgiveninFigure1,itshouldalwayschooseeithertospecializeorgeneralizeatalltime(referredtoasthe‘all-or-none’ruleforselectingthelessprofitabletype);thus,theODMpredictsthatanimalsshouldnevershowapartialpreference.
10
Figure1:ODMEquationsforspecializationandgeneralization.Forspecializing,thetotalenergyequalstheproductoftheencounterrate(#ofblueflowersencountered/time),Energygainedfromeachblueflower,andthetotaltimespentsearching.Thetotaltimespentforagingissearchtimeaddedtothetotaltimespenthandlingblueflowers,whichequalstheproductofencounterrate,handlingtimerequiredforeachblueflower,andtotaltimespentsearching(Eqn1).Forgeneralizing,theideaissimilarexceptnowthetotalenergyisthesumoftotalyellowflowerenergygainedandtotalblueflowerenergygained,andthetotaltimeincludestotaltimespenthandlingyellowflowersandtotaltimespenthandlingblueflowers(Eqn2).IfEqn1>Eqn2,thebeeshouldspecialize;thisinequalityreducestothethresholdequation(Eqn3).IfS1<threshold,thebeeshouldspecialize.Simulationexperimentalparameters Unlessstatedotherwise,simulationexperimentswereperformedinbatchmode(BehaviorSpaceinNetlogo)usingthedefaultsettingsdescribedbelow.Beememorylengthwasoneofthefollowingsettings:1,000,10,5,3,2,or1.Thetimerequiredforeachsamplingperioddependedonthismemorylength.Forexample,ifthememorylengthwas10,thebeewouldsample10blueflowersand10yellowflowersbeforeenteringforagemode.Theforagetimeperiodwasalways300,000ticksaftersamplingended,whichisapproximately8hoursinrealtime(1second=10ticks).
11
Themoreprofitableflowers(prey1)werealwaysblue,contained40ulofnectar,andrequired2secondsofhandlingtime.Thelessprofitableflowers(prey2)werealwaysyellow,contained10ulofnectar,andrequired2secondsofhandlingtime.Eachflowerinstantlyregeneratesthestorednectaramountonceabeehasharvestedtheflowerandlefttheparticularlocation.Forgeneralizedforagingenvironments,wherebothpreytypesarealwaysacceptedduringforaging,theenvironmentcontained10blueand50yellowflowers,randomlyplacedwithinthelandscape.Forspecializedforagingenvironments,whenonlythemostprofitablepreytypeisacceptedduringforaging,theenvironmentcontained20blueand50yellowflowers,randomlyplacedwithinthelandscape.
12
ResultsTheSimBeemodel TheSimBeeuserinterfaceisillustratedinFigure2.Uponsetup,thevirtualenvironment,termeda‘world’,isgenerated.Auser-definednumberofflowersisrandomlydistributedintheworldforeachflowertype.Currentlytwotypesofflowersareallowed,depictedbyblueandyellowflowericons.Theuserdeterminestheenergycontentandhandlingtimesforeachflowertype.Forexperimentsreportedhere,theblueflowersarealwaysmostprofitable(energycontentof40J,handlingtime2seconds),andtheyellowflowersarealwaysleastprofitable(energycontentof10J,handlingtime2seconds).Flowersrefillinstantaneouslyafterbeingacceptedaspreybyabee. Thebeeisplacedatarandomlocationintheenvironment.Thebeemovesaroundthesimulationuntilitdetectsaflower.Thebeedetectsadjacentflowerswithinitslineofsight,usingauser-definedviewradiusandarc.Forexperimentsreportedhere,aviewradiusof9patchesandanarcof140°wereused.(Figure3).Iftherearemultipleflowerswithindetectionrange,thebeewillchoosearandomflowerandtraveltothislocation;thisactionistermedanencounterwiththeflower.Thebeewillaccepttheflower(takenectarfromit)basedontheoptimaldietmodelstrategydescribedbelow.Ifthebeeacceptstheflower,itwillremainattheflowerlocationforthehandlingtimeassociatedwiththatflower.Thebeestoresthesearchtimeandprofitabilityfromitsmostrecentacceptancesofeachflowertype,uptoitsmemorycapacity,whichcanrangefrom1to1000.Theusercanchoosewhetherornottoincludehandlingtimeinthesearchtimesforeachflowertype.
Figure2:SimBeeuserinterface:Theusercansetmodelparametersusingtheslidersandinputsontheleft,whileobservingthesimulationinrealtimeontheright.
13
Figure3:Beedetectsflowerswithinauser-definedradiusandangle.Thegreencirclesurroundingthebeedemonstratesthedistancethebeecandetectfrominrelationtoitself,whilethewhiteareavisualizestheradiusandanglethebeeconsiderswithinitsdetectionarea.Here,oneyellowandtwoblueflowersaredetectedbythebee.SimBeeProcedureOverview TheSimBeemodelprocedureoverviewisshowninFigure4.Aftertheinterfaceissetup,aninitialsamplingmodeisutilizedbythebeeinordertodetermineprofitabilityoftheavailableflowertypes.Insamplingmode,thebeewillalwaysacceptbothpreytypesuponencounteringthem.Oncethebeememorycapacityisreachedforbothflowertypes,thebeeswitchestoforagingmode.Inourexperiments,foragingmodeisrunfor300,000steps(simulatingapproximately8hours,whereeachmodelstepcorrespondsto0.1seconds).Duringthistime,eachencounterdecisiontoacceptorrejectaflowertypedependsonthethresholdinequalityderivedfromtheOptimalDietModel(SeeMethods,Fig.1,Eqn3).Iftheencounteriswithablueflower(mostprofitable),itisalwaysacceptedbythebee,andtheflower’sprofitabilityandsearchtimevaluesareaddedtothebeememory.Iftheencounteriswithayellowflower(lessprofitable),thebeewillacceptthefloweriftheaverageblueflowersearchtimeiscurrentlygreaterthanthethresholdcalculation.Otherwise,thebeewillrejectthisyellowflowerandcontinueforaging.
14
Figure4:SimBeeProcedureOverview.Uponsetup,thebeeenterssamplingmode,whereeveryflowerencounteredisacceptedtodetermineprofitabilityofflowertypes.Onceasetnumberofflowersareacceptedforeachflowertype,thebeewillswitchtoforagemode,andusetheinformationgatheredduringsamplingmodetodeterminewhetheroneofbothflowertypesshouldbeaccepted.Uponflowerencounter,iftheflowertypeisblue(mostprofitable),itisautomaticallyaccepted,addstheinformationintoitsmemory,andreturnstosearchingforflowers.Iftheflowertypeisyellow(lessprofitable),itdeterminesiftheaveragesearchtimeforblueflowersisaboveorbelowthethreshold.Ifbelow,itrejectstheyellowflowerandcontinuessearching.Ifabove,itacceptstheyellowflower,addstheinformationtoitsmemory,andreturnstosearchingforflowers.Thiscontinuesforasetintervaloftime(300kticks,whichisroughly8hoursoronedayofforaging).DeterminingSpecialized(S)andGeneralized(G)environments Inordertotestthebehavioraleffectsofchangesinmemory,wefirstwantedtocreateenvironmentsinwhichabeewithcompleteknowledgeoftheenvironment(an‘all-knowing’bee)willeitheralwaysspecialize(Senvironment)oralwaysgeneralize(Genvironment).Foroursimulatedenvironments,wedeterminedthatabeewithmemorylengthof1000was‘all-knowing’,withessentiallycompleteknowledgeoftheenvironment.Weranmultipletrialsofwithbeememorylength1000forarangeofblueflowercounts,anddeterminedtheenvironmentsinwhichbeesalwaysspecializedoralwaysgeneralizedforeverytrial.Byrunning10trialsforenvironmentswith50yellowflowersandvariablenumbersofblueflowers,itwasdeterminedthat10blueflowersand50yellowflowersalwaysresultedingeneralizationwhile20blueflowersand50yellowflowersalwaysresultedinspecialization(Figure5).Forenvironmentswithintermediatenumbersofblueflowers,thesimulationsometimesgeneratedGandsometimesSenvironments,duetotherandomplacementofflowerswithintheenvironment.Thuswechose10and20blueflowerstodefineourGandSenvironments,respectively.
15
Figure5:DeterminationofSpecializedandGeneralizedEnvironments.‘All-knowing’beesweresubjectedtodifferentworldscontainingaspecificnumberofblueflowers(8,10,12,etc.)and50yellowflowers.Weran10trialspernumberofblueflowers,witheachtrialcontainingadifferentdistributionofeachflowertype.Inthesetrials,searchtimesforpreydidnotincludehandlingtimes.Atrialwasconsideredtobe‘generalized’ifbothpreyitemswereselectedoverthesimulationperiod.Changingmemorysizeaffectsbeebehavior:PartialpreferenceinODM
Inordertotestwhethermemorystrengthaffectsbehavioralchoices,weranthesimulationwithvirtualbeesofvariousmemorylengthsinthespecializedandgeneralizedenvironmentsdefinedabove.Wegenerated10randomSenvironmentsand10randomGenvironments.Withineachenvironment,wetestedabeeforeachmemorylength(1000,10,5,3,2,1).Wemeasuredthepercentyellowflowersaccepted;0%acceptanceindicatesthebeehadcompletelyspecializedonblueflowers,while100%acceptanceshowsthebeehadcompletelygeneralizedandacceptedbothflowertypes.Anypercentagebetweenindicatesthatthebeefluctuatedbetweenspecializationandgeneralizationatcertainpointsinthesimulation.Averagesforageneralizedenvironmentandspecializedenvironmentweregraphedwith95%CI(Figure6).Thesefindingsshowthatreducedmemorycanresultintheappearanceofpartialpreferenceswhenthesamebeewith‘all-knowing’memorywouldalwayseitherspecializeorgeneralizeforeachtrial.Notethatasmemorysizedecreases,thevirtualbeeshowsgreaterpartialpreferences;thatis,itacceptsyellowflowersmorefrequentlyinaspecializedenvironment,orlessfrequentlyinageneralizedenvironment.
(a)
00.20.40.60.81
1.2
8 10 12 14 16 18 20 22
%GeneralizedTrials
#BlueFlowers
PercentageofGeneralizedTrialsbySamplingend(HandlingTimeexcluded)
16
(b)
Figure6:Percentageyellowflowersacceptedoverencounteredbybeeswithvaryingmemorylengthsingeneralized(a)andspecialized(b)environments.‘Mx’denotesthenumberofblue-bluetransitions(bluesearchtimes)thatcanbestoredinmemory.Partialpreferencesareobservedwhenvaluesarebetween0and1.N=10foreachmemorylength.Theimpactoflimitedmemoryandenvironmentalvariabilityonbeedecisionmaking
Byexaminingpaths,abeemighttakeduringasimulationtrial,wecanunderstandwhypartialpreferencesareobserved.Environmentalvariability’seffectondecisionmakingisillustratedinfigure7withbeememorylength3.Here,thebeeisinageneralizingenvironment,whereabeewithamemorylengthof1000wouldalwaysacceptyellowflowers.Forthebeetakingthevioletpath,theaverageofthepastthreebluesearchtimesisgreaterthanthethresholdof60,sothebeewillacceptthenextyellowflowerencountered(Figure7).Forthebeetakingtheredpath,theaverageofthepastthreebluesearchtimesislessthanthethresholdof60,sothebeewillrejectthenextyellowflowerencountered(Figure7).
0
0.2
0.4
0.6
0.8
1
1.2
m1000 m10 m5 m3 m2 m1
% A
ccep
ted
/ Enc
ount
ered
Memory Length
Percent Yellow Accepted / Encountered20 blue 50 yellow - Generalized Environment
0
0.05
0.1
0.15
0.2
m1000 m10 m5 m3 m2 m1
% A
ccep
ted
/ Enc
ount
ered
Memory Length
Percent Yellow Accepted / Encountered10 blue 50 yellow - Specialized Environment
17
Figure7:Schematicofhowenvironmentalvariabilitycaneffectoptimaldecisionmakingprocesses.Forthebeefollowingtheredpath,thepast3blueflowerencountershaveanaveragesearchtimeof23ticks,whichisbelowthethresholdof60.Thisindicatesthatthemoreprofitablepreytypeisfrequentenoughthatlessprofitablepreytypesshouldberejected,sotheincomingyellowflowerencounterwillberejected.Forthebeefollowingthevioletpath,however,theaveragesearchtimeforthepast3blueencountersis64.Thisisabovethethresholdof60,whichindicatesthatthemoreprofitablepreytypeisuncommonenoughthatacceptingallpreytypesisoptimal,andtheincomingyellowflowerencounterwillbeaccepted.Inclusionofhandlingtimewithinsearchtimes
TheODMdefinessearchtimeandhandlingtimesasmutuallyexclusive.Inactuality,it’sunclearwhetherbeesarecapableofcalculatingpreyhandlingtimesseparatelyfromsearchtimes,especiallywhenconsideringhundredsofpastencounters.Bydefault,SimBeeremoveshandlingtimesofyellowflowerencountersthatoccurredbetweenblueflowerencounters,sothattheaveragesearchtimeofblueflowers(S1)followstheODMdefinition(HandlingTimeExcludedmode,Figure8).Wealsoincorporatedtheabilitytoincludehandlingtimesinthecalculationofsearchtimes,possiblymorecloselyfollowinganactualbee’sperceptionofsearchtimes(HandlingTimeIncludedmode,Figure8).
18
Figure8:SearchtimeandHandlingtimerelationshipintheSimBeemodel.Whenhandlingtimeisexcludedfromsearchtime,thebluesearchtimeequalsthesumof5searchtimes(purplearrows)for93ticks.Whenhandlingtimeisincludedinsearchtime,thebluesearchtimeincludesthehandlingtimesforthe4yellowflowersencountered;thetotalsearchtimeis173ticks.Specialized(S)andGeneralized(G)environmentsbyHandlingTimemode Whenhandlingtimeisincludedinsearchtime,thesearchtimeismuchlonger,andthenumbersofflowersrequiredtogenerateSpecializedandGeneralizedenvironmentschange.Byrunning10trialswitharangeofblueflowercountsandplottingthepercentageofgeneralizedtrials,wedemonstratedthatthenumberofblueflowersrequiredtogenerateSpecializedenvironmentsshiftsfrom10blueflowersforhandlingtimeexcluded,to20blueflowersforhandlingtimeincluded(Figure9).ForGeneralizedenvironments,thenumberofblueflowersshiftsfrom20blueflowersforhandlingtimeexcluded,to40blueflowersforhandlingtimeincluded(Figure9).Thisshiftwasconsideredsignificantforthepurposeofdemonstratinghowtherelationshipbetweenhandlingandsearchtimecanalterhowbeesperceivegeneralizedorspecializedenvironments,whilefurthertrialsareneededinordertoconsiderthisshifttrulystatisticallysignificant.
19
Figure9:Specialized(S)andGeneralized(G)environmentsbyhandlingtimemode.Withhandlingtimeexcluded,Genvironmentisachievedwith10blueflowers,andSenvironmentisachievedwith20blueflowers.Whenhandlingtimeisincludedinsearchtimes,however,Genvironmentisshiftedto20blueflowers,andSenvironmentisshiftedto40blueflowers.ValidatingtheSimBeeModelinalabsetting Inordertotestwhetherthemodelcorrespondstorealbeebehavior,wewantedtogeneratesimulationworldsthatcouldbereplicatedandusedinalaboratoryenvironment.Comparisonofrealandsimulatedbeebehaviorwouldthenenableustovalidateandrefinethesimulation,aswellasprovidingawayofestimatingactualbeememorylengthandbehavioralstrategies.Toaccomplishthis,wedevelopedaswitchtofacilitatelaboratoryparametersfortheSimBeemodel.Forthefloralenvironmentlayout,possibleflowerlocationswereconstrictedtoagrid:15rowsby22columnstotaling330possibleflowerpositions.Eachrowandcolumnwere6.5cmapart,andknowingbeesflightspeedapproximated15cm/sbetweenencounters,thesimulationparameterswerestructuredtoemulatethisbehavior(Figure10).Blueflowerswereadjustedtocontain13ulofnectarandhavea4.5secondhandlingtime.Yellowflowerswereadjustedtocontain6.5ulofnectarandhavea4.5secondhandlingtime. UsingtheSimBeeinLaboratorymode,wegeneratedalaboratoryenvironmentcorrespondingwithasimulationworld(Figure10).Thelaboratoryreplicareplacescolordiscriminationwithodordiscrimination,becausethisforcesbeestoapproachflowersverycloselyinordertodiscriminaterewardingandnon-rewardingodors,similartotheprogrammedbeebehaviorinthemodel.Laboratorytestswillallowustodeterminewhetherweobservespecializedand
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
0 10 20 30 40 50 60
%GeneralizedTrials
#BlueFlowers
PercentageofGeneralizedTrialsbySamplingend(BothHandlingTimemodes)(10trials,always50yellow)
HandlingTimeIncluded
HandlingTimeExcluded
20
generalizedenvironments,aswellaspartialpreferences,similartothoseobservedinoursimulations.Theaccuracyofthismethodofdesigningmodelparameterstoemulateknownlabspecificationswillremainunclearuntilassessmentmetricsareincorporatedforcomparisonagainstactualbeebehaviordata.
Figure10:Testingsimulationpredictionswithlaboratorydata.InLaboratorymode,thesimulationgeneratesfloralenvironmentsonagrid(toppanel)thatiseasilytranslatedtoafoamboardwithslotsforpositioningartificialflowers–microfugetubesfilledwithsugarwater‘nectar’surroundedbyfoam‘petals’(bottompanel).Odorantsonthesurfaceofflowersenablesbeestodifferentiatelowandhighqualityflowers.Theboardfitsintoabeecage;beescanbereleasedintothecageandtheirbehaviortrackedbyvideomonitoring.
21
22
Discussion:
Byprogrammingvirtualbeeforagerswithanadaptivedecision-makingalgorithmbasedonOptimalDietModeldevelopedbyCharnov(1976),modifiedtoincludememory,arealisticvirtualbumblebeewasdevelopedthatcanbeusedtoemulateactualbeebehaviorandbetterassistfuturestudiesinvolvingforagingbehavioronthepopulationlevel.Bycomparingpercentageofpreyacceptanceoverencounterofvaryingmemorysizesinthesameenvironments,theresultsshowthatreductionsinmemorycausebeestomakenon-optimalchoiceswhenfloralresourcesarerandomlydistributedintheenvironment.Previousdietmodeldesignscannotexplainpartialpreferencesduetomodelconstraints,howeverbyincorporatingmemoryabilityintothemodel,partialpreferencesareanaturaloutcomefromenvironmentalvariability.Byinvestigatinghowhandlingtimesareincorporatedintosearchtimes,themodelallowscomparisontoactualbeebehaviortodeterminehowbeesactuallyperceivesearchtimesduringforaging,andalsotoestimateactualbee’smemorycapacity.Theseresultssuggestthatenvironmentalstressorsaffectingmemorymaycontributetopopulationdeclinebyincreasingnon-optimalforagingchoices,whichcouldultimatelyreducethereproductivepotentialofbumblebeecolonies.
TheBeeSimmodelisnovelbecauseitisamemory-basedextensionoftheoptimaldietmodelrulesintheforagingmodel.InBecheretal’sBEEHAVEmodel,anagent-basedforagingmodelisderivedforhoneybeecoloniesthatincorporatescolonydynamicsandanagent-basedforagingmodel,howeveritdoesnotincorporatetheoptimaldietmodelforagentdecisionmaking.Dyeretal’s,Beereverse-learningbehaviorsimulationsincorporateagent-basedcomputersimulationsthatinvolveparametersofflowerhandlingtimesandrewardsinordertohelppredictefficiencyinbeebehaviorwhenadjustingtorewardingflowerschangingtounrewardingflowers,butdoesnotaddressthedietmodelintheirmodeldesigns.Quetal’sEcoSimInGridmodelisaspatiallyexplicitagent-basedsimulatorforcomplexanalysesofpollinatorsonplantpopulations,howevertheirdesigndoesnotincorporatebehavioralchoicesbasedontheoptimaldietmodel.
Zhangetal’srecentexperience-driven(RED)decision-makingforagingmodelexplainspartialpreferencesbyusingaprobability-basedmodelthatdeterminespreyacceptancebycomparingtheprofitabilityofthecurrentencountertotheaverageofthemostrecentflowerencounters.Insteadofincorporatingsearchtimesforvarioustypesintodecision-makingasintheoptimaldietmodel,Zhangetal.includeanaversionfactorrelatedtothehungeroftheforagerovertime:foragersthathaven’teatenrecentlyaremorelikelytoacceptencounteredprey.Whileaninterestingmodel,thissimulationislesslikelytoberelevanttobumblebeeforagers,sincetheirbehaviorisnotdrivenbyindividualhunger[Goulson,2009].
FutureworkusingtheSimBeemodelwillinvolvemorerealisticaspectsofthesimulation,includingchangingfloralenvironments,alternatememoryweights,andadditionalpreytypesthatofferarangeofavailablerewardsinsteadofastaticvalue.Adjustingthedecision-makingalgorithmtoincludemultiplepreytypesthatplacemoreweightonthemostrecentdatagatheredwillcreateamorerealisticsystem,allowingbeestoadapttoconstantlychangingresourcesavailable.
23
PredictingtheeffectofmemoryimpairmentontheoverallbeepopulationisthefinalgoaloftheSimBeemodel.Themodelwillcomplementandenhanceinformationgainedfromlaboratoryandfieldstudies.
TheSimBeemodelcanalsobeusedinaneducationaltoolthatallowsstudentstolearnaboutbiologicalconceptsthroughagent-basedmodelling.Thesimulationseparatesaspectsofforagingintosinglevariables,whichgivesstudentstheabilitytohypothesistestbyadjustingsingleparametersofthemodelwithseparateslidersforeachapplicablemodelaspect.Themodelbydesignisuserfriendlyandinteractivewiththereal-timeabilitytoadjustenvironmentalvalues,whichcanfacilitatepubliceducationandagreaterunderstandingoftheimportanceofbumblebeedecline.
24
References:Arundel,J.,Oldroyd,B.P.,Winter,S.(2013)Modellingestimatesofhoneybee(Apisspp.)colonydensityfromdrones.EcologicalModelling267:1-10
Becher,M.A.,Grimm,V.,Thorbek,P.,Horn,J.,Kennedy,P.J.,Osborne,J.L.(2014)BEEHAVE:asystemsmodelofhoneybeecolonydynamicsandforagingtoexploremultifactorialcausesofcolonyfailure.JournalofAppliedEcology51:470–482.
Bukovac,Z.,Dorin,A.,Dyer,A.G.(2013)A-BeesSee:ASimulationtoAssessSocialBeeVisualAttentionDuringComplexSearchTasks.ECAL2013:276-283.
Castello,E.,Yamamoto,T.,Nakamura,T.,Ishiguro,H.(2013)TaskAllocationforaroboticswarmbasedonanAdaptiveResponseThresholdModel.Control,AutomationandSystems(ICCAS)12:259-266
Charnov,E.(1976).OptimalForaging:AttackStrategyofaMantid.TheAmericanNaturalist110:141-151.
Couvillon,M.J.,Toufailia,H.A.,Butterfield,T.M.,Shrell,F.,Ratnieks,F.L.W.,Shurch,R.(2015)CaffeinatedForageTricksHoneybeesintoIncreasingForagingandRecruitmentBehaviors.CurrentBiology25:2815-2818
Das,S.,Biswas,S.,Kundu,S.(2013)Synergizingfitnesslearningwithproximity-basedfoodsourceselectioninartificialbeecolonyalgorithmfornumericaloptimization.AppliedSoftComputing13:4676-4694
Dyer,A.G.,Chittka,L.(2004)Biologicalsignificanceofdistinguishingbetweensimilarcoloursinspectrallyvariableillumination:bumblebees(Bombusterrestris)asacasestudy.JournalofComparativePhysiology190:105-114
Dyer,A.G.,Dorin,A.,Reinhardt,V.,Garcia,J.E.,Rosa,M.G.P.(2014)Beereverse-learningbehaviorandintra-colonydifferences:Simulationsbasedonbehavioralexperimentsrevealbenefitsofdiversity.EcologicalModelling277:119-131.
Faruq,S.,McOwan,P.W.,Chittka,L.(2013)Thebiologicalsignificanceofcolorconstancy:Anagent-basedmodelwithbeesforagingfromflowersundervariedillumination.J.Vis10:1-4.
González-Varo,J.P.,Biesmeijer,J.C.,Bommarco,R.,Potts,S.G.,Schweiger,O.,Smith,H.G.,Steffan-Dewenter,I.,Szentgyörgyi,H.,Woyciechowski,M.,Vilà,M.(2013)CombinedEffectsofglobalchangepressuresonanimal-mediatedpollination.TrendsinEcology&Evolution28:221-240
25
Goulson,D.Bumblebees:Behaviour,Ecology,andConservation(2ndEdition).2009.OxfordUniversityPress.
Grimm,V.,Berger,U.,DeAngelis,D.L.,Polhill,J.G.,Giske,J.,Railsback,S.F.(2010)TheODDprotocol:Areviewandfirstupdate.EcologicalModelling221:2760–2768
Helbing,D.(2012)SocialSelf-OrganizationAgent-BasedSimulationsandExperimentstoStudy.EmergingSocialBehavior11:341-349.
Holt,R.D.(2013).Unstablepredator–preydynamicspermitsthecoexistenceofgeneralistandspecialistpredators,andthemaintenanceofpartialpreferences.IsraelJournalofEcologyandEvolution59:5-9
Janssen,M.A.,Hill,K.(2014)BenefitsofGroupingandCooperativeHuntingAmongAcheHunter–Gatherers:InsightsfromanAgent-BasedForagingModel.HumanEcology42:823-835
Liu,B.,Cai,M.,Yu,J.(2015)SwarmIntelligenceanditsApplicationinAbnormalDataDetection.Informatics39:1-13
Lourenco,R.,Delgado,M.,Korpimaki,E.,Penteriani,V.(2015)Evaluatingtheinfluenceofdiet-relatedvariablesonbreedingperformanceandhomerangebehaviorofatoppredator.PopulationEcology57:625-636
Mills,R.,Correia,L.(2015)TheInfluenceofTopologyinCoordinatingCollectiveDecision-MakinginBio-hybridSocieties.ProgressinArtificialIntelligence9273:250-261
Muth,F.(2015)Theeffectsofacutestressonlearningandmemoryinbumblebees.Learningandmotivation50:39-43
Politopoulos,I.(2007)ReviewandAnalysisofAgent-basedModelsinBiology.UniversityofLiverpoolTechReports07:2-14
Pyke,G.H.(1984)OptimalForagingTheory:ACriticalReview.Ann.Rev.Ecol.Syst.15:523-75.
Qu,H.,Seifan,T.,Tielborger,K.,Seifan,M.(2013)Aspatiallyexplicitagent-basedsimulationplatformforinvestigatingeffectsofsharedpollinationserviceonecologicalcommunities.SimulationModellingPracticeandTheory37:107–124
Sih,A.(2013).Understandingvariationinbehavioralresponsestohuman-inducedrapidenvironmentalchange:aconceptualoverview.AnimalBehavior85:1077-1088.
Sih,A.,Christensen,B.(2001)Optimaldiettheory:whendoesitwork,andwhenandwhydoesitfail?AnimalBehaviour61:379–390.
26
Wilensky,U.(1999).NetLogo.http://ccl.northwestern.edu/netlogo/.CenterforConnectedLearningandComputer-BasedModeling,NorthwesternUniversity
Zhang,F.,Cang,H.(2014)Recentexperience-drivenbehaviouroptimizesforaging.AnimalBehaviour88:13-19.
27
28
Appendix1:CodeStructure:Bees
• Move-bees:o Ifnoton-flower?[bees-search-for-flower]o Ifon-flower?[bees-collect-nectar]
• Bees-search-for-flowero ifchosen-flower=NOBODY[bees-decide-next-flower]o Ifnoflowers-in-view[moverandomly]o Ifchosen-flower!=NOBODY[facechosen-flower,movetowards]
• Bees-decide-next-flowero IFanyflowers-in-view[chooserandomflower]o Determinewhichpreytypeshouldbeacceptedo Ifcolorofchosen-flower=next-color[acceptencounter]
• Bees-collect-nectaro Bees-determine-memory-valueso Update-memoryo bee-decide-preyo Iftimespentonflowerreached,forageandleave
• Bees-determine-memory-valueso Ifmutually-exclusivehandlingtime:
§ Subtracthandling-timeofbetweenencountersrecordedo Storesearch-timeinsearchmemoryo Ifaccepting-encounter?true
§ Storeenergyandhandlingtimesinmemory• Update-memory
o Ifmemorylistlength>bee-memory-length§ removeoldestmemoryvalue
o Ifsamplingandallmemorylistsfilled§ Setsamplingfalse§ Resetnectarheld,encountertrackingvariables
• Bee-decide-preyo Calculateaveragesformemorylists
§ Searchtimes§ Handlingtimes§ Energycontents
o Determineprey1=greatestenergy/handling-timeo Determinethreshold
§ ((p1energy*p2handling)/p2energy)–p1handlingo Ifaveragep1search-time>threshold,generalize
§ Acceptanypreytypeencounterednexto Ifaveragep1search-time<threshold,specialize
§ Acceptonlyprey1fornextencounterFlowers
• Regenerate-flower-nectar
29
o Ifnectarcontent<flower-max-nectar[refillnectar]• Flowers-track-occupation
o Ifanybees-here[setoccupied?true]o Else[setoccupied?false]
30
Appendix2:FullSimBeeCode;--------------------------------------------------breeds------------------------------------------------------------------------------breed[flowersflower]breed[beesbee]breed[hiveshive];-------------------------------------------------variables----------------------------------------------------------------------------globals[;-ticks-at-sampling-end;-----outputvariable:timewhensamplingendedspecialized-at-sampling-end?;-----outputvariable:ifbeespecializedatsamplingendworld-name;-----outputvariable:whattheworldoutputfileisnamedhive-1;----IDof1sthivehive-2;----IDof2ndhiveswitch-count;-----outputvariable:#timesflowercolor!=lastvisittotal-count;-----outputvariable:#flowervisitstotalerror-visit-count;-----debugvariable:ifbeevisitsunintendedflowertravel-distances;-----outputvariable:distancesbetweenvisitedflowersthreshold-switch-count;-----outputvariable:#timesS1wentabove/belowthresholdNectarGathered;-----outputvariable:totalnectarbeegatheredcurrent-iteration;-----behaviorspacevariable:trackscurrentrunnext-run?;-----behaviorspacevariable:iftrue,behaviorspacedeletescurrentworldfile,startsnextrundone-time?;-----behaviorspacevariable:alsousedtoendstartnextruninsomecasesblue-search-mean;-----OFTvariable:averagebluesearchtimeofbeememoryyellow-search-mean;-----OFTvariable:averageyellowsearchtimeofbeememoryyellow-handling-mean;-----OFTvariable:avgyellowhandlingtimeblue-handling-mean;-----OFTvariable:avgbluehandlingtimeyellow-energy-mean;-----OFTvariable:avgyellowenergycontentblue-energy-mean;-----OFTvariable:avgblueenergycontentprey-1;-----OFTvariable:defineswhichpreytypeismostrewardingnext-prey;-----OFTvariable:definesifnextencounterwillbespecializedorgeneralizedsearch-threshold;-----OFTvariable:calculateswhatthresholdis:(E1*h2)/E2)-h1last-visit-yellow;-----graphvariable:updatessequencegraphwithyellowbarlast-visit-blue;-----graphvariable:updatessequencegraphwithbluebarsame-color-inarow;-----graphvariable:trackssetsofsame-colorvisitpatternsPropNecBlue;-----graphvariable:displaysproportionofnectarhascomefromblueflowersPropNecYellow;-----graphvariable:displaysproportionofnectarhascomefromyellowflowersblue-population;-----graphvariable:tracks#blueflowersinenvironmentyellow-population;-----graphvariable:tracks#yellowflowersinenvironmentlast-flower1;-----debugvariable:displayslastflowervisitedthis-flower1;-----debugvariable:displayscurrentflowervisitingblue-accepted;-----graphvariable:displays#blueflowersacceptedblue-encountered;-----graphvariable:displays#blueflowersencounteredyellow-accepted;-----graphvariable:displays#yellowflowersacceptedyellow-encountered;-----graphvariable:displays#yellowflowersencounteredblue-ratio1;-----graphvariable:displays%blueflowersaccepted/encounteredyellow-ratio1;-----graphvariable:displays%yellowflowersaccepted/encounteredseq-update?;-----graphvariable:iftrue,updatesvisitsequencegraphsampling-file-name;-----outputvariable:nameofseparateexportfileforsamplingdataifneededspecialized?;-----outputvariable:indicatesofbeespecializedornotatsamplingendlandscapeID;-----outputvariable:unique#foreachgeneratedenvironment,formultiplerunswithsamelayout;-]bees-own[on-flower?;-----indicatesifflowerpresenthive-belongs-to;-----whichhiveitbelongstobee-nectar-collected;-----amountofnectarcollectedtime-on-flower;-----howlongbeehasbeensittingonflowerflowers-in-view;-----agentsetofallflowersdetectedinviewlast-flower;-----IDoflastflowervisitedchosen-flower;-----IDofnextflowertovisitnext-color;-----colorofnextfloweryellow-handling-memory;-----listofpastyellowflowerhandlingtimesblue-handling-memory;-----listofpastbluehandlingtimes
31
yellow-energy-memory;-----listofyellowenergycontentsblue-energy-memory;-----listofblueenergycontentsyellow-search-memory;-----listofyellowsearchtimesblue-search-memory;-----listofbluesearchtimeslast-blue-time;-----timestampoflastblueencounterlast-yellow-time;-----timestampoflastyellowencounterflower-landing-memory;-----listoftimestampswhenpastflowersvisitedjust-landed?;-----indicatesifbeejustarrivedtoflowerornotsampling?;-----indicatesifbeeisstillsamplingprey1;-----indicatesthemorerewardingpreytypeprey2;-----indicatesthelessrewardingpreytypenextprey;-----equals"both"ifbeeisgeneralized,"blue"ifspecializedlast-color;-----coloroflastflowervisitedaccept-encounter?;-----indicatesifbeewillacceptthecurrentencounter]flowers-own[flower-nectar-content;-----amountofnectarinflowerflower-handling-time;-----amountofhandlingtimeforfloweroccupied?;-----indicatesifabeeisontheflowerflower-type;-----indicatespreytypeblock-number;-----indicateswhichregionflowerislocatedin]hives-own[hive-nectar-content;-----amountofnectarthat'sbeenreturnedtothehive]togenerate-worlds;------------------------------createworldsforbehaviorspaceletoriginal-numbernumber-of-worlds;-----tooffsetworldfilenamesletoriginal-handlingyellow-handling-time;-----savesoriginalyellowhandlingtime,toresetonceworldsgeneratedsetnumber-of-worldsnumber-of-worlds+last-world-offset;-----offsetsworldfilenameswhile[number-of-worlds>last-world-offset=true][setupsetbee-decision-type"prey-model"setbee-memory-length1000;-----exportworldfor'all-knowing'beesetnumber-of-worldsnumber-of-worlds-1setworld-name(word"g"number-of-worlds".csv")export-worldworld-namesetbee-memory-length10;-----adjustworldnameandbeememorylength,exportworldsetnumber-of-worldsnumber-of-worlds-1setworld-name(word"g"number-of-worlds".csv")export-worldworld-namesetbee-memory-length5;-----*setnumber-of-worldsnumber-of-worlds-1setworld-name(word"g"number-of-worlds".csv")export-worldworld-namesetbee-memory-length3;-----*setnumber-of-worldsnumber-of-worlds-1setworld-name(word"g"number-of-worlds".csv")export-worldworld-namesetbee-memory-length2;-----*setnumber-of-worldsnumber-of-worlds-1setworld-name(word"g"number-of-worlds".csv")export-worldworld-namesetbee-memory-length1;-----*setnumber-of-worldsnumber-of-worlds-1setworld-name(word"g"number-of-worlds".csv")export-worldworld-name]setlast-world-offsetlast-world-offset+original-number;-----ensuresworldfilesaren'toverwrittensetnumber-of-worldsoriginal-number;-----returnsworldcountsetyellow-handling-timeoriginal-handling;-----resetsyellowhandlingtimeendtoexport-lab-world;----------------exportspecificenvironmentforlabrecreationexport-worldexport-world-nameexport-view(word"view-"export-world-name".png");-----exportsimageoflandscapegeneratedendtodetermine-world;-----;-----------------forbehaviorspace:determinenextworldtoimportandrunletnum-test1000;-----startsveryhightoenurelastworldgeneratedisfirstletworld-test(word"g"num-test".csv")while[file-exists?world-test=false][;-----continuessearchinguntilfilenameexistssetnum-testnum-test-1setworld-test(word"g"num-test".csv")ifnum-test<0[error"Worlddoesn'texist"];-----indicatesnoworldlefttoimport
32
]setworld-nameworld-test;-----setsworldnametoimportoncevalidworldnamefoundendtosetup-imported;-----;--------------forbehaviorspace:importnextworldandsetupclear-allreset-tickssetup-globalsdetermine-worldimport-worldworld-name;-----importsworldnamedeterminedfromdetermine-worldend;-----------------------------------------------settingvalues------------------------------------------------------------------------tofix-flower-count;-----;-------------forlabenvironment:makesuretotalflowercountiscorrectsetyellow-flower-counttotal-flower-count-blue-flower-countend;---------------------------------------------------setup------------------------------------------------------------------------------;-----;initializesbreedsandenvironmenttosetupclear-allreset-tickssetup-globalssettravel-distances[1];-----formonitoringdistancestravelled;-----;;callsetupfunctionssetup-patchessetup-flowersspace-flowerssetup-bees;setup-hives;-----hivesnotcurrentlyusedspace-flowersset-labelssetup-exportendtosetup-globals;-----addsinitialvaluestovariablesthatcan'tbeemptyatinitializationsetblue-search-mean1setyellow-search-mean1setyellow-handling-mean1setblue-handling-mean1setyellow-energy-mean1setblue-energy-mean1setsearch-threshold1setthreshold-switch-count0setdone-time?falsesetyellow-encountered1setyellow-accepted1setblue-encountered1setblue-accepted1setblue-ratio11setyellow-ratio11setseq-update?falsesetlandscapeIDrandom-float1end;----setup-patches----;makesthebackgroundgreentosetup-patchesaskpatches[setpcolor57]end
33
;----setup-flowers----;initializescolor,shape,size,andlocationofflowerstospace-flowers;-----;;-------------adjustflowersintolab-environmentspacinggridaskflowers[ifelselab-flower-layout?=true[while[pxcormod5!=3orpycormod5!=0orany?otherflowers-here][setxyrandom-pxcorrandom-pycor];-----iflablayoutwanted,ensuresflowerplacedinavailablegridspots][while[any?otherflowersin-radius2=trueorany?hivesin-radius2=true];-----ifrandomlayoutwanted,ensuresflowersdon'toverlap[setxyrandom-pxcorrandom-pycor]]]endtosetup-flowers;-----createsfloweragentsset-default-shapeflowers"flower"create-flowersyellow-flower-count[;-----yellowflowerssetflower-type"f1"setxyrandom-pxcorrandom-pycorsetcoloryellowsetsize5setoccupied?truesetflower-nectar-contentyellow-energysetflower-handling-timeyellow-handling-time]setyellow-populationyellow-flower-countcreate-flowersblue-flower-count[;-----blueflowerssetflower-type"f2"setxyrandom-pxcorrandom-pycor;ifany?flowers-here[setxyrandom-pxcorrandom-pycor]setcolorbluesetsize5setoccupied?truesetflower-nectar-contentblue-energysetflower-handling-timeblue-handling-time]setblue-populationblue-flower-countend;----setup-bees----;initializescolor,shape,size,location,andvariablesofbeestosetup-beescreate-beesnumber-of-bees[setshape"bee2"setcolor45setsize4setxy0-20seton-flower?falsesettime-on-flower0;-----indicatesnotimehasbeenspentonflowertostartsethive-belongs-to1setbee-nectar-collected0setjust-landed?falsesetaccept-encounter?truesetflowers-in-viewflowerswith[self!=[last-flower]ofmyself]in-coneview-radiusview-degrees;-----addsflowerforinitialiationsetlast-flowerone-offlowers;-----choosesrandomfloweraslast-flowersovariableisn'temptyatstartsetchosen-flowerone-offlowerswith[self!=[last-flower]ofmyself];-----*chosen-flowersetnext-color[color]ofchosen-flowersetyellow-search-memory[10];-----addeddefaultnumbertolistssovariableisn'temptyatstartsetblue-search-memory[10];-----*setyellow-handling-memory[20];-----*setblue-handling-memory[20];-----*setyellow-energy-memory[10];-----*setblue-energy-memory[40];-----*setflower-landing-memory[1];-----*setlast-blue-time0;-----*setlast-yellow-time0;-----*setsampling?true;-----indicatesbeestartsinsamplingmodesetprey1blue;-----indicatesbeeconsidersblueasprey1tostartsetprey2yellow;-----indicatesbeeconsidersyellowasprey2tostartsetnextprey"both";-----indicatesbeecanvisitbothpreytypestostartsetPropNecBlue.5;-----50%nectarfrombluetostart
34
setPropNecYellow.5;-----50%nectarfromyellowtostartsetblue-accepted0setblue-encountered0setyellow-accepted0setyellow-encountered0setyellow-ratio11;-----indicates100%yellowencountersacceptedtostartsetblue-ratio11;-----indicates100%blueencountersacceptedtostart]end;----setup-hives----;initializescolor,shape,size,location...ofhivestosetup-hives;-----notincurrentuseifnumber-of-hives=1[;initializeallvaluesforasinglehivecreate-hives1[setshape"beehive"setcolor45setsize10setxy-500setheading0sethive-1selfsethive-nectar-content0]]ifnumber-of-hives=2[;initializeallvaluesforhive1create-hives1[setshape"beehive"setcolor45setsize10setxy5050setheading0sethive-1selfsethive-nectar-content0];initializeallvaluesforhive2create-hives1[setshape"beehive"setcolor45setsize10setxy-50-50setheading0sethive-2selfsethive-nectar-content0]]end;-------------------------------------------------------go-----------------------------------------------------------------------------------;setsthesimulationinmotiontogoifshow-radius?;-----debug:redrawrangeofdetect-flowerseachtimebeemoves[clear-patchesdraw-view]regenerate-flower-nectarmove-beesflowers-track-occupationset-labelstickifexport?[export-data];-----fordataoutput:exportdataifapplicablerequirementsmetendtodraw-view;-----;debug;drawsthebee'sviewrangeaskbees[askpatchesin-coneview-radius360with[distancemyself>(view-radius-1)][setpcolorgreen]askpatchesin-coneview-radiusview-degreeswith[distancemyself>(1)][setpcolorwhite]]endtomove-bees;-----;determineswhenbeesexecutecertainbehaviorsaskbees[ifon-flower?=false[bees-search-for-flower];-----;whilethebeeisnotonaflowercollectingnectar
35
ifon-flower?[bees-collect-nectar];-----;whilethebeeisonaflower]endtobees-search-for-flower;-----;directsbeesearchingbehaviorwhilenotonaflowersetflowers-in-viewflowerswith[self!=[last-flower]ofmyself]in-coneview-radiusview-degrees;-----updatesdetectedfloweragentsetifchosen-flower=NOBODY[bees-decide-next-flower];-----;-----endof"ifchosen-flower=NOBODY"sectionifany?flowers-in-view=falseorchosen-flower=NOBODY;-----ifthebeeseesnoflowersitmovesforwardrandomly[forward1rightrandom30leftrandom30]ifany?flowers-in-viewandchosen-flower!=NOBODY;whenthebeeseesthechosenfloweritheadstowardsit[setheadingtowardschosen-flowerifon-flower?=false[forward1]]ifany?flowers-here;-----whenthebeereachesthechosen-floweritsetsthevariableon-flower?totrue[ifelse[occupied?]ofone-offlowers-here=true;-----iffloweralreadyoccupied,moveon[forward1][ifelseone-offlowers-here=chosen-flower[;-----ifbeereachedchosen-flower,startcollectprocedure,elsecontinuetowardschosen-flowerseton-flower?trueforward0][forward1]]]endtobees-decide-next-flower;-----beedecideswhethertoacceptthenextencountersetlast-color[color]oflast-flowerifelserandom-flower?[;-----ifbeeshouldchoosearandomflowerindetectedfloweragentsetifany?flowers-in-view[setchosen-flowerone-offlowers-in-viewifbee-decision-type="prey-model"[;-----prey-model:ifchosenfloweriscorrectpreytype,beewillacceptencounterifelse[color]ofchosen-flower=next-color[setaccept-encounter?true][setaccept-encounter?false]ifnextprey="both"[setaccept-encounter?true];-----ifbeeisgeneralized/sampling,ensureschosenflowerwillbeaccepted]ifbee-decision-type="PropNec"[;-----PropNec:ifchosen-flowercolorhashigher%nectar,ensureacceptance.Iflower%nectar,P(visit)=f1/f2%chanceifelsePropNecBlue>=PropNecYellow[ifelse[color]ofchosen-flower=blue[setaccept-encounter?true][ifelserandom-float1<(PropNecYellow/PropNecBlue)[setaccept-encounter?true][setaccept-encounter?false]]][ifelse[color]ofchosen-flower=yellow[setaccept-encounter?true][ifelserandom-float1<(PropNecBlue/PropNecYellow)[setaccept-encounter?true][setaccept-encounter?false]]]]ifsampling?[setaccept-encounter?true];-----ifbeeinsamplingmode,ensuresacceptance]][setchosen-flowermin-one-offlowers-in-viewwith;-----random-flower?isfalse:beeselectsclosestflowerindetectedagentset[color=[next-color]ofmyselfandself!=[last-flower]ofmyself][distancemyself]]
36
endtobees-collect-nectar;-----directsbeecollectionbehaviorwhileonaflowerletthis-flowerone-offlowers-herebees-determine-memory-values;-----calculatesearchtimesformemorystorageupdate-memory;-----adjustmemorylistsifapplicablesetNectarGatheredbee-nectar-collected;-----updatemonitorwithnewnectaramountheldbee-decide-prey;-----beeupdatespreydecisionssetseq-update?true;-----graph:updatesequencegraphsetjust-landed?false;-----endsone-time-onlyportionofcalculationswhenbeeislandedifnotaccept-encounter?[settime-on-flower[flower-handling-time]ofthis-flower+1];-----ifbeeacceptedencounter,itmustwaitatthislocationfor(handling-time)tickssettime-on-flower(time-on-flower+1)ifthis-flower!=chosen-flower[seterror-visit-counterror-visit-count+1];-----debug:ifthisflowerwasn'tthechosen-flower,trackerroriflast-flower!=nobody[ifelse[color]oflast-flower!=[color]ofthis-flower[iftime-on-flower>=[flower-handling-time]ofthis-flower+SwitchCostPenalty;-----switchcost:iflastvisitedwasdifferentcolor,increasedbeepausetimerequired[askthis-flower[setflower-nectar-content0];-----askflowertodepletenectarheldletthis-distancedistancelast-flowersettravel-distanceslputthis-distancetravel-distances;-----updatelistofdistancestravelledsetlast-flowerthis-flowersetlast-flower1last-flowerseton-flower?falsesetchosen-flowerNOBODYbees-choose-colorsetswitch-countswitch-count+1settotal-counttotal-count+1settime-on-flower0forward2]][iftime-on-flower>=[flower-handling-time]ofthis-flower;-----switchcost:iflastvisitedwassamecolor,lesspausetimewasrequired[askthis-flower[setflower-nectar-content0]letthis-distancedistancelast-flowersettravel-distanceslputthis-distancetravel-distancessetlast-flowerthis-flowerseton-flower?falsesetchosen-flowerNOBODYbees-choose-colorsettotal-counttotal-count+1settime-on-flower0forward2]]]endtobees-determine-memory-valuesletthis-flowerone-offlowers-heresetthis-flower1this-flowersetjust-landed?true;-----ensurescertaintasksonlyoccuronce,atlanding(addingtomemorylists,etc)iftime-on-flower=0andlast-flower!=nobody[ifelse[color]ofthis-flower=[color]oflast-flower;-----adjustscolorstreakmonitorvariables[setsame-color-inarowsame-color-inarow+1][setsame-color-inarow0]if[color]ofthis-flower=yellow[letlast-search(ticks-last-yellow-time);-----calculatestimesincelastyellowflowervisitifhandling-time-mode="mutually-exclusive"[;-----ifmutually-exclusiveprey-model:subtracthandlingtimesofvisitedflowersofotherpreytypefromsearchtimeletyellow-tempflower-landing-memorywhile[lengthyellow-temp>1=true][ifelsefirstyellow-temp<last-yellow-time[setyellow-tempbut-firstyellow-temp];-----iftimestampearlierthanlast-yellow,removefromlist[setlast-searchlast-search-blue-handling-time;-----iftimestampbetweenlast-yellowandcurrent,subtractfromsearchtime,removefromlistsetyellow-tempbut-firstyellow-temp]]]setyellow-search-memorylputlast-searchyellow-search-memory;-----addsearchtimetoyellowsearchmemorysetlast-yellow-time(ticks+yellow-handling-time);-----setnewlast-yellow-time,adjustforhandlingtime
37
setyellow-encounteredyellow-encountered+1setyellow-ratio1yellow-accepted/yellow-encounteredifaccept-encounter?=true[;-----ifacceptingencounter:alsoaddcurrentflower'shandlingtime/energytomemorylistssetflower-landing-memorylputticksflower-landing-memorysetyellow-energy-memorylput[flower-nectar-content]ofthis-floweryellow-energy-memorysetyellow-handling-memorylput[flower-handling-time]ofthis-floweryellow-handling-memorysetyellow-acceptedyellow-accepted+1setyellow-ratio1yellow-accepted/yellow-encountered;-----updateaccepted/encounteredratioaftermemoryupdatesetbee-nectar-collected(bee-nectar-collected+[flower-nectar-content]ofthis-flower);-----addflower'snectarcontenttonectar-held]]if[color]ofthis-flower=blue[;-----repeatstimesincelastflowervisitcalculations,butforblueflowersletlast-search(ticks-last-blue-time)ifhandling-time-mode="mutually-exclusive"[;-----ifmutually-exclusiveprey-model:subtracthandlingtimesofvisitedflowersofotherpreytypefromsearchtimeletblue-tempflower-landing-memorywhile[lengthblue-temp>1=true][ifelsefirstblue-temp<last-blue-time[setblue-tempbut-firstblue-temp];-----iftimestampearlierthanlast-blue,removefromlist[setlast-searchlast-search-yellow-handling-time;-----iftimestampbetweenlast-blueandcurrent,subtractfromsearchtime,removefromlistsetblue-tempbut-firstblue-temp]]]setblue-search-memorylputlast-searchblue-search-memorysetlast-blue-time(ticks+blue-handling-time)setblue-encounteredblue-encountered+1setblue-ratio1blue-accepted/blue-encounteredifaccept-encounter?=true[;-----ifacceptingencounter:alsoaddcurrentflower'shandlingtime/energytomemorylistssetflower-landing-memorylputticksflower-landing-memorysetblue-energy-memorylput[flower-nectar-content]ofthis-flowerblue-energy-memorysetblue-handling-memorylput[flower-handling-time]ofthis-flowerblue-handling-memorysetblue-acceptedblue-accepted+1setblue-ratio1blue-accepted/blue-encounteredsetbee-nectar-collected(bee-nectar-collected+[flower-nectar-content]ofthis-flower);-----addflower'snectarcontenttonectar-held]ifaccept-encounter?=false[;-----debug:blueflowersshouldalwaysbeaccepted,ifnotthenerrorisloggedaskthis-flower[setcolorredsetsize10]export-interface(word"blue-not-accepted"bee-memory-length"-"bee-decision-type"-"random-float1.0".png")askthis-flower[setcolorbluesetsize5]]];-----endofsearchtimeadjustment/memorylistadditions]endtobees-choose-colorifnextprey="yellow"[ifelserandom100<resample-threshold[setnext-coloryellow][setnext-colorblue]]ifnextprey="blue"[ifelserandom100<resample-threshold[setnext-colorblue][setnext-coloryellow]]ifnextprey="both"[ifelserandom100<50[setnext-colorblue][setnext-coloryellow]]endtobees-deliver-nectar-to-hive;-----ifnectar-heldreachesbee-nectar-max,returntohiveandemptynectar-heldintohive(inactive)ifany?hives-here[askone-ofhives-here[sethive-nectar-content(hive-nectar-content+[bee-nectar-collected]ofmyself)setNectarGatheredNectarGathered+[bee-nectar-collected]ofmyself]setbee-nectar-collected0]ifhive-belongs-to=1[setheadingtowardshive-1ifany?hives-here=false[forward1]]ifhive-belongs-to=2[setheadingtowardshive-2ifany?hives-here=false[forward1]]endtoregenerate-flower-nectar;-----ifflowerunoccupiedandnectarlessthanmax,refillnectaraskflowers
38
[ifcolor=blue[ifflower-nectar-content<blue-energy[setflower-nectar-contentblue-energy]ifflower-nectar-content>blue-energy[setflower-nectar-contentblue-energy]setflower-handling-timeblue-handling-time]ifcolor=yellow[ifflower-nectar-content<yellow-energy[setflower-nectar-contentyellow-energy]ifflower-nectar-content<yellow-energy[setflower-nectar-contentyellow-energy]setflower-handling-timeyellow-handling-time]]endtoflowers-track-occupation;-----ifanybeesonflower,setoccupied?trueaskflowers[ifelseany?bees-here[setoccupied?true][setoccupied?false]]endtoset-labels;-----debug:changeagentlabelsifelsebee-nectar-label?[askbees[setlabelprecisionbee-nectar-collected3]][askbees[setlabel""]]ifelseflower-nectar-label?[askflowers[setlabelprecisionflower-nectar-content3]][askflowers[setlabel""]]ifelsehive-nectar-label?[askhives[setlabelprecisionhive-nectar-content3]][askhives[setlabel""]]ifbee-label?[ifbee-label-as="blue-search-times"[askbees[setlabelblue-search-memory]]ifbee-label-as="yellow-search-times"[askbees[setlabelyellow-search-memory]]]endtoupdate-memory;;--------memory-lengthbasedupdate-memory-Activeaskbees[;ifbee'smemorylistshaveanewnectaraddedto1stlistindexandit'slongerthanallowed,lastvalueremoved(independentfromeachother)iflengthyellow-energy-memory>bee-memory-length[setyellow-energy-memorybut-firstyellow-energy-memory]iflengthblue-energy-memory>bee-memory-length[setblue-energy-memorybut-firstblue-energy-memory]iflengthyellow-handling-memory>bee-memory-length[setyellow-handling-memorybut-firstyellow-handling-memory]iflengthblue-handling-memory>bee-memory-length[setblue-handling-memorybut-firstblue-handling-memory]iflengthyellow-search-memory>bee-memory-length[setyellow-search-memorybut-firstyellow-search-memory]iflengthblue-search-memory>bee-memory-length[setblue-search-memorybut-firstblue-search-memory]iflengthflower-landing-memory>50[setflower-landing-memorybut-firstflower-landing-memory]ifnotempty?blue-search-memory[setblue-search-meanmeanblue-search-memory];-----updatelistaveragesforOFTthresholdifempty?yellow-search-memory=false[setyellow-search-meanmeanyellow-search-memory]ifempty?yellow-handling-memory=false[setyellow-handling-meanmeanyellow-handling-memory]ifempty?blue-handling-memory=false[setblue-handling-meanmeanblue-handling-memory]ifempty?yellow-energy-memory=false[setyellow-energy-meanmeanyellow-energy-memory]ifempty?blue-energy-memory=false[setblue-energy-meanmeanblue-energy-memory]setsearch-threshold((blue-energy-mean*yellow-handling-mean)/yellow-energy-mean)-blue-handling-meanifsampling?andlengthblue-energy-memory>=bee-memory-lengthandlengthyellow-energy-memory>=bee-memory-length[;-----ifbothmemorylistsfull,endsamplingmodeexport-sampling-filessetticks-at-sampling-endticksifelseblue-search-mean>=search-threshold[setspecialized-at-sampling-end?false][setspecialized-at-sampling-end?true]setsampling?falsesetthreshold-switch-count0;-----resetaccepted/encounteredmonitorsnowthatsamplingendedsettotal-count0setblue-encountered0setblue-accepted0setyellow-encountered0setyellow-accepted0setNectarGathered0askbees[setbee-nectar-collected0]];ifbeevisitedenoughflowerstofillit'slist,nolongersamplingsetsearch-threshold((blue-energy-mean*yellow-handling-mean)/yellow-energy-mean)-blue-handling-mean;-----updatesearch-thresholdwithnewmemoryvaluesifnotempty?yellow-energy-memoryandnotempty?blue-energy-memory[;-----PropNec:update%valueswithnewmemoryvaluesletyesmeanyellow-energy-memoryletbesmeanblue-energy-memory
39
setPropNecYellowprecision(yes/(yes+bes))3setPropNecBlueprecision(bes/(yes+bes))3ifseq-update?=true[;-----graph:updatesequencegraphsifelse[color]oflast-flower=yellow[setlast-visit-yellow1setlast-visit-blue0setseq-update?false][setlast-visit-blue1setlast-visit-yellow0setseq-update?false]]]]endtobee-decide-preyifbee-decision-type="prey-model"[letyemyellow-energy-meanletyhmyellow-handling-meanletbemblue-energy-meanletbhmblue-handling-meanletlastpreynextpreyifelse(yem/yhm)>(bem/bhm);-----determinewhichflowercolorisprey1(bestchoice)[setprey1"yellow";-----ifyellowisprey1:setprey2"blue"ifelseyellow-search-mean>((yem*bhm/bem)-yhm);-----determineifbeeshouldgeneralizeorspecialize[setnextprey"both"][setnextprey"yellow"]][setprey1"blue";-----ifblueisprey1:setprey2"yellow"ifelseblue-search-mean>((bem*yhm/yem)-bhm);-----determineifbeeshouldgeneralizeorspecialize[setnextprey"both"][setnextprey"blue"]]iflastprey!=nextprey[setthreshold-switch-countthreshold-switch-count+1];-----ifgeneralize/specializechanged,increasethreshold-switch-countsetprey-1prey1setnext-preynextprey]ifbee-decision-type="PropNec"[;-----forPropNec:determinewhichpreytypehashigher%nectarinmemory,setasprey1letyesmeanyellow-energy-memoryletbesmeanblue-energy-memoryifelsebes>=yes[setprey1"blue"setprey2"yellow"][setprey1"yellow"setprey2"blue"]setprey-1prey1setnext-prey"NA"]endtosetup-export;-----createexportfileifonedoesn'texistsetsampling-file-name(wordexport-file-name"-sampling.csv")iffile-exists?sampling-file-name=false[create-sampling-files]iffile-exists?export-file-name=false[create-files]iffile-exists?export-file-name2=false[create-files2]iffile-exists?sampling-file-name=false[create-sampling-files]endtoexport-data;export-specific'foreverloop'procedure
40
;ifticks=1andcurrent-iteration=1[create-files];createoutputspreadsheet,addvariablenamesanddefinitiononceperexperimenttrial;ifticksmod(sim-iteration-length-1)=0[export-files];outputtotalvariablesattheendofeachiteration(totalnectargatheredbyhive1,etc)if(ticks-ticks-at-sampling-end)mod(sim-iteration-length-1)=0[export-files]endtocreate-files;initialoutputheadersandrelevantvariablesettingsatthestartofeachtrialletspacer","file-openexport-file-namefile-print(listspacer"Outputname:"spacerexport-file-namespacer"Date+TimeStarted:"spacerdate-and-timespacer)file-print(listspacer"NectarGathered"spacer"total-count"spacer"bee-decision-type"spacer"threshold-switch-count"spacer"yellow-energy"spacer"blue-energy"spacer"yellow-handling-time"spacer"blue-handling-time"spacer"yellow-flower-count"spacer"blue-flower-count"spacer"bee-memory-length"spacer"yellow-encountered"spacer"yellow-accepted"spacer"blue-encountered"spacer"blue-accepted"spacer"handling-time-mode"spacer"search-threshold"spacer"specialized-at-sampling-end?"spacer"world-name"spacer"landscapeID"spacer"ticks"spacer"ticks-at-sampling-end"spacer)file-closeendtocreate-files2;initialoutputheadersandrelevantvariablesettingsatthestartofeachtrialletspacer","file-openexport-file-name2file-print(listspacer"Outputname:"spacerexport-file-namespacer"Date+TimeStarted:"spacerdate-and-timespacer)file-print(listspacer"blue-handling-time:"spacerblue-handling-timespacer"yellow-handling-time:"spaceryellow-handling-timespacer"blue-energy:"spacerblue-energyspacer"yellow-energy:"spaceryellow-energy"yellow-flower-count:"spaceryellow-flower-countspacer"bee-memory-length:"spacerbee-memory-lengthspacer)file-print(listspacer"Blue-flower-count"spacer"Blue-search-mean"spacer"inequality"spacer)file-closeendtoexport-files2letspacer","letinequality(((blue-energy-mean*yellow-handling-mean)/yellow-energy-mean)-blue-handling-mean)file-openexport-file-name2file-print(listspacerblue-flower-countspacerblue-search-meanspacerinequalityspacer)file-closeendtoexport-files;-----attrialend,exportlistedvariablesintoanewspreadsheetrow,setnext-run?trueifnext-run?!=true[letspacer","letActualPVL(total-count-switch-count)/(total-count+1)letMeanTDmeantravel-distancesifelse[sampling?]ofbees=false[file-open(word"sampling-"export-file-name)][file-openexport-file-name]file-print(listspacerNectarGatheredspacertotal-countspacerbee-decision-typespacerthreshold-switch-countspaceryellow-energyspacerblue-energyspaceryellow-handling-timespacerblue-handling-timespaceryellow-flower-countspacerblue-flower-countspacerbee-memory-lengthspaceryellow-encounteredspaceryellow-acceptedspacerblue-encounteredspacerblue-acceptedspacerhandling-time-modespacersearch-thresholdspacerspecialized-at-sampling-end?spacerworld-namespacerlandscapeIDspacerticksspacerticks-at-sampling-endspacer)file-closeexport-interface(word"results"bee-memory-length"-"bee-decision-type"-"random-float1.0".png")ifexport-memory-lists?=true[export-lists]setnext-run?true]endtoexport-lists;-----exportentirememorylistsinseperatespreadsheet,ifneededifnext-run?!=true[letspacer","file-open(wordexport-file-name"-lists.csv")file-print(listspacerbee-decision-typespacerbee-memory-lengthspaceryellow-handling-timespacerlandscapeIDspacerworld-namespacer([blue-search-memory]ofbees)spacer)file-close]endtocreate-sampling-filesletspacer","file-opensampling-file-nameendtoexport-sampling-files;-----exportvariablesatsamplingendtoseperatespreadsheet,ifneededifnext-run?!=true[letspacer","file-opensampling-file-namefile-print(listspacersampling?spacerbee-memory-lengthspacerbee-decision-typespacerNectarGatheredspacertotal-countspaceryellow-encounteredspaceryellow-acceptedspacerblue-encounteredspacerblue-acceptedspacerthreshold-switch-countspaceryellow-energy-meanspacerblue-energy-meanspaceryellow-search-meanspacerblue-search-meanspacersearch-thresholdspacerspecialized?spacerlandscapeIDspacerworld-namespacer)]end
41
toupdate-label;changethebee'slabelduringthesimulationwiththedrop-downmenu'bee-label-as',allowsreal-timediagnosingifelsebee-label?[ifbee-label-as="blue-search-times"[askbees[setlabelblue-search-memory]]ifbee-label-as="yellow-search-times"[askbees[setlabelyellow-search-memory]]][askbees[setlabel""]]end