Community Simulation State & Data Matrices
Brian S. Yandell
28 July 2026
dataorg.RmdThis document details the critical data structures and primary execution pipelines used internally to drive the event-based simulation in Quantitative Population Ethology.
Table of Contents
1. State Management (The community Object)
The core architecture operates around a robust state object called
community. The simulation evaluates and updates this object
at every step, meaning past events are discarded except when
intrinsically expressed by an organism’s currently modeled history or
future transition path.
The community object comprises several components:
-
pop: A matrix constructed per species holding raw population attributes. Note: Thecommunity$popitems dynamically store dimensional data with features mapping to rows and individuals mapped to columns. This rotated alignment guarantees that calling an individual isolates its column, simultaneously retrieving its entire feature subset cleanly. -
org: Contains global organism configurations, traits, and behavioral interaction constants. (UsegetOrgInfoandgetOrgInteract). -
temp: A configuration array maintaining parameters like environmental temperature cycles and degree-day thresholds. -
count: Actively running summary tallies. -
cpu: Diagnostic CPU measurement.
Each organism tracked under pop evaluates parameters
defining precise spatial interactions, life cycles, and behavior
triggers. Notable row attributes inside the pop column
trace include:
-
left,right,up: Tree linkages to navigate network topologies -
pos.a,pos.b,pos.c: Triangular continuous positional coordinates mapped onto the immediate substrate environment -
stage&future: Current developmental array and the immediately pending advancement event -
sub.stage&sub.future: Current geographical substrate target and anticipated movement
Simulation events systematically pluck organisms holding imminent
mintime thresholds. Upon evaluation, monadic
(e.g. chronological molting) or dyadic (e.g. host-parasite conflicts)
modifications physically rewrite these state features on the subject
population matrices natively. Aggregated structural translations are
subsequently written outbound to writeCount for data
visualization.
2. Global Parameters (Datafiles)
Baseline operational properties, mapping keys, and environment
coefficients are pulled from global definitions within the source code
ewing/data/ structure.
Interaction & Functional Parameters
-
organism.features.txt: Base limits and definitions (units, offspring, attack behavior) mapping the base functional limits of species against environments. -
host.parasite.txt: Dyadic interaction matrices mapping parasite feeding behavior, oviposition matrices, and gender determination parameters to specific stages of standard host lifecycles.
Transition Matrices
These describe the fundamental arrays an organism iterates through based on the passage of time or ecological interaction.
-
future.host.txt&future.parasite.txt: Linkcurrentlifecycle states to predictablefuturetransitions based on temporal progressions (fid,time,pch,color). Example:egg->larva->pupa. -
substrate.host.txt&substrate.parasite.txt: Spatial matrices defining how organisms interpret physical positioning based on distinct geometry arrays (e.g., fruit vs. leaf vs. twig).
3. Simulation Functional Flow
The package operates via a sequence of procedural pipelines dividing into environment initialization, event logic sorting, and temporal adjustments.
A. Initialization (init.simulation |
init.R & community.R)
This initializes the entire topological network from an arbitrary starting population.
-
initOrgInfo: Pulls functional baselines from the environment datasets into network configurations. -
initTemp: Binds weather array logic to system base. -
init.population: Initializes array counts mapping strictly generated physical and temporal states across populations using a leftist tree framework.
B. Core Event Loop (future.events.R)
The quantitative framework iterates over timeline horizons.
-
Step & History Accumulation: When called on a
pre-existing
communityobject containing event counts (community$count$counts),future.eventsautomatically setsappend = TRUEand computesstart_stepfromcommunity$count$step. Subsequent steps increment asstart_step + istep, accumulating event logs continuously across sequential simulation blocks. - Generates counts and maps the lowest sequential transition milestone
via
update_mintime. - Passes identified organisms to target handlers based on condition:
-
event.death: Eliminates nodes out of positional topological maps. -
event.future: A monadic evaluator routing progress natively (moving between age classes and stages based on time horizons). Also triggers geographic movementevent.movedepending on active substrate mapping rules. -
event.attack: A dyadic evaluator representing predation. Models parasitic search routines over distinct topological layers until a target is acquired. Results either functionally remove targets (Ectoparasite) or compromise them.
-
-
Count Logging (
sim.R&fileCount.R):updateCount()updatescommunity$count$stepand captures return values fromwriteCount(), persisting complete event histories intocommunity$count$counts.setEvents()cleanly updates period tallies without truncatingcommunitywhen life stage vectors are empty.
4. Plot Routines
Graphic outputs are natively aggregated via S3 method generics
(autoplot / ggplot_ewing_*) and structured
outputs:
-
ewing_ageclass.R: Reshapes continuous event counts fromreadCount(community)into age-class time-series.ggplot_ewing_ageclass()formats titles dynamically (e.g."Age Distribution over Time (<nstep> steps)"), assigns open shape markers per species (scale_shape_manual(name = "Species", values = c(1, 2, 0, 5, 6, 3, 4))), and displays step-by-step history from step 0 to the final accumulated step. -
temp.R/temp.plot&temp.design: Evaluation vectors tracking degree-day dynamics and temperature threshold simulations -
triangle.R/plot_current: Two-dimensional plotting logic tracking population clusters specifically using triangular mappings upon the target substrates -
spline.R/five.plot: Interactive functional graphics used for plotting development loops
5. AI Documentation Refactoring
Historically, deep structural and architectural documentation for the
ewing project was nested entirely within the central
README.md in the form of raw developer logic logs tracing
back to 2014. These blocks were often intertwined with localized
debugging notes and granular pseudo-code matrices.
Through integrated AI assistance methodologies tracked via our
walkthrough and prompts structures:
- The literature was heavily partitioned. High-level installation and
accessibility notes remain natively within the core system
README.md, while strict architectural notes were securely abstracted into thisinst/doc/refactor/directory. - Former raw development logic was synthesized into comprehensive
explanations outlining system dependencies (e.g. clearly identifying
State Management,Global Parameters, andFunctional Pipelines). - Legacy debug logic (long-resolved codebase “To-Dos” and graphical constraints from older implementations) was thoroughly scrubbed to prevent downstream developmental confusion.
This compartmentalization vastly improves the cognitive parsing of the system boundaries and isolates architectural onboarding specifically to developers who require access without cluttering the baseline user experience.