<<

Biodiversity Informatics, 6, 2009, pp. 5-17

AN EFFICIENT SEGMENTATION ALGORITHM FOR ENTITY INTERACTION EUGENECH’NG 1 School of Computing and Information Technology, The University of Wolverhampton Wulfruna Street, WV1 1SB, Wolverhampton, United Kingdom. Abstract .—The inventorying of biological diversity and studies in biocomplexity require the management of large electronic datasets of . While inventory has adopted structured electronic databases for some , the computer modelling of the functional interactionsbetweenbiologicalentitiesatalllevelsofisstillinthestageofdevelopment.One of the challenges for this type of modelling is the biotic interactions that occur between large datasets of entities represented as computer algorithms. In realtime simulation that models the bioticinteractionsoflargedatasets,theuseofcomputationalprocessingtimecouldbe extensive.Onewayofincreasingtheefficiencyofsuchsimulationistopartitionthelandscapeso thatentitiesneedonlytraverseitslocalforentitiesthatfallswithintheinteractionproximity. Thisarticlepresentsanefficientsegmentationalgorithmforbioticinteractionsforresearchrelated tothemodellingandsimulationofbiological. Key words.— artificial life, entity interaction, individualbased model, optimisation algorithms, segmentation. research studies the “variation of species level such as population, biocenosis lifeatalllevelsofbiologicalorganisation”(Gaston , and require controlled andSpicer2004)andisusedtoreferto“thewhole experiments of their environment. For example, range of activities traditionally connected with one may wish to project the impacts of future inventorying and studying living resources” increase in yearly mean temperature on an (Lévêque and Mounolou 2003). Such studies , or to attempt to computationally frequently encounter large datasets of biological introduceaninvasivespeciestoseeitseffectsona entities, especially in functional interactions population. In other cases, one may wish to between different levels of organisms and their increase the biological time and processes of a effects on the modifying and shaping of the virtualecosysteminordertopredictitsoutcomein environment.Asresearchinbiodiversitybecomes ahundredyears’time.Otherimportantneedsareto complex, computer modelling and simulation visualise,notbychartsandgraphsbutbyutilising become a necessary means for conducting interactive computer graphics, the realtime experiments so that questions that cannot be interaction of a biological in order to answered by traditional approaches may be observetheecosystemdynamics.Inanycase,there resolved through the use of technology. The is much to be explored in the mergence of feasibility of computer modelling of is computersandforbiodiversityresearch. amplified in studies in biocompexity, which is Traditionalmodellingindependedupon definedbyLévêqueandMounolouas“theresultof statistical and probabilistic procedures such as functionalinteractionsbetweenbiologicalentities, classification and regression trees, generalised at all levels of organization, and their biological, linear models, multivariate adaptive regression chemical,physicalandsocialenvironments”where splines, and artificial neural networks. According observationalstudiesofcomplexentitiesabovethe tosomecomparativestudies(Cairns2001,Miller and Franklin 2002, Muñoz and Felicísimo 2004), suchmethodsoftenproduceinconsistentresults.In correspondenceemail: [email protected]

