@title = Rabbit Espacial @author = Alessandro Ribeiro Campos, Juliana Leroy Davis, William Leles Souza Costa e Britraldo Silveira Soares Filho @organization = UFMG/IGC Análise e Modelagem de Sistemas Ambientais @metaversion = 2.15 @description = A spatially-explicit agent-based model designed to represent interactions between a rabbit population and the environment. The model simulates agents'movements, internal states, spatial distribution, and demographic features. Several scenarios were run to analyze the responses of agents to changes in their environment. @showproperties = no @date = Fri Feb 15 09:57:15 2013 @version = 2.0.6.20130201 @submodel.import = CalculateGiniCoefficientMap Script {{ // Input parameters of the model @collapsed = no @alias = Parameters Group {{ // Initial population of agents initialPopulationOfAgents := Int 201; // Rabbit's vision @alias = Rabbit's Vision rabbitSVision := Int 3; // Energy spent to move (10) and survive (10) energySpentToMove := Int 20; // Energy spent to survive energySpentToSurvive := Int 10; // Maximum Birth rate maximumBirthRate := Percent 0.0323; // Average lifespan averageLifespan := Int 36; // Initial amount of calories in agent’s stock @alias = Initial amount of calories in agent’s stock initialAmountOfCaloriesInAgentSStock := Int 50; // Variance of death function varianceOfDeathFunction := Int 4; // Recovery rate of the landscape recoveryRateOfTheLandscape := Double 0.1; }}; // Inputs @collapsed = no @alias = Inputs Group {{ // Type: group to which the agent belongs. // // === // Types of rabbits according to Maximum absorption of energy of each group. typesOfRabbits := LookupTable [ "Tipo" "Caloria", 1 17, 2 19 .. 4 25 ]; // Initial landscape map initialLandsacapeMap := LoadMap { filename = "../../../originais/recurso_coelhos_homogeneo.tif", loadAsSparse = .no, defineNullValue = .no, nullValue = 255, suffixDigits = 0, step = .none, workdir = .none }; }}; // Creates: Initial population of agents map, rabbit's energy stock (calories) // table and rabbit's age table @collapsed = yes @alias = Rabbits Start Group {{ // Creates initial probability map @collapsed = yes initialProbability := CalculateCategoricalMap { expression = [ if not isNull(i1) then 100 else null ], cellType = .uint8, nullValue = 255, resultIsSparse = .no, resultFormat = .none } {{ // initial probability map @alias = initial probability map NumberMap initialLandsacapeMap 1; }}; // Empty map @collapsed = yes extendRabbits := CalculateCategoricalMap { expression = [ if not isNull(i1) then 0 else null ], cellType = .uint16, nullValue = 65535, resultIsSparse = .no, resultFormat = .none } {{ // empty map NumberMap initialLandsacapeMap 1; }}; // Creates Initial population of agents @collapsed = no @alias = Creates Initial population of agents Repeat initialPopulationOfAgents {{ probability := MuxCategoricalMap initialProbability newProbabilityMap; rabbit := MuxCategoricalMap extendRabbits rabbits; // Creates Initial population of agents // // === // Creates pixels representing rabbits, according to the probability map rabbits _ _ := Patcher { landscape = rabbit, probabilities = probability, changes = [ 0->1 1 ], transitionParameters = [ 0->1 10000 0 1 ], neighborWindowLines = 3, neighborWindowColumns = 3, pruneFactor = 10 }; // rabbit's region according to the vision @collapsed = yes @alias = Rabbit's region rabbitSRegion := CalculateCategoricalMap { expression = [ nbMax(i1, v1, v1) ], cellType = .uint8, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit created @alias = Rabbit NumberMap rabbits 1; // rabbit's Vision @alias = Vision rabbit NumberValue rabbitSVision 1; }}; // Exclude rabbit's region out of the probability map @collapsed = yes newProbabilityMap := CalculateCategoricalMap { expression = [ if not isNull(i1) then null else i2 ], cellType = .int32, nullValue = 0, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitSRegion 1; // Probability map @alias = Probability map NumberMap probability 2; }}; }}; // Creates Binary map of rabbits @collapsed = yes binaryMapOfRabbits := CalculateCategoricalMap { expression = [ if i1 = 1 then 1 else null ], cellType = .uint16, nullValue = 65535, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbit 1; }}; // Assigns label to rabbits // // === // Creates an identifier for the rabbits calcRabbitLabel := CalcPatchLabelMap { source = binaryMapOfRabbits, initialPatchLabel = 1, onlyOrthogonalsAreAllowed = .no, windowLines = 3, windowColumns = 3, cellType = .uint16, nullValue = 65535, patchLabelsAreSparse = .yes }; extractMapValues701 _ _ := ExtractMapValues calcRabbitLabel .no; // Assigns types to Initial population of agents @collapsed = yes @alias = Types of Rabbits Group {{ @viewer.attributes = yes extractLookupTableAttributes2100 := ExtractLookupTableAttributes { table = typesOfRabbits, extractStatisticalKeyAttributes = .no, extractStatisticalValueAttributes = .no, extractDynamicKeyValueAttributes = .no }; // Types // // === // Extract the number of types of rabbits of the input table parameter type and // the Maximum absorption of energy of each type @collapsed = yes @viewer.calculated = yes types := CalculateValue { expression = [ t1[1] ], useDefaultValue = .no, defaultValue = 0 } {{ // Attributes NumberTable extractLookupTableAttributes2100 1; }}; // Initial population of agents Table base @alias = Initial population of agents @viewer.result = yes initialPopulationOfAgents0 := CreateLookupTable { initialKey = 1, finalKey = initialPopulationOfAgents, initialValue = 0, finalValue = 0, increment = 1, keyName = "Key", valueName = "Value" }; // Types of Initial population of agents // // === // Creates the table of Types of Initial population of agents @collapsed = yes @viewer.result = yes typesOfInitialPopulationOfAgents := CalculateLookupTable { expression = [ t1[line] + round(rUniform(1, v1)) ], keyName = .none, valueName = .none } {{ // Tabela Inicial NumberTable initialPopulationOfAgents0 1; NumberValue types 1; }}; }}; // Creates rabbit's energy stock(calories) table @collapsed = yes initialTableOfCalories := CalculateLookupTable { expression = [ v1 ], keyName = .none, valueName = .none } {{ // Rabbit label @alias = Rabbit label NumberTable extractMapValues701 1; // Initial amount of calories in agent’s stock NumberValue initialAmountOfCaloriesInAgentSStock 1; }}; // Creates rabbit's age table @collapsed = yes initialTableOfAge := CalculateLookupTable { expression = [ 0 ], keyName = .none, valueName = .none } {{ // Rabbit label @alias = Rabbit label NumberTable extractMapValues701 1; }}; // Save Initial population of agents map @alias = Initial rabbit map SaveMap { map = calcRabbitLabel, filename = "../../../Downloads/CoelhosInicial.ers", suffixDigits = 2, step = .none, useCompression = .yes, workdir = .none }; }}; // Movement, Consumption, Death @collapsed = no @alias = Iterations Repeat 20 {{ step = step; landscapeMap := MuxMap initialLandsacapeMap resourceMap1; @alias = Step step0 := Step step; rabbitMap := MuxCategoricalMap calcRabbitLabel rabbitMap3; // Table of calories per time step tableOfCalories := MuxLookupTable initialTableOfCalories lookupTableJunction1060; // Number of rabbits according tp the type typesRabbits := MuxLookupTable typesOfInitialPopulationOfAgents typesRabbits1; // Rabbitsborn per time step rabbitsBorn := MuxLookupTable [ "Key" "Value" ] rabbitsBorn0; // Birth rate per time step birthRate := MuxLookupTable [ "Key" "Value" ] birthRate0; // Rabbit's birth, rabbit's typification, rabbit's energy stock @collapsed = yes @alias = Birth Group {{ // Rabbit's birth @collapsed = yes @alias = Create rabbits Group {{ extractMapAttributes1169 := ExtractMapAttributes { map = initialLandsacapeMap, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; extractMapAttributes1172 := ExtractMapAttributes { map = landscapeMap, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; // Calculate log function of birth rate @collapsed = yes calcBirthRate := CalculateValue { expression = [ t2[12] / t1[12] * v1 ], useDefaultValue = .yes, defaultValue = 0 } {{ // Initial lanscape map @alias = Initial lanscape map NumberTable extractMapAttributes1169 1; // Landscape map @alias = Landscape map NumberTable extractMapAttributes1172 2; // Maximum Birth rate @alias = Maximum Birth rate NumberValue maximumBirthRate 1; }}; extractMapAttributes1042 := ExtractMapAttributes { map = rabbitMap, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; // Calculate birth rate according normal distribution @collapsed = yes @alias = Calc Birth Rate calcBirthRate0 := CalculateValue { expression = [ rNormal(v1, 0.001) ], useDefaultValue = .no, defaultValue = 0 } {{ // Birth rate @alias = Birth rate NumberValue calcBirthRate 1; }}; // Calculate the number of rabbits to be born @collapsed = yes rabbitsToBeBorn := CalculateValue { expression = [ ceil(t1[9] * v1) ], useDefaultValue = .yes, defaultValue = 0 } {{ // Number rabbits @alias = Number rabbits NumberTable extractMapAttributes1042 1; // Birth rate @alias = Birth rate NumberValue calcBirthRate0 1; }}; // Transition matrix transitionMatrix := SetLookupTableValue { table = [ "Key" "Value" ], key = 0.001, value = rabbitsToBeBorn }; // Calc probablility map excluding cells with rabbits @collapsed = yes calcProbability := CalculateCategoricalMap { expression = [ if not isNull(i1) then null else 100 ], cellType = .uint8, nullValue = 0, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap 1; }}; patcher1052 _ _ := Patcher { landscape = extendRabbits, probabilities = calcProbability, changes = transitionMatrix, transitionParameters = [ 0->1 100 0 0 ], neighborWindowLines = 1, neighborWindowColumns = 1, pruneFactor = 10 }; bool633 := Bool .yes; // Accumulate birth rates of each step time @alias = Birth rate birthRate0 := SetLookupTableValue { table = birthRate, key = step0, value = calcBirthRate0 }; // Calculate new rabbits map // // === // Cancel cells without rabbits to assign label to the born rabbits @collapsed = yes calcRabbitsMap := CalculateCategoricalMap { expression = [ if i1 = 0 then null else 1 ], cellType = .uint16, nullValue = 65535, resultIsSparse = .no, resultFormat = .none } {{ // Rabbits map @alias = Rabbits map NumberMap patcher1052 1; }}; // Calculate the last label of rabbit map // // === // Extracts the greatest value raster and adds 1 . If no rabbit in raster, the // value 0 will be passed to the Patcher. @collapsed = yes calcLastLabel := CalculateValue { expression = [ t1[11] + 1 ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractMapAttributes1042 1; }}; }}; // Join new rabbits and rabbit's population @collapsed = yes @alias = Join rabbits Group {{ calcPatchLabelMap614 := CalcPatchLabelMap { source = calcRabbitsMap, initialPatchLabel = calcLastLabel, onlyOrthogonalsAreAllowed = .no, windowLines = 1, windowColumns = 1, cellType = .int32, nullValue = .default, patchLabelsAreSparse = .yes }; bool635 := Bool bool633; // Join new rabbits to rabbit's population of the current step @collapsed = no @alias = Join new rabbits and rabbit's population joinNewRabbitsAndRabbitSPopulation := CalculateCategoricalMap { expression = [ if not isNull(i2) then i2 else i1 ], cellType = .uint16, nullValue = 65535, resultIsSparse = .no, resultFormat = .none } {{ // New rabbits @alias = New rabbits NumberMap calcPatchLabelMap614 1; // Rabbit map @alias = Rabbit map NumberMap rabbitMap 2; }}; }}; // Update rabbit's types and energy stock (calories) @collapsed = yes @alias = Update stocks Group {{ extractMapAttributes1481 := ExtractMapAttributes { map = calcPatchLabelMap614, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; extractMapValues647 _ _ := ExtractMapValues calcPatchLabelMap614 .yes; // Calculate the number of rabbits born at the step time @collapsed = yes calcRabbitsBorn := CalculateValue { expression = [ t1[9] ], useDefaultValue = .no, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractMapAttributes1481 1; }}; // Create stock of energy( calories) to the rabbits born at the time step // // === // Adds the label of born rabbits to energy stock with the value of 50 calories. @collapsed = yes @alias = Table of calories tableOfCalories0 := CalculateLookupTable { expression = [ v1 ], keyName = .none, valueName = .none } {{ // Rabbit label @alias = Rabbit label NumberTable extractMapValues647 1; // Initial amount of calories in agent’s stock @alias = Initial amount of calories in agent’s stock NumberValue initialAmountOfCaloriesInAgentSStock 1; }}; // Calculate the type of rabbits @collapsed = yes @alias = Calc type of rabbit Group {{ extractMapAttributes1209 := ExtractMapAttributes { map = rabbitMap, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; // Account rabbits according to types @collapsed = yes @alias = Accout rabbits types Group {{ // Calculate the number of rabbits per type ForEach typesOfRabbits .yes {{ step1 = step; type := Step step1; // Select type of rabbit @collapsed = no selectTypeOfRabbit := CalculateLookupTable { expression = [ if t1[line] = v1 then 1 else null ], keyName = .none, valueName = .none } {{ // Number of rabbits according to the type @alias = Types rabbits NumberTable typesRabbits 1; // Type @alias = Type NumberValue type 1; }}; extractLookupTableAttributes1179 := ExtractLookupTableAttributes { table = selectTypeOfRabbit, extractStatisticalKeyAttributes = .no, extractStatisticalValueAttributes = .no, extractDynamicKeyValueAttributes = .yes }; countTypes := MuxLookupTable [ "Key" "Value" ] tableOfRabbitsTypes; // Account rabbits by selected type @collapsed = no accountRabbitsTypes := CalculateValue { expression = [ if not isNull(t1[31]) then t1[31] else 0 ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractLookupTableAttributes1179 1; }}; // Accumulate the number of rabbits types per step time tableOfRabbitsTypes := SetLookupTableValue { table = countTypes, key = type, value = accountRabbitsTypes }; }}; ForEach typesOfRabbits .yes {{ step2 = step; @alias = Count types countTypes0 := MuxLookupTable [ "Key" "Value" ] typeTable; @alias = Step step3 := Step step2; // Cumulative frequency of Rabbits types @collapsed = no cumulativeFrequency := CalculateValue { expression = [ if v1 = 1 then t1[v1] else t1[v1] + t2[v1 - 1] ], useDefaultValue = .no, defaultValue = 0 } {{ // Number of rabbits per type NumberTable tableOfRabbitsTypes 1; NumberTable countTypes0 2; // Rabbit type NumberValue step3 1; }}; // Number of rabbits per type table establishing the ranges of the types typeTable := SetLookupTableValue { table = countTypes0, key = step3, value = cumulativeFrequency }; }}; }}; // Uniform probability to types distribuition @collapsed = yes calcRUniform := CalculateLookupTable { expression = [ round(rUniform(1, t1[9])) ], keyName = .none, valueName = .none } {{ // Number rabbits @alias = Number rabbits NumberTable extractMapAttributes1209 1; }}; // Calculate the type of the rabbit @collapsed = yes calcTypeOfRabbbit := CalculateLookupTable { expression = [ if t1[line] <= t2[1] then 1 else if t1[line] > t2[1] and t1[line] <= t2[2] then 2 else if t1[line] > t2[2] and t1[line] <= t2[3] then 3 else if t1[line] > t2[3] and t1[line] <= t2[4] then 4 else null ], keyName = .none, valueName = .none } {{ // Sort @alias = Sort NumberTable calcRUniform 1; // Thresholds @alias = Thresholds NumberTable typeTable 2; }}; }}; // Accumulate the number of rabbits born per step time @alias = Rabbits born rabbitsBorn0 := SetLookupTableValue { table = rabbitsBorn, key = step0, value = calcRabbitsBorn }; // Adds boirn rabbits to energy stock (calories) @alias = Table of calories tableOfCalories1 := CalcLookupTableUnion { firstTable = tableOfCalories, secondTable = tableOfCalories0, useFirstTableToSolveDuplicatedKey = .yes }; _ := Bool bool635; // Update types rabbits stock @alias = Types rabbits typesRabbits0 := CalcLookupTableUnion { firstTable = typesRabbits, secondTable = calcTypeOfRabbbit, useFirstTableToSolveDuplicatedKey = .yes }; }}; }}; // Rabbit movement @collapsed = yes @alias = Movement Group {{ // Define vision area of the rabbits // // === // Creates the search field of each rabbit, based on a 3x3 neighborhood (vision). // This field will define the search area for better target cells, ie, those with // the greatest amount of resources within the vicinity of the rabbit. @collapsed = yes @alias = Define region Group {{ // Calculate vision area of the rabbits @collapsed = yes defineRegion := CalculateCategoricalMap { expression = [ nbMax(i1, v1, v1) ], cellType = .int32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap joinNewRabbitsAndRabbitSPopulation 1; // Rabbit vision @alias = Rabbit vision NumberValue rabbitSVision 1; }}; bool1813 := Bool .yes; // Creating neighborhood to disappeared rabbits. // // === // It was identified that when a rabbit is between (directly) two other rabbits or // between a rabbit and the limit of raster, it disappears, resulting in no // generation of buffer. The solution was to force it to add vicinity on the // rabbit buffer map. In this way, the neighborhood for these rabbits will be its // own cell. @collapsed = yes @alias = neighborhood disappeared rabbits. neighborhoodDisappearedRabbits := CalculateCategoricalMap { expression = [ if not isNull(i2) then i2 else i1 ], cellType = .int32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit region @alias = Region rabbit NumberMap defineRegion 1; // Rabbit map @alias = Rabbit map NumberMap joinNewRabbitsAndRabbitSPopulation 2; }}; }}; // Take look around itself @collapsed = yes @alias = Look around Group {{ // Identifies higher resource cell value in the region of the rabbit @collapsed = yes @alias = Max resource ForEachRegion neighborhoodDisappearedRabbits .uint1 {{ regionManager = regionManager; step4 = step; // Selects resources in the region of the rabbit resourcesSelection := RegionalizeMap { globalMap = landscapeMap, regionId = step4, regionManager = regionManager }; extractMapAttributes1018 := ExtractMapAttributes { map = resourcesSelection, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; muxLookupTable1030 := MuxLookupTable [ "Key" "Value" ] maxValue; @alias = Step step5 := Step step4; // Identifies higher resource cell value in the region of the rabbit @collapsed = no higherResource := CalculateValue { expression = [ t1[11] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractMapAttributes1018 1; }}; // Creates a table with Labels & max values of resource in the region of the // rabbit maxValue := SetLookupTableValue { table = muxLookupTable1030, key = step5, value = higherResource }; _ := Bool bool1813; }}; lookupTableJunction1039 := LookupTableJunction maxValue initialPopulationOfAgents0; // Identify in the landscape map the cells with the highest values in each // rabbit's region @collapsed = yes Group {{ // Add max value in the region of the rabbit @collapsed = no maxValueMap := CalculateMap { expression = [ t1[i1] ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Region rabbit @alias = Region rabbit NumberMap neighborhoodDisappearedRabbits 1; // Max value @alias = Max value NumberTable lookupTableJunction1039 1; }}; // Identify in the landscape map the cell with the highest value in the rabbit // region: the prossible cells that rabbits can move to @collapsed = yes calculateMap909 := CalculateMap { expression = [ if i1 = i2 then i3 else null ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Landscape NumberMap landscapeMap 1; // Neigborhood Max NumberMap maxValueMap 2; // Vizinhança NumberMap neighborhoodDisappearedRabbits 3; }}; }}; }}; // Find the spot with the most resource // // === // Identifie the better position in the rabbit region, with the most resource. @collapsed = yes @alias = Find spot Group {{ @collapsed = no Group {{ bool1823 := Bool .yes; // Sum a value to each possible position @collapsed = no regionRabbit := CalculateMap { expression = [ rUniform(0, 1000) + i1 ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit Region @alias = Region rabbit NumberMap calculateMap909 1; }}; }}; @collapsed = no ForEachRegion neighborhoodDisappearedRabbits .uint1 {{ regionManager0 = regionManager; step6 = step; // Selects rabbit region to select the higher value selectsRegion := RegionalizeMap { globalMap = regionRabbit, regionId = step6, regionManager = regionManager0 }; extractMapAttributes1114 := ExtractMapAttributes { map = selectsRegion, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; muxLookupTable1129 := MuxLookupTable [ "Key" "Value" ] selectedValue; @alias = Step step7 := Step step6; // Select the higher value @collapsed = no selectPosition := CalculateValue { expression = [ t1[11] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractMapAttributes1114 1; }}; // Create a table with Labels & selected values in the region of the rabbit selectedValue := SetLookupTableValue { table = muxLookupTable1129, key = step7, value = selectPosition }; _ := Bool bool1823; }}; @collapsed = no Group {{ lookupTableJunction1050 := LookupTableJunction selectedValue initialPopulationOfAgents0; // Adds the higher value in the rabbit region @collapsed = no @alias = Region rabbit regionRabbit0 := CalculateMap { expression = [ t1[i1] ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit Region @alias = Region rabbit NumberMap neighborhoodDisappearedRabbits 1; // Label & higher value @alias = Label NumberTable lookupTableJunction1050 1; }}; // To find the higher cell value in the posible positions @collapsed = no @alias = Region rabbit regionRabbit1 := CalculateMap { expression = [ if i1 = i2 then i2 else null ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Neighborhood Max NumberMap regionRabbit0 1; // Position options NumberMap regionRabbit 2; }}; // Label the final position @collapsed = no @alias = Region rabbit regionRabbit2 := CalculateCategoricalMap { expression = [ if not isNull(i1) then i2 else null ], cellType = .int32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ NumberMap regionRabbit1 1; // Neighborhood NumberMap neighborhoodDisappearedRabbits 2; }}; }}; }}; // New position of rabbit @collapsed = yes @alias = Go there Group {{ // New position @collapsed = no @alias = Rabbit map rabbitMap0 := CalculateCategoricalMap { expression = [ i1 ], cellType = .uint16, nullValue = 65535, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap regionRabbit2 1; }}; }}; }}; // Amount of resource // // === // Accumulates the total amount of resources available for consumption amountResource := MuxLookupTable [ "Key" "Value" ] amountOfResources; // Number of rabbits per time step // // === // Accumulates the number of rabbits which survived the at thetime step numberRabbits := MuxLookupTable [ "Key" "Value" ] survivorsRabbits0; // Number dead by starvation numberDeadStarvation := MuxLookupTable [ "Key" "Value" ] numberDeadStarvation0; // Table of age per time step tableOfAge := MuxLookupTable initialTableOfAge tableOfAge4; // Average age per time step // // === // Accumulating the average age of rabbits which survived per time step averageAge := MuxLookupTable [ "Key" "Value" ] averageAge1; // Average calories per time step averageCalories := MuxLookupTable [ "Key" "Value" ] averageCalories1; // Age of dead rabbits per time step ageDead := MuxLookupTable [ "Key" "Value" ] deadsByAge0; // Number of dead rabbits per time step numberDead := MuxLookupTable [ "Key" "Value" ] numberDead0; // Mortality rate per time step mortalityRate := MuxLookupTable [ "Key" "Value" ] mortalityRate1; // Geometric growth rate per time step geometricGrowthRate := MuxLookupTable [ "Key" "Value" ] geometricGrowthRate1; // Resource Consumption @collapsed = yes @alias = Resource Group {{ // Put resource value in the rabbit position @collapsed = yes resourceMap := CalculateMap { expression = [ if not isNull(i1) then i2 else 0 ], cellType = .float32, nullValue = 255, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 1; // Landscape map @alias = Landscape map NumberMap landscapeMap 2; }}; // Put the rabbit type in the position @collapsed = yes @alias = Rabbit map rabbitMap1 := CalculateMap { expression = [ if not isNull(i1) then t1[i1] else 0 ], cellType = .int32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 1; // Types rabbits @alias = Types rabbits NumberTable typesRabbits0 1; }}; // Calculate resources availability for consumption // // === // The absorption value for each type is limited according to the table of Maximum // absorption of energy of rabbits. The rabbit absorb its maximum calorie value or // the value conteined in the cell if the value is smaller than it. @collapsed = yes resourceAvailable := CalculateMap { expression = [ if i1 < t1[i2] or 0 then i1 else t1[i2] ], cellType = .float32, nullValue = 255, resultIsSparse = .no, resultFormat = .none } {{ // Resoruce value NumberMap resourceMap 1; // Rabbit type map NumberMap rabbitMap1 2; // Rabbit type table NumberTable typesOfRabbits 1; }}; // Subtract the resource that the rabbit has consumed in the lanscape map. @collapsed = yes @alias = Resource Map resourceMap0 := CalculateMap { expression = [ if not isNull(i1) then i2 - i3 else i2 ], cellType = .float32, nullValue = 255, resultIsSparse = .yes, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 1; // Resource map @alias = Lanscape map NumberMap landscapeMap 2; // Resource available @alias = Resource available NumberMap resourceAvailable 3; }}; // Calculate the value to be recovered in the landscape map according to the // logistic function @collapsed = yes valueRecovery := CalculateMap { expression = [ v2 * (1 - i1 / i2) * i1 ], cellType = .float32, nullValue = 255, resultIsSparse = .no, resultFormat = .none } {{ // Landscape map @alias = Landscape map NumberMap resourceMap0 1; // Max resource @alias = Max resource NumberMap initialLandsacapeMap 2; // Recovery Rate Of The Landscape @alias = Recovery Rate Of The Landscape NumberValue recoveryRateOfTheLandscape 2; }}; // Adds the recovery value to landscape map @collapsed = yes @alias = Resource map resourceMap1 := CalculateMap { expression = [ i1 + i2 ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Landscape map @alias = Landscape map NumberMap resourceMap0 1; // Value recouvery @alias = Value recouvery NumberMap valueRecovery 2; }}; // Landscape map recovered @alias = Landscape map SaveMap { map = resourceMap1, filename = "../../../Downloads/NovoRecurso_.ers", suffixDigits = 2, step = step, useCompression = .yes, workdir = .none }; // Amount of resources @collapsed = yes @alias = Amount of resources Group {{ // Landscape map @alias = Landscape map landscapeMap0 := ExtractMapAttributes { map = resourceMap1, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; // Count resource @collapsed = no resouceMap := CalculateValue { expression = [ t1[12] ], useDefaultValue = .no, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable landscapeMap0 1; }}; // Accumulate the amount of resources amountOfResources := SetLookupTableValue { table = amountResource, key = step0, value = resouceMap }; }}; }}; // Gini coefficient per time step giniCoefficient := MuxLookupTable [ "Key" "Value" ] giniCoefficient0; // Energy Stock, Rabbit's age, Dead rabbits @collapsed = no @alias = Energy Balance and Death Group {{ // Estimated final amount of calories - Energy Stock @collapsed = no @alias = Balance Group {{ // Calculate stock energy @collapsed = yes @alias = Stock Group {{ // Calculate energy stock @collapsed = no stock := CalculateMap { expression = [ if not isNull(i1) then t1[i1] else if not isNull(i1) and not isNull(i2) then i2 + 49 else null ], cellType = .float32, nullValue = 65535, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 1; // Newborns @alias = Newborns NumberMap calcRabbitsMap 2; // Table of calories @alias = Table of calories NumberTable tableOfCalories1 1; }}; }}; // Calculate consumed energy @collapsed = yes @alias = Intake Group {{ @collapsed = yes ForEachCategory rabbitMap0 {{ step8 = step; @alias = Step step9 := Step step8; // Select the rabbit @collapsed = no selectRabbit := CalculateCategoricalMap { expression = [ i1 = v1 ], cellType = .uint8, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 1; // Label @alias = Label NumberValue step9 1; }}; // Calculates the energy consumed @collapsed = no energyConsumed := CalculateMap { expression = [ if not isNull(i1) then i2 else null ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap selectRabbit 1; // Landscape map @alias = Resource map NumberMap resourceAvailable 2; }}; extractMapAttributes458 := ExtractMapAttributes { map = energyConsumed, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; muxLookupTable470 := MuxLookupTable [ "Key" "Value" ] energyConsumed1; // Identifies the amount of energy consumed @collapsed = no @alias = Energy consumed energyConsumed0 := CalculateValue { expression = [ t1[12] ], useDefaultValue = .no, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractMapAttributes458 1; }}; // Accumulate the energy consumed @alias = Energy Consumed energyConsumed1 := SetLookupTableValue { table = muxLookupTable470, key = step9, value = energyConsumed0 }; }}; @collapsed = no Group {{ lookupTableJunction1055 := LookupTableJunction energyConsumed1 initialPopulationOfAgents0; // Energy consumed map @collapsed = no @alias = Energy consumed energyConsumed2 := CalculateMap { expression = [ t1[i1] ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 1; // Energy consumed @alias = Energy consumed NumberTable lookupTableJunction1055 1; }}; }}; }}; // Calculate spent energy @collapsed = no @alias = Spent Energy Group {{ // Calculate the energy spent to survive and move @collapsed = no energyUsed := CalculateCategoricalMap { expression = [ if not isNull(i1) and not isNull(i2) then v1 else if not isNull(i2) then v2 else null ], cellType = .uint8, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Inital rabbit map @alias = Inital rabbit map NumberMap joinNewRabbitsAndRabbitSPopulation 1; // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 2; // Energy Spent To Survive @alias = Energy Spent To Survive NumberValue energySpentToSurvive 1; // Energy Spent To Move @alias = Energy Spent To Move NumberValue energySpentToMove 2; }}; }}; // Energy Stock + absorved Energy - spent Energy @collapsed = no balance := CalculateMap { expression = [ i1 + i2 - i3 ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Stock @alias = Stock NumberMap stock 1; // Absorved Energy @alias = Energy consumed NumberMap energyConsumed2 2; // Spent Energy @alias = Energy used NumberMap energyUsed 3; }}; // Calculate the enery stock (calories) @collapsed = yes @alias = Table of calories Group {{ // Energy balance @collapsed = no @alias = Energy balance Group {{ bool1853 := Bool .yes; // Energy balance @collapsed = no energyBalance := CalculateMap { expression = [ i1 ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Energy balance @alias = Energy balance NumberMap balance 1; }}; }}; @collapsed = no ForEachCategory rabbitMap0 {{ step10 = step; @alias = Step step11 := Step step10; // Select each label @collapsed = no selectLabel := CalculateCategoricalMap { expression = [ i1 = v1 ], cellType = .uint16, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 1; // Label @alias = Label NumberValue step11 1; }}; // Energy balance of each rabbit @collapsed = no @alias = Energy balance energyBalance0 := CalculateMap { expression = [ if not isNull(i1) then i2 else null ], cellType = .float32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit NumberMap selectLabel 1; // Energy balance @alias = Energy balance NumberMap energyBalance 2; }}; extractMapAttributes904 := ExtractMapAttributes { map = energyBalance0, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; muxLookupTable916 := MuxLookupTable [ "Key" "Value" ] tableOfCalories2; // Table with energy balace of each rabbit @collapsed = no @alias = Energy balance energyBalance1 := CalculateValue { expression = [ t1[12] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractMapAttributes904 1; }}; // Update the table of energy stock (calories) @alias = Table of calories tableOfCalories2 := SetLookupTableValue { table = muxLookupTable916, key = step11, value = energyBalance1 }; _ := Bool bool1853; }}; lookupTableJunction739 := LookupTableJunction tableOfCalories2 initialPopulationOfAgents0; }}; }}; // Calculates the age of rabbits per time step @collapsed = yes @alias = Table of age Group {{ extractMapValues642 _ _ := ExtractMapValues rabbitMap0 .yes; // Surviving rabbits per time step @collapsed = yes rabbitsSurvivors := CalculateLookupTable { expression = [ t1[line] * 0 + 1 ], keyName = .none, valueName = .none } {{ // Rabbits survivor @alias = Rabbits survivor NumberTable extractMapValues642 1; }}; // Initial table of age @collapsed = yes @alias = Table of age tableOfAge0 := CalculateLookupTable { expression = [ t1[line] ], keyName = .none, valueName = .none } {{ // Table of age @alias = Table of age NumberTable tableOfAge 1; }}; // Adds 1 (year) to rabbits age that are still alive @collapsed = no rabbitSurvivors := CalculateLookupTable { expression = [ t2[line] + 1 ], keyName = .none, valueName = .none } {{ // Suviving Rabbits @alias = Rabbit suvivors NumberTable rabbitsSurvivors 1; // Table of age @alias = Table of age NumberTable tableOfAge0 2; }}; // Born rabbits age @collapsed = yes @alias = Table of age tableOfAge1 := CalculateLookupTable { expression = [ t1[line] * 0 + 1 ], keyName = .none, valueName = .none } {{ // Table of age @alias = Table of age NumberTable tableOfCalories0 1; }}; // Surviving rabbits and newborn rabbits @alias = Table of age tableOfAge2 := CalcLookupTableUnion { firstTable = rabbitSurvivors, secondTable = tableOfAge1, useFirstTableToSolveDuplicatedKey = .yes }; }}; // Identify dead rabbits and create new rabbit map @collapsed = yes @alias = Dead rabbits/ New Rabbit map Group {{ // Identify dead rabbits @collapsed = yes @alias = Deads rabbits Group {{ // Death threshold according to the normal probability @collapsed = yes threshold := CalculateLookupTable { expression = [ t1[line] * 0 + rNormal(36, 4) ], keyName = .none, valueName = .none } {{ // Label NumberTable tableOfAge2 1; // Average lifespan @alias = Average lifespan NumberValue averageLifespan 1; // Variance Of Death Function @alias = Variance Of Death Function NumberValue varianceOfDeathFunction 2; }}; // Result: // // Live = 1 // // Dead = 2 @collapsed = yes @alias = Table of calories tableOfCalories3 := CalculateLookupTable { expression = [ if t1[line] > 0 then 1 else 2 ], keyName = .none, valueName = .none } {{ // Table of calories @alias = Table of calories NumberTable lookupTableJunction739 1; }}; // Result: // // Live = 1 // // Dead = 2 @collapsed = yes @alias = Table of age tableOfAge3 := CalculateLookupTable { expression = [ if t1[line] > t2[line] then 2 else 1 ], keyName = .none, valueName = .none } {{ // Table of age @alias = Table of age NumberTable tableOfAge2 1; // Threshold @alias = Threshold NumberTable threshold 2; }}; // by starvation @collapsed = yes deadRabbits := CalculateLookupTable { expression = [ if t1[line] = 2 then 2 else null ], keyName = .none, valueName = .none } {{ // Table of age @alias = Table of age NumberTable tableOfCalories3 1; }}; // by age @collapsed = yes @alias = Dead rabbits deadRabbits0 := CalculateLookupTable { expression = [ if t1[line] = 2 then 2 else null ], keyName = .none, valueName = .none } {{ // Table of age @alias = Table of age NumberTable tableOfAge3 1; }}; // Join dead by age and starvation @alias = Dead Rabbits deadRabbits1 := CalcLookupTableUnion { firstTable = deadRabbits, secondTable = deadRabbits0, useFirstTableToSolveDuplicatedKey = .yes }; extractMapValues853 _ _ := ExtractMapValues rabbitMap0 .yes; // Alive rabbits @collapsed = yes @alias = Rabbit map rabbitMap2 := CalculateLookupTable { expression = [ t1[line] * 0 + 1 ], keyName = .none, valueName = .none } {{ // Rabbit map @alias = Rabbit map NumberTable extractMapValues853 1; }}; bool1791 := Bool .yes; // Calculate the number dead by starvation @collapsed = yes @alias = Calc number dead starvation Group {{ extractLookupTableAttributes1773 := ExtractLookupTableAttributes { table = deadRabbits, extractStatisticalKeyAttributes = .no, extractStatisticalValueAttributes = .no, extractDynamicKeyValueAttributes = .no }; // Calculate the number dead rabbits by starvation @collapsed = yes calcNumberDeadStarvation := CalculateValue { expression = [ t1[1] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractLookupTableAttributes1773 1; }}; @alias = Number dead starvation numberDeadStarvation0 := SetLookupTableValue { table = numberDeadStarvation, key = step0, value = calcNumberDeadStarvation }; }}; // Count deads by age @collapsed = yes @alias = Deads by age Group {{ extractLookupTableAttributes1811 := ExtractLookupTableAttributes { table = deadRabbits0, extractStatisticalKeyAttributes = .yes, extractStatisticalValueAttributes = .no, extractDynamicKeyValueAttributes = .no }; // Count deads by age @collapsed = yes deadsByAge := CalculateValue { expression = [ t1[1] ], useDefaultValue = .no, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractLookupTableAttributes1811 1; }}; // Accumulate number of deads by age @alias = Deads By Age deadsByAge0 := SetLookupTableValue { table = ageDead, key = step0, value = deadsByAge }; }}; // Count deads by starvation @collapsed = yes @alias = Deads by starvation Group {{ extractLookupTableAttributes2034 := ExtractLookupTableAttributes { table = deadRabbits1, extractStatisticalKeyAttributes = .no, extractStatisticalValueAttributes = .no, extractDynamicKeyValueAttributes = .no }; // Nº Coelhos // // === // Número de coelhos após o nascimento extractMapAttributes1161 := ExtractMapAttributes { map = joinNewRabbitsAndRabbitSPopulation, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; // Dead rabbits @collapsed = yes @alias = Dead rabbits deadRabbits2 := CalculateValue { expression = [ t1[1] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Dead rabbits @alias = Dead rabbits NumberTable extractLookupTableAttributes2034 1; }}; // Calculate mortality rate @collapsed = yes @alias = Mortality rate mortalityRate0 := CalculateValue { expression = [ t1[1] / t2[9] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Number dead @alias = Number dead NumberTable extractLookupTableAttributes2034 1; // Number rabbits @alias = Number rabbits NumberTable extractMapAttributes1161 2; }}; // Accumulate number of dead step time @alias = Number dead numberDead0 := SetLookupTableValue { table = numberDead, key = step0, value = deadRabbits2 }; // Accumulaate mortality rate step time @alias = Mortality rate mortalityRate1 := SetLookupTableValue { table = mortalityRate, key = step0, value = mortalityRate0 }; }}; calcLookupTableDifference851 := CalcLookupTableDifference { firstTable = rabbitMap2, secondTable = deadRabbits1, useSymmetricalDifference = .yes }; }}; // Count surviving rabbits and create new rabbit map @collapsed = yes @alias = Survivors rabbits Group {{ // Surviving rabbits // // === // Generate the final position of the rabbits which survived excluding dead // rabbits @collapsed = yes @alias = Rabbit map rabbitMap3 := CalculateCategoricalMap { expression = [ if not isNull(t1[i1]) then i1 else null ], cellType = .uint16, nullValue = 65535, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap0 1; // Surviving rabbits @alias = Survivors rabbits NumberTable calcLookupTableDifference851 1; }}; // Count surviving rabbits @collapsed = yes @alias = Survivors rabbits Group {{ extractMapAttributes556 := ExtractMapAttributes { map = rabbitMap3, extractDynamicAttributes = .yes, extractStatisticalAttributes = .no }; // Count surviving rabbits @collapsed = yes survivorsRabbits := CalculateValue { expression = [ t1[9] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attibutes @alias = Attibutes NumberTable extractMapAttributes556 1; }}; // Accumulate number of surviving rabbits @alias = Survivors Rabbits survivorsRabbits0 := SetLookupTableValue { table = numberRabbits, key = step0, value = survivorsRabbits }; }}; // Rabbit map @alias = Rabbit map SaveMap { map = rabbitMap3, filename = "../../../Downloads/Coelhos_PosicaoFinal_.ers", suffixDigits = 2, step = step, useCompression = .yes, workdir = .none }; // Geometric growth rate of rabbits for step time @collapsed = yes @alias = Geometric growth rate Group {{ // Calculate geometric growth rate @collapsed = yes calcGeometricGrowthRate := CalculateLookupTable { expression = [ if t1[line = v1 - 1] or v1 > 1 then (sqrt(v2 / t1[line]) - 1) * 100 else null ], keyName = .none, valueName = .none } {{ // Number rabbits of previous step @alias = Number rabbits NumberTable numberRabbits 1; // Step @alias = Step NumberValue step0 1; // Number rabbits of current step time @alias = Number rabbits NumberValue survivorsRabbits 2; }}; extractLookupTableAttributes1950 := ExtractLookupTableAttributes { table = calcGeometricGrowthRate, extractStatisticalKeyAttributes = .yes, extractStatisticalValueAttributes = .yes, extractDynamicKeyValueAttributes = .no }; // Calculate geometric growth rate @collapsed = no @alias = Geometric growth rate geometricGrowthRate0 := CalculateValue { expression = [ t1[21] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attibutes @alias = Attibutes NumberTable extractLookupTableAttributes1950 1; }}; // Accumulate the geometric growth rate @alias = Geometric growth rate geometricGrowthRate1 := SetLookupTableValue { table = geometricGrowthRate, key = step0, value = geometricGrowthRate0 }; }}; _ := Bool bool1791; }}; }}; // Update: // // Types rabbits // // Average age // // Average calories @collapsed = yes @alias = Update tables Group {{ // Count of rabbits according its type @collapsed = yes @alias = Types rabbits Group {{ // Number of rabbits according its type @collapsed = yes @alias = Types rabbits typesRabbits1 := CalculateLookupTable { expression = [ t1[line] * t2[line] ], keyName = .none, valueName = .none } {{ // Types rabbits @alias = Types rabbits NumberTable typesRabbits0 1; // Survivors rabbits @alias = Survivors rabbits NumberTable calcLookupTableDifference851 2; }}; @collapsed = no ForEach typesOfRabbits .yes {{ step12 = step; @alias = Step step13 := Step step12; // Select rabbits by type @collapsed = yes selectType := CalculateLookupTable { expression = [ if t1[line] = v1 then 1 else null ], keyName = .none, valueName = .none } {{ // rabbits Types @alias = Types rabbits NumberTable typesRabbits1 1; // Type @alias = Type NumberValue step13 1; }}; extractLookupTableAttributes2090 := ExtractLookupTableAttributes { table = selectType, extractStatisticalKeyAttributes = .yes, extractStatisticalValueAttributes = .yes, extractDynamicKeyValueAttributes = .yes }; muxLookupTable2104 := MuxLookupTable [ "Key" "Value" ] typesRabbits3; // Calculate the number of rabbits by type @collapsed = no @alias = Types rabbits typesRabbits2 := CalculateValue { expression = [ if not isNull(t1[31]) then t1[31] else 0 ], useDefaultValue = .no, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractLookupTableAttributes2090 1; }}; // Accumulate the number of rabbits by type @alias = Types rabbits typesRabbits3 := SetLookupTableValue { table = muxLookupTable2104, key = step13, value = typesRabbits2 }; }}; // Types rabbits @alias = Types rabbits SaveLookupTable { table = typesRabbits3, filename = "../../../Downloads/tipos_.csv", suffixDigits = 2, step = step, workdir = .none }; }}; // Calculate average age @collapsed = yes @alias = Average age Group {{ // Age of suviving rabbits @collapsed = no @alias = Table of age tableOfAge4 := CalculateLookupTable { expression = [ t1[line] * t2[line] ], keyName = .none, valueName = .none } {{ // Table of age @alias = Table of age NumberTable tableOfAge2 1; // Label @alias = Label NumberTable calcLookupTableDifference851 2; }}; extractLookupTableAttributes674 := ExtractLookupTableAttributes { table = tableOfAge4, extractStatisticalKeyAttributes = .yes, extractStatisticalValueAttributes = .yes, extractDynamicKeyValueAttributes = .no }; // Calculate average age of rabbits @collapsed = no @alias = Average age averageAge0 := CalculateValue { expression = [ t1[22] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractLookupTableAttributes674 1; }}; // Accumulate average age per time step @alias = Average age averageAge1 := SetLookupTableValue { table = averageAge, key = step0, value = averageAge0 }; }}; // Calculate average calories @collapsed = yes @alias = Table of calories Group {{ // Calories of surviving rabbits @collapsed = no @alias = Table of calories tableOfCalories4 := CalculateLookupTable { expression = [ t1[line] * t2[line] ], keyName = .none, valueName = .none } {{ // Table of calories @alias = Table of calories NumberTable lookupTableJunction739 1; // Survivors @alias = Survivors NumberTable calcLookupTableDifference851 2; }}; lookupTableJunction1060 := LookupTableJunction tableOfCalories4 lookupTableJunction739; extractLookupTableAttributes650 := ExtractLookupTableAttributes { table = lookupTableJunction1060, extractStatisticalKeyAttributes = .yes, extractStatisticalValueAttributes = .yes, extractDynamicKeyValueAttributes = .yes }; // Calculate average calories of rabbits @collapsed = no @alias = Average calories averageCalories0 := CalculateValue { expression = [ t1[22] ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractLookupTableAttributes650 1; }}; // Accumulate average calories of rabbits @alias = Average calories averageCalories1 := SetLookupTableValue { table = averageCalories, key = step0, value = averageCalories0 }; }}; }}; }}; // Calculate gini coefficient @collapsed = yes @alias = Gini coefficient Group {{ extractLookupTableAttributes1134 := ExtractLookupTableAttributes { table = lookupTableJunction1060, extractStatisticalKeyAttributes = .yes, extractStatisticalValueAttributes = .yes, extractDynamicKeyValueAttributes = .yes }; // Controls the execution of the process @collapsed = yes flag := CalculateValue { expression = [ if t1[31] != 0 then 1 else 0 ], useDefaultValue = .yes, defaultValue = 0 } {{ // Attributes @alias = Attributes NumberTable extractLookupTableAttributes1134 1; }}; IfThen flag {{ // Table of calories @collapsed = yes @alias = Rabbit map rabbitMap4 := CalculateMap { expression = [ t1[i1] ], cellType = .int32, nullValue = .default, resultIsSparse = .no, resultFormat = .none } {{ // Rabbit map @alias = Rabbit map NumberMap rabbitMap3 1; // Table of calories @alias = Table of calories NumberTable lookupTableJunction1060 1; }}; calculateGiniCoefficientMap1475 := CalculateGiniCoefficientMap rabbitMap4; // Accumulate gini coefficient step time @alias = Gini coefficient giniCoefficient0 := SetLookupTableValue { table = giniCoefficient, key = step0, value = calculateGiniCoefficientMap1475 }; }}; }}; }}; SaveLookupTable { table = amountOfResources, filename = "../../../Downloads/Historico_EstoqueRecurso.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = mortalityRate1, filename = "../../../Downloads/Historico_TxMortalidade.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = geometricGrowthRate1, filename = "../../../Downloads/Historico_TxCrescimento.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = deadsByAge0, filename = "../../../Downloads/Historico_NMortosIdade.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = numberDead0, filename = "../../../Downloads/Historico_NCoelhosMortos.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = survivorsRabbits0, filename = "../../../Downloads/Historico_NCoelhos.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = averageAge1, filename = "../../../Downloads/Historico_MediaIdadeCoelhos.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = numberDeadStarvation0, filename = "../../../Downloads/Historico_NMortosInanicao.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = rabbitsBorn0, filename = "../../../Downloads/Historico_NCoelhosInput.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = giniCoefficient, filename = "../../../Downloads/Historico_CoefGini.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = birthRate0, filename = "../../../Downloads/Historico_TxNatalidade.csv", suffixDigits = 2, step = .none, workdir = .none }; SaveLookupTable { table = averageCalories1, filename = "../../../Downloads/Historico_MediaCaloriasCoelhos.csv", suffixDigits = 2, step = .none, workdir = .none }; }};