|
MalariaSentinel — C++ reference
The contract-defining headers of the ABM engine
|
#include <coordinator.hpp>
Classes | |
| struct | JetView |
Public Member Functions | |
| CoordinatorModel (AOI aoi, std::shared_ptr< ClimateEngine > climate, HabitatEngine habitat, int32_t seed, std::chrono::sys_days start_date) | |
| const AOI & | aoi () const |
| const ClimateEngine & | climate () const |
| const HabitatEngine & | habitat () const |
| std::chrono::sys_days | current_date () const |
| std::chrono::sys_days & | current_date () |
| Prng & | rng () |
| const std::vector< PatchState > & | patch_states_today () const |
| void | set_climate_day (int32_t day_index) |
| void | warm_up_pluvial (int32_t n_warmup_bands) |
| void | update_habitat_day (float gamma_t=0.0f) |
| void | set_salinity_hi_tol_ppt (float ppt) |
| void | set_host_landscape (const HostLandscape *hosts) |
| float | salinity_hi_tol_ppt () const |
| void | activate_patches () |
| Legacy no-op kept for engine.step() API parity. | |
| std::vector< PatchState > | to_dataframe () |
| std::vector< SeedInstruction > | build_seed_instructions (const SeedingConfig &config) |
| std::vector< SeedInstruction > | build_uniform_seed_instructions (int32_t n_adults, int32_t n_immatures) |
| JetView | J_view () const |
| const std::vector< float > & | z_grid () const |
| DensityGrid | aggregate_density (const MosquitoSubmodel &sub) const |
| SuitabilityGrid | suitability_grid (const MosquitoSubmodel &sub) const |
| std::string | write_state_cog (const std::string &path, const DensityGrid &density, const SuitabilityGrid &suit, int32_t year, int32_t month, int32_t seed, int32_t n_rollouts=1, int32_t rollout_index=0) const |
| – output ----------------------------------------------------------— | |
The engine's spatial façade (the Mesa-Geo half of the ABM). It owns the AOI geometry, the env-NC climate reader, the candidate-patch habitat registry and the per-rollout PRNG, and serves the per-day habitat update, the seeding plans and the state-COG output.
| mal_abm_fast::CoordinatorModel::CoordinatorModel | ( | AOI | aoi, |
| std::shared_ptr< ClimateEngine > | climate, | ||
| HabitatEngine | habitat, | ||
| int32_t | seed, | ||
| std::chrono::sys_days | start_date ) |
Construct a coordinator for (AOI, climate, habitat, seed, start date). day_offset is the absolute NC band index of the start date (pluvial warm-up reads bands before it).
| DensityGrid mal_abm_fast::CoordinatorModel::aggregate_density | ( | const MosquitoSubmodel & | sub | ) | const |
– adult count aggregation -----------------------------------------—
Contract 4.0: both grids carry RAW per-cell adult counts (individuals). No K_MAX division, no [0,1] clamp.
|
inline |
Accessors. The Prng is mutable (submodel.advance_day advances it) so rng() is non-const.
| std::vector< SeedInstruction > mal_abm_fast::CoordinatorModel::build_seed_instructions | ( | const SeedingConfig & | config | ) |
Identify viable patches (potential clear of the candidate floor) and build the per-patch seed instructions for the submodel. config.min_water_frac / config.min_twi are ignored by the v3.0 contract (retired selectors); viability is potential-based.
| std::vector< SeedInstruction > mal_abm_fast::CoordinatorModel::build_uniform_seed_instructions | ( | int32_t | n_adults, |
| int32_t | n_immatures ) |
UNIFORM-mode seeding: every candidate habitat cell (patch union at day 0) receives the explicit n_adults + n_immatures counts (contract 4.0; the retired init_frac × K_MAX product is replaced by direct counts).
|
inline |
The env-NC climate reader (daily rainfall, daily air temperature and the static habitat planes); valid for the coordinator's lifetime.
|
inline |
Mutable calendar date of the simulated day; the Engine uses it to advance the simulation by one day at the end of each step.
|
inline |
The calendar date (day resolution) of the simulated day. The Engine advances it by one day at the end of every step, so after a step it already holds the date of the next day.
|
inline |
The candidate-patch habitat registry read from the habitat gpkg; valid for the coordinator's lifetime.
|
inline |
The read-only per-cell capacity K view for the current day, in absolute Beverton-Holt capacity units (individual-equivalent).
|
inline |
The per-patch state vector cached by the last to_dataframe() call (one PatchState per candidate cell); empty until that call runs.
|
inline |
The per-rollout PRNG sub-stream (derived from --seed). It is advanced by the seeding planners and by MosquitoSubmodel::advance_day.
|
inline |
The species salinity high-tolerance in PSU (parts per thousand): patches whose water salinity reaches it cannot breed.
|
inline |
– warm-up + per-day habitat update ---------------------------------— Point the climate engine at the NC band for simulation day day_index (relative to base_day_). Called by the engine loop.
|
inline |
Attach the host landscape (non-owning pointer) used to score candidate cells in HOST_WEIGHTED seeding; it must outlive the coordinator and may be left null, in which case HOST_WEIGHTED seeding is rejected.
|
inline |
Species salinity high-tolerance (psu). Patches whose water salinity exceeds this cannot breed (activated=false). Engine wires the active species' salinity_hi_tol_ppt; the default comes from the default species row.
| SuitabilityGrid mal_abm_fast::CoordinatorModel::suitability_grid | ( | const MosquitoSubmodel & | sub | ) | const |
Per-cell raw adult counts at the adults' current position (state COG band 2, adult_cell_count); counts every adult regardless of sex or physiological state.
| std::vector< PatchState > mal_abm_fast::CoordinatorModel::to_dataframe | ( | ) |
– per-patch state vector -----------------------------------------— Build the per-patch PatchState vector over candidate cells: the union of the gpkg patches and every grid cell whose static potential clears habitat.candidate_min_engine (contract: candidate-floor based, no TWI/water/urban gates). Stables pid per cell for site fidelity.
| void mal_abm_fast::CoordinatorModel::update_habitat_day | ( | float | gamma_t = 0.0f | ) |
Per-day: advance z with today's rainfall per cell, recompute the species-neutral daily accuracy S[i, t] and capacity K[i, t], and track per-cell dry-day streaks. Call AFTER climate_->set_day(). gamma_t: temperature scaling of the pluvial drying memory — tau_eff = pluvial.dry_memory_days * (1 - gamma_T * clamp((T_opt - temp)/T_ref)) when gamma_T > 0.
| void mal_abm_fast::CoordinatorModel::warm_up_pluvial | ( | int32_t | n_warmup_bands | ) |
Integrate the pluvial state z causally over every env-NC band from base_day - n_warmup_bands to base_day - 1, starting from z = 0 at the cold end. Called once by the Engine facade before the daily loop (plan §6.5 warm-up Causal).
|
inline |
Read-only per-cell pluvial state z in [0,1] (plan 04 §2.3 — the GIF inset reads the SAME grid the coordinator integrates, so the inset cannot drift from the engine). Row-major (H,W) matching ClimateEngine::h()/w(); empty until the first update_habitat_day().