5 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION the worst case, they are fraught with errors and applications of biology in our engineering inaccuraciesasfactorsconsideredcrucialareoften endeavors.” notbeingtakenintoaccount.Anumberofcritiques Most,ifnotallofArtificialLifebasedmodelling haverecentlyquestionedthevalidityofmodelling techniques are IndividualBased Models (IBMs) strategiesforpredictingthenaturaldistributionof and an extension of it called Evolutionary species. For example, a research review (Pearson IndividualBased Model (EIBM) (Bornhofen and andDawson2003)showedthatmanyfactorsother Lattaud 2006), or Agentbased models. Breckling than determine species distributions and et al. stated that ‘IBMs contrasts with common the dynamics of distribution changes. While ecologicalmodelswhichfrequentlyoperateonthe traditional approaches have been focused on the population level and represent a population as an identification of a species’ bioclimatic envelope, overall state, thereby specifying rules how the crucialfactorssuchasbioticinteractions(Connell overallstatechanges(Brecklingetal.2005). 1961,SilanderandAntonovics1982,Davisetal. IBMs was identified in a visionary article by 1998) and evolutionary change (Woodward 1990, Huston et al. (Huston et al. 1988) as a potential DavisandShaw2001,Thomasetal.2001)arenot model for simulating the effects of individual taken into account and therefore making variation,spatialprocesses,cumulativestress,and predictions erroneous and misleading. Species naturalcomplexitiesthataredifficultwithclassical dispersal is another factor that has been approaches: “individualbased models allow disregarded, Pearson and Dawson (Pearson and ecological modellers to investigate types of Dawson 2003) suggest that migration limitations questionsthathavebeendifficultorimpossibleto suchaslandscapebarriers,deforestation,andman address using the statevariable approach.” madecanobstructspeciesmovementand IndividualBased Models have been thoroughly should be taken into account in such models. As reviewed up to 1999 (Grimm 1999) and 2005 incorporating these factors into the procedures of (GrimmandRailsback2005)followedbyarecent traditional approaches is difficult, it becomes review of EIBM (Bornhofen and Lattaud 2006). necessarytoexplorenewapproachesforecological Another review of the approach have shown that modelling(Ch'ng2009). individualbased models can also benefit from Nature has intrinsic problemsolving principles conceptsinComplexAdaptiveSystems(Railsback and natureinspired design seems a potential area 2001). These novel modelling techniques could for discovering new methodology for research. potentiallyresolveissuesoutlinedearlier,suchas Theremaynotbeabetterwaytomodelbiological bioticinteraction,evolutionarychange,andspecies lifethantosimplymimicitsdesignsbyusingthe dispersal barriers. What distinguishes IBMs from algorithmicformattosimulatethevariouslevelsof other “individualoriented” models that complexities (molecular, species, ecosystem, and acknowledgetheindividuallevelinsomewaybut ). This synthesis of nature formulates still adhere mainly to the classical modelling algorithmsbyextractingnature’sprinciplerulesin paradigm?Therearefourcriterion:(1)thedegree order that biological organisms can be replicated to which the complexity of the individual's life withintheconfinesofvoltageandsilicon.Indeed, cycleisreflectedinthemodel;(2)whetherornot the aim of the experimental science of Artificial thedynamicsofresourcesusedbyindividualsare Life (Langton 1995) attempts to understand the explicitly represented; (3)whether real or integer mechanismsbehindlivingsystemsbysynthesising numbers are used to represent the size of a them so that the and functions of these population;and(4)theextenttowhichvariability systemsmaybeunderstoodandapplied.Oneofits among individuals of the same age is considered founders(Langton1990)statesthat“Byextending (UchmanskiJandV.1996,GrimmandRailsback the horizons of empirical research in biology 2005).Sincethephenomenonobserved beyond the territory currently circumscribed by inIBMsreflectsthatofecologicalsystems,three lifeasweknowit, the study of Artificial Life properties characterises them (Breckling et al. givesusaccesstotheoflifeasitcouldbe, 2005):(1)theydonotexistonthelevelofisolated anditiswithinthisvastlylargerdomainthatwe subsystems;(2)theyemergeonhigherlevelsasa must ground general theories of biology and in result of interactions of the subsystems; and (3) which we will discover novel and practical newpropertiesappearatonelevelofaand

6 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION arenotdeduciblefromtheobservationofthelower graphics (Snyder and Barr 1987, Deussen et al. levels units or compartments of the system. This 1998, Soler et al. 2003) but algorithms have not requiresthemodellingofindividualsratherthanat been formalised for improving the efficiency of the population level. Such techniques require the largeentityinteractions. modelling of individual biological life, including Data for managing and categorising their genotype, phenotype and dynamics. This largecollectionsofdataareavailable.Thesimplest implies the requirements for large computing perhapsisthearraydatastructure.Moreadvanced resourcesashundredsofthousandsofcalculations structuresarehierarchicaldatastructures,whichis areperformedforeachindividualastheyreactand based on recursive decomposition (Aho et al. interactwiththeirbioticandabioticenvironment. 1974). Well known hierarchical data structures If optimisation problems associated with these (Samet1984)usedinthescienceandengineering modelsareproperlydeveloped,newopportunities for efficient representation and improving for conservation planning, and execution are binary trees, quadtrees, and biodiversitymanagement,mitigationstrategiesand octrees. A tree in computer science terminology studies related to the understanding of emulatesatreestructure.Ithassetsoflinknodes demographicproblemscanbeinitiated. startingfromarootnodeandproceedsthroughthe Thisresearchattemptstosolveacriticalproblem childnodes(branch)andfinallytotheleafnodes associated with computational resources that is (finalnodes).Achildnodehasoneparentnodeand connected to artificial life, IBMs or agentbased a parent node may have zero to many nodes. A modellingofbiologicalsystemsatthespecieslevel binarytreecontainsonlytwochildnodesandisnot and the simulation of biotic interactions among suitable for partitioning terrains into equal parts large datasets of spatiallyexplicit sessile (wheretheratiois1).Quadtreeandoctreescontain organismsandasuggestedextensionforvagilelife onlyfourandeightnodesrespectively.Asweshall forms.Thefollowingsectionsexploreoptimisation soon see in the discussions, hierarchical data techniques and formulate logical methods for structures presents some problems for managing optimisingentityinteractions.Thepaperconcludes large indexes that have frequent changes. The with a discussion of the results and opportunities approach presented in this article uses a data forfuturework. structurethatisnonhierarchical.Itdividesterrains based on the square root of the number of OPTIMISATIONTECHNIQUES segments, S . The approach is flexible and is Unlikestatisticalmethods,whichusespixelsas abletosegmentalandscapeintoaninfinitenumber patch size of n meter of space to describe large of equal parts. The next section explores some communities of organisms on a landscape, new conceptsrelatedtotheefficiencyofsegmentation approaches require the modelling of individual logic. organisms and all its internal processes and external interactions. Experience tells us that the EXPLORINGTHELOGICOF modelling of biological life using computer SEGMENTATIONMETHODOLOGY algorithms requires large numbers of variables, Thesegmentationalgorithmpresentedhereisan algorithmic structures, and calculations. This is optimisation technique developed and applied for true even for a single entity. The availability of investigating a new approach of vegetation computing resources for simulation becomes an modellingforstudyingpalaeoenvironments(Ch'ng exponential challenge when biotic and abiotic andStone2006b,a,Ch'ng2009).Theoptimisation interactionsoccurandentitiesreproduce.Resource techniquetargetsnonbasedIBMsandagent bottleneckisaproblemthatrequiressolvingbefore basedmodels.Inotherwords,itdoesnotapplyto new modelling methods can see fruition. discrete environments such as Cellular Automata Unfortunately, a review of literature in the area (CA),E.g.,(Gutowitz1991,Ginotetal.2002).The yieldedlittleevidenceofsuchstudies.Schulzand IBMsmustbespatiallyexplicitandinacontinuous Reggiadevelopedamethodforpredictingnearest environment. The optimisation technique targets agent distances in artificial worlds (Schulz and sessile organisms (e.g., ) but can be easily Reggia 2002). Other methods are developed for extended to include vagile life forms (e.g., fish, representing complex outdoor scenes in computer

7 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION and insects) and is suggested in the Discussions section. The following paragraphs exploresegmentationlogics. In the ecosystem model, there are bound to be largenumbersofentityinteractions,bothaccessing andcompetingforresources.Theefficiencyofan optimisation technique will determine the computational speed of the simulation. In an algorithm,theentitiesareusuallystoredinasingle array, in more advanced simulation requiring constantinsertionanddeletion(birthsanddeaths) entitiesarestoredwithinac ollection datastructure. Inthesimulationcycle,eachentityaccessesevery other entity in the same collection to determine theirproximitiesforinteractionorcompetition.If entities are at proximity, interaction occurs. Therefore,ifthecollectioncontainstensimpletwo stateentities,everyentitywillhavetogothrough Figure1.InefficientMemoryIndices(MI). ten loops including itself for determining the proximity of other entities before computing the Collection Class Indices (CCI) 2 Thesecondconceptsegmentsthelandscapeinto interaction.Thisamountsto10 ,andifthereare different collection classes storing the indices of 1000 entities, the amount increases exponentially entities in each class (Figure 2). This is a better at 1000 2 = ,1 000,000 . In large landscapes and algorithmcomparedtothefirstsincethesegments actual models, vegetations could amount to inaterrainisfixedprovidedthelandscapeisnot thousandstohundredsofthousandsofplantswith continually being resegmented during the computable variables, algorithms and calculations simulation. However, different collection classes in each entity. This problem gives reason for increases memory and the need to traverse each developing optimisation techniques. In the initial collectionduringsimulationwastescomputational stagesofresearch,threetheoreticalconceptswere time. Furthermore, in each reproductive lifecycle, comparedfortheirefficiencies. eachcollectionhastobecheckedagainstthenew plants to determine which segment boundary it Memory Indices (MI) belongsto.CCIdiffersfromCellularAutomatabut The first concept requires that each entity isverysimilartotheInCell(PIC)method remembers the indices of nearby entities (Figure in(BithellandMacmillan2007). 1).Inthistechnique,eachentityaccessesonlythe indices in its memory for interaction and Segmentation Algorithm competition. The technique however, has serious The third technique is more efficient. In a limitations andisrestricted only to sessile IBMs. landscape,acanonlycompetewithadjacent We know that vegetation reproduces abundantly plantsatagiventimeandallotherplantsshouldbe duringthespringsummerseasonseachyear.Inthe discounted from the interaction. In theory, the simulation,whennewplantsarereproducedplant simulationtimeshoulddecreasewiththeincrease proximitiesintheentirecollectionwillhavetobe of landscape segments. We shall soon see the traversedandcomputedtodeterminewhichplants performanceofthetechnique. shouldbeinthememoryofotherplants.Andeach Figure 3a shows a landscape with groups of time a single plant dies the collection has to be plants where only intersecting plants are being traversed again to remove the index of the dead competedagainst.Intherealworld,computationis plant from the memory of nearby plants. This notaproblemsinceinteractionbetweenentitiesis becomes very slow as the number of plants parallelandoccurssimultaneously.However,since increases. every virtual plant is stored within an array in a computerprogram,traversalisrequiredto

8 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION

segment, 1= 12 = 1 .Thelandscapein b and c both contain 2 divisions with 4 segments, 2= 22 = 4 . Figure 3d contains 3 divisions with 9 segments 3= 32 = 9 . The number of divisionshasequalwidthandheight.Thevalueof the width and height of the landscape can be obtainedwith, w w = terrain divs S (1) hterrain Figure2.InefficientCollectionClassIndices(CCI). hdivs = S determinewhichplantis‘visible’forcompetition. Inasimulation,theidealcompetitionscenariofor segmentation in Figure 3a can be divided into 4 where wdivs and hdivs are respectively the segments where each plant needs only accessthe numberofdivisionsinthewidthandheightofthe otherplantsinitsownsegmentspace(shownin b). terrain. w and h arethesizeofthewidth Inadifficultsegmentationconditionat cwherethe terrain terrain sourceplant(largecircle)isneartoaboundaryor and height of the terrain. S is the number of overlaps the boundary of a segment space, the divisions which divides the terrain into w and sourceplantisrequiredtoaccessallotherplantsin divs neighbouring segment for thorough hdivs . interaction.Inthiscase,thebenefitsofsegmenting Constructing the segments requires an thelandscapearenotapparentasitisthesameas understandingofthe3Dcoordinatesystem,shown condition asinceplantswithintheentirecollection in Figure 4a. The origin of the axis lies at the is accessed. The benefits become apparent when centreoftheplanewithextensionsoftheaxisin the segments are increased (in d). The figure both the negative and positive directions. The illustratesthatahighersegmentationincreasesthe segmentation however, cannot begin from the speedoftheprogramsinceeachplantneedsonly originbutisoffsetinthenegative( -x,-y)direction access the plants within its segment space and starting from the ‘start’ position show in b. This adjacentsegmentspaces.Theonlyruleneededis means that segment 0 begins from the lower left that the size of a segment should not be smaller corner( -x, -y)andendsatthetoprightcorner( +x, thanthecanopyofatreewiththelargestdiameter. +y) at segment 15. The units ( -50, -25, 0, +25, SegmentingalandscapeinastandardDirectXor +50 )aregivenasanexampleandcanbereplaced OpenGL 3D coordinates is different from the 2D withanyotherunitswithequaldivisions.Basedon screencoordinatesystems.Themethoddeveloped thedivisionsofwidthat b,itisobservedthatwhen inthisresearchtargetstheDirectX3Dcoordinate j=0 , x=-50 ,when j=1 , x=25 ,when j=2 , x=0 ,and space but can be easily extended to include so on. This generates a graph at c where an OpenGL and 2D coordinate spaces. Segmentation equationofthelineisgiven(Eq.2), beginswithdivisions.Thenumberofdivisionscan befrom 1to∞ subjectto thelimits of computer w w f( j ) = j terrain − terrain memory.Thesegmentsarederivedfromthesquare S 2 (2) of the divisions with d= d2 = S , where d is the number of divisions and S is the number of segments. Figure 3a contains 1 division with 1

9 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION

Figure3.EfficientSegmentationLogic.Alandscapewith1segment(a),alandscapewith4segments(b),entity accessingothersegmentsforinteraction(c),andentityinteractionina9segmentsscenario(d). morethanthreenonexistentsegments.Thecorner where j is the segment junction, wterrain is the segmentsshouldnotaccessnotlessormorethan5 width of the terrain, and S is the number of nonexistent segments. The algorithm for divisions.Theequationoffsetsthefirstsegment(0) segregatingtheedgeandcornersegmentsisgiven from the origin to the ‘start’ position. A inListing2. pDivisions isthenumberofdivisions constructionoftheheightdivisionsusesthesame on the landscape, pNumOfSegment is the number equationreplacing wterrain with hterrain . of segments on the landscape. The rest are self In the algorithm, each segment is a rectangle explanatory. objectstoringitssizeandposition.Thealgorithm AUMLdiagramshowingtheclassrelationship instandardformatisgiveninListing1. divs isthe between the Segment and Vegetation is given in number of divisions, i and j are each division’s Figure 7. Every plant hasa unique VegetationID . index, wDiv and hDiv arethewidthandlengthof Within the plant, SegmentID defines the segment w h theplantisinandhasadefaultvalueof -1whenit eachsegmentdividedfrom terrain and terrain . is in the dormant stage. It is assigned when the S S seed is germinated as that is the beginning of Everyplantinitsownsegmentspaceaccessesits competition.The Segment objectcontainsaunique adjacent segment spaces. Figure 5a shows the SegmentID andanarrayof PlantIndices[ ] which index accessing pattern using a one dimensional storestheindexofeachplantwithintheboundary array. Tisthetargetsegmentwhereaplantresides. ofthesegmentrectangle.Theindexofaplantcan Theplantaccessesitsadjacentsegmentspacesfor onlybeinthe PlantIndices[ ]arrayofonesegment competition. The segmentation in b shows black at any given time. The pseudo code in Listing 3 colouredsegmentswithinthesafeframe(red).In c, showshowentitiesaremanagedduringsimulation the segment within the safe frame (blue arrows) time. safely accesses segments that exist whereas segments outside the safe frame (red arrows) OPTIMISATIONRESULTS accesses nonexistent segments and will generate Results from the segmentation algorithm errorsintheprogram. coveredintheprevioussectionwererecordedona This problem can be solved by preventing the 150m²terrainwithfivespeciesoftrees. left edge and corner segments from accessing Due to the nature of the simulation (large certain nonexisting segments. Figure 6 shows number and fluctuations of population), it is some instances of the patterns of nonexistent difficult to generate a comparison chart of the segmentswherethetargetsegmentshouldnothave increaseofthesegments( 1, 2, …, n)andforeach accessto.Thepatternillustratesthatdependingon case,thenumberoforganismsandthesimulation where the edge segment (orange) is located (top, speed.Thereforeacharthastobeshownforeach bottom,left,right),itshouldnotaccessnotlessor individual segmentation simulation.

10 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION

Figure4.Segmentationconstructionsin3Dcoordinatespace(a,b,andc).

Figure5.Theconceptofsafeframeinsegmentationalgorithm:Indexaccessingpatternusingonedimensional array(a),safeframewithblacknumbers(b),andframesaccessingnonexistentsegments(c). Atthestartofthesimulation,theinitialnumberof Acomparisonofthethreegraphsshowedthat treesis147distributedamongthespecies. there is significant increase in speed if the Three segmentation experiments were segmentation algorithm is applied. In Figure 9, conducted to compare the results using the same when the number of vegetation reaches its settings where vegetation reproduces up to a maximum at 140, the speed reaches only 180 maximum of 162 on one of the experiment. The millisecondsusing64segmentsascomparedtoan first segmentation test uses 1 segment for the averageof400millisecondsusingonly1segment landscape with a total of 162 at peak production (Figure8).Ifthesegmentsareincreasedto144,the over258years,thesecondandthirdpartitionedthe speed decreased to only an average of 100 terraininto64and144segmentsrespectively.The milliseconds with the same amount of vegetation 64 segments version produces 147 plants at its (Figure10). peakover263yearsandthe144segmentsversion Figure 11 is a comparison of efficiency of producesupto151duringitspeakover258years. segmentation between the three experiments. The Eventhoughthesettingsarethesameforallthree graph showed that the computational speed experiments,thenumberofvegetationproducedis increasessignificantlybetween1and64segments. different. This is due to the interaction among However, the increase in performance is not vegetation and the environmental variations apparentbetween64and144segments.Thisisdue affecting them. This however, does not to the small number of vegetation present in the significantly affect the results as comparison is landscape. The performance becomes obvious madebetweenthespeedandthenumberofplants whenthenumberofvegetationisgreatlyincreased produced(Figure811). neartheendofthegraph.Figure1213aregraphs

11 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION

Listing 1: 1. int n = 0; // segment number 2. for (int j = 0; j < divs; j++) // Rows (divided on Length) 3. { 4. for (int i = 0; i < divs; i++) // Columns (divided on Width) 5. { 6. x = (terrainWidth/divs)*i - terrainWidth/2; // Set the x position (Columns) 7. y = (terrainHeight/divs)*j - terrainHeight/2; // Set the y position (Rows) 8. 9. // Create a new segment 10. segment[n] = new Segment(x*2, y*2, wDiv*2, hDiv*2); 11. n += 1; // next segment 12. } 13.} Listing 2: 1. // Collect Segment Corners 2. pBottomLeftCorner = 0; 3. pBottomRightCorner = pDivisions-1; 4. pTopLeftCorner = pDivisions * (pDivisions-1); 5. pTopRightCorner = pNumOfSegment-1; 6. 7. // Collect Segment Edges 8. pLeftEdge = new int[pDivisions-2]; 9. pRightEdge = new int[pDivisions-2]; 10. 11.for (int i=0 ; i < pDivisions-2 ; i++) 12.{ 13. pLeftEdge[i] = (i+1) * pDivisions; 14. pRightEdge[i]= (pDivisions-1) + pDivisions * (i+1); 15.}

Listing 3: Initialise Simulation: Generate Segments Test all entities If entity is within segment Assign VegetationID to segment PlantIndices based on its location Assign SegmentID to each entity Simulation Cycle: Remove dead entities and assign new entities to segment Simulate entity interaction within proximity segments

Listing 4: Initialise Simulation: Generate Segments Test all entities If entity is within segment Assign VegetationID to segment PlantIndices based on its location Assign SegmentID to each entity Simulation Cycle: Remove dead entities and assign new entities to segment Assign vagile entities to segment and assign SegmentID to vagile entities Simulate entity interaction within proximity segments Simulate interaction for vagile entities (viewable entities within segment)

12 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION comparingsegmentationresultsofanenvironment Tests conducted in a larger landscape with usingthesamelandscape.Vegetationisamixture thousandsofplantsaveraging13,594alsoshowed of trees and herbaceous plants totalling 203 in a significant increase in simulation speed (Figure number at the start of the simulation. The 1213). When plants in the landscape reached a herbaceous plants are used because the rate of population of 12,000, the 144 segments yielded ismuchfasterthanthetrees.The64 300k milliseconds as compared to 700k segments version produces 14,795 plants at its millisecondsusingthe64segmentsversion. peakover23yearsandthe144segmentsversion The experiments were conducted on sessile entities.Butanadditionalcycleinthesimulation willenablehighlyvagileentitiestobeincludedin the system. The bold lines in Listing 4 show the extension. Vagile entities may require a separate collection class from the static entities and the interactionshouldbeafterthestaticentitieshave been processed. Static objectsareat priority. For example, the seeds of plants should be produced first before predators have access to them, trees should first appear before habitats are made available,andetc. Hierarchical data structures such as quadtrees Figure6.Accessingnonexistentsegments. and octrees may have potential solution for such produces up to 12,393 during its peak over 33 problems. But they will need to be tested. years.Thecomparisonshowsasignificantincrease Hierarchical data structures divide a space into in performance using 144 segments. When the equalparts.Quadtreesdivideaspaceorthesubset number of plants increases to around 12,000 ofaspaceintofourequalpartsthatarestoredas (Figure 13), the speed decreases to only 300,000 nodeswhileoctreesdivideaspaceintoeightequal milliseconds as compared to 64 segments at parts. Apart from that, the two structures are 700,000milliseconds. essentially the same and achieve the same objective. These structures are found to be very DISCUSSION efficientinaspacethatcontainsentitiesthatdonot The implementation of an efficient go through large and frequent changes such as segmentation algorithm will greatly reduce thousands of addition, deletion, interaction and simulationtimeinstudiesdealingwithlargereal movement in one simulation cycle. They are time datasets, such as the modelling of frequently used in computer graphics and biocompexity where biotic interaction plays a visualisation. When there are large changes, it is major role in the dynamics of the system. The predicted that the restructuring and traversing of results in the study confirm that the use of the the nodes will increase the simulation time. The segmentationalgorithmtodividethelandscapeand simulationcycleinListing3and4showasimple the devising of a strategy for managing entity breadthtraversal of the segments for both sessile interaction greatly speeds up the simulation, with and vagile entities. Hierarchical data structures anincreaseof>40%inallcases. requireadditionalstepsineachcycletorebuildthe The finding suggests that increasing the nodes when entities die and new entities are segmentationdecreasesthespeedofsimulationin produced. Furthermore, entities need to traverse all studies. In the first test, (Figure 810), three boththebreadthanddepthofthenodesinorderto scenarios with segments 1, 64, and 144 were determine their interaction proximity. In theory, compared. The number of plants in all three suchstructuresshouldnothavesignificantincrease scenarios averaged 153. The results showed that inspeed,buttestsshouldbecarriedoutinfuture the speed of simulation doubles from 400ms to work. There is much to be explored as far as 180ms if 64 segments were applied. If 144 efficient algorithms for entity interaction is segments were applied, the speed decreases from concerned. The algorithms have produced 400msto100ms. significantresultsforpotentialinteractionamong

13 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION

Figure7.AUMLdiagramillustratingtherelationshipbetweentheclassVegetationandSegment.

Figure8.Experimentalresultsusing1segmentonthelandscape.Theimageshowsthespeedofsimulation(the graphwithhighfluctuationsatbottom)andthenumberofplants(thegraphonthetop).

Figure9. Experimentalresultsusing64segmentsonthelandscape.

Figure10.Experimentalresultsusing144segmentsonthelandscape.

14 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION

Figure11.Acomparisonoftheefficiencyofsegmentationsbetweentheexperiments.Solidlinesshowthe averagespeedofsimulationanddashedlinesofapalershadeshowitscorrespondingplantpopulation.

Figure12.Thecomparisonofefficiencyofsegmentationbetweenexperiments(64segments).

Figure13.Thecomparisonofefficiencyofsegmentationbetweenexperiments(144segments).

15 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION

thousands of entities. When vagile life forms are Davis,M.B.andR.G.Shaw.2001.RangeShiftsand introduced, more efficient techniques will be AdaptiveResponsestoQuaternaryClimateChange. required. In future work, High Performance Science 292 :673679. Computing with hundreds of nodes of computer Deussen,O.,P.Hanrahan,B.Lintermann,R.Mech,M. clusters is essential to support the calculations Pharr, and P. Prusinkiewicz. 1998. Realistic modeling and rendering of plant ecosystems. in involved in biotic and abiotic interactions. ProceedingsofSIGGRAPH'98AnnualConference Researchisunderwaytomakethisareality. Series1998.ACMPress. Gaston, K. J. and J. I. Spicer. 2004. Biodiversity: an REFERENCES introduction. Blackwell Publishing (2nd Ed.), Aho,A.V.,J.E.Hopcroft,andJ.D.Ullman.1974.The Oxford. Design and Analysis of Computer Algorithms. Ginot, V., C. Le Page, and S. Souissi. 2002. A multi AddisonWesley,Reading,Mass. agentsarchitecturetoenhanceenduserindividual Bithell, M. and W. D. Macmillan. 2007. Escape from basedmodelling.EcologicalModelling 157 :2341. the Cell: Spatially explicit modelling with and Grimm, V. 1999. Ten years of individualbased withoutgrids.EcologicalModelling 200 :5978. modeling in ecology: what have we learned and Bornhofen, S. and C. Lattaud. 2006. Outlines of what could we learn in the future? Ecological Artificial Life : A Brief History of Evolutionary Modelling 56 :221224. Individual Based Models. Lecture Notes in Grimm,V.andS.F.Railsback.2005.Individualbased ComputerScience,SpringerVerlag 3871 :226237. ModelingandEcology.PrincetonUniversityPress, Breckling,B.,F.Müller,H.Reuter,F.Hölker,and O. Princeton,NewJersey. Fränzle. 2005. Emergent properties in individual Gutowitz, H. 1991. Cellular automata: Theory and basedecologicalmodels–introducingcasestudies experiment.PhysicaD 45 :13. in an ecosystem research context. Ecological Huston, M., D. Deangelis, and W. Post. 1988. New Modelling 186 :376388. computer models unify ecological theory. Cairns, D. M. 2001. A Comparison of Methods for Bioscience 38 :682692. PredictingVegetation.PlantEcology 156 :318. Langton, C. G. 1990. Artificial Life. AddisonWesley Ch'ng, E. 2009. An Artificial LifeBased Vegetation LongmanPublishingCo.,Inc.,Boston,MA. Modelling Approach for Biodiversity Research. in Langton, C. G., editor. 1995. Artificial Life: An R. Chiong, editor. to appear in NatureInspired Overview.MITPress,Cambridge. informatics for Intelligent Applications and Lévêque, C. and J. C. Mounolou. 2003. Biodiversity. Knowledge Discovery: Implications in Business, JohnWiley&Sons,Ltd.,Chichester,WestSussex. ScienceandEngineering.IGIGlobal,Hershey,PA. Miller, J. and J. Franklin. 2002. Modeling the Ch'ng, E. and R. J. Stone. 2006a. 3D Archaeological distribution of four vegetation alliances using ReconstructionandVisualization:AnArtificialLife generalized linear models and classification trees Model for Determining Vegetation Dispersal with spatial dependence. Ecological Modelling Patterns in Ancient Landscapes. Pp. 112118.in 157 :227247. Computer Graphics, Imaging and Visualization Muñoz,J.andÁ.M.B.Felicísimo.2004.Comparison (CGiV). IEEE Computer Society, Sydney, ofstatisticalmethodscommonlyusedinpredictive Australia. modelling. Journal of Vegetation Science 15 :285 Ch'ng, E. and R. J. Stone. 2006b. Enhancing Virtual 292. Reality with Artificial Life: Reconstructing a Pearson,R.G.andT.P.Dawson.2003.Predictingthe FloodedEuropeanMesolithicLandscape.Presence: impacts of climate change on the distribution of Teleoperators and Virtual Environments 15 :341 species: are bioclimate envelope models useful? 352. GlobalEcology& 12 :361371. Connell, J. H. 1961. The influence of interspecific Railsback,S.F.2001.Conceptsfromcomplexadaptive competitionandotherfactorsonthedistributionof systems as a framework for individualbased thebarnacleChthamalusstellatus.Ecology 42 :710 modelling.EcologicalModelling 139 :4762. 723. Samet,H.1984.TheQuadtreeandRelatedHierarchical Davis, A. J., L. S. Jenkinson, J. H. Lawton, B. DataStructures.ComputerSurveys,ACM 16 . Shorrocks, and S. Wood. 1998. Making mistakes Schulz, R. and J. A. Reggia. 2002. Predicting Nearest whenpredictingshiftsinspeciesrangeinresponse AgentDistancesinArtificialWorlds.ArtificialLife toglobalwarming.Nature 391 :783786. 8:247264. Silander, J. A. and J. Antonovics. 1982. Analysis of interspecific interactions in a coastal plant

16 CH’NG.–ANEFFICIENTSEGMENTATIONALGORITHMFORENTITYINTERACTION

community a perturbation approach. Nature Uchmanski J and G. V. 1996. Individualbased 298 :557560. modelling in ecology: what makes the difference? Snyder, J. M. and A. H. Barr. 1987. Ray tracing TrendsinEcology& 11 :437441. complex models containing surface tessellations. Woodward,F.I.1990.Theimpactoflowtemperatures Pages110SIGGRAPH'87Proceedings.ACM. in controlling the geographical distribution of Soler, C., F. X. XSillion, F. Blaise, and P. Dereffye. plants. Philosophical Transactions of the Royal 2003. An Efficient Instantiation Algorithm for Society of London, Series B, Biological Sciences Simulating Radiant Transfer in Plant 326 :585593. Models. ACM Transactions on Graphics 11 :204 233. Thomas, C. D., E. J. Bodsworth, R. J. Wilson, A. D. Simmons, Z. G. Davies, M. Musche, and L. Conradt. 2001. Ecological and evolutionary processes at expanding range margins. Nature 411 :577581.

17