MalariaSentinel — C++ reference
The contract-defining headers of the ABM engine
Loading...
Searching...
No Matches
mal_abm_fast::CoordinatorModel Class Reference

#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 ----------------------------------------------------------—

Detailed Description

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.

Constructor & Destructor Documentation

◆ CoordinatorModel()

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).

Member Function Documentation

◆ aggregate_density()

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.

◆ aoi()

const AOI & mal_abm_fast::CoordinatorModel::aoi ( ) const
inline

Accessors. The Prng is mutable (submodel.advance_day advances it) so rng() is non-const.

◆ build_seed_instructions()

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.

◆ build_uniform_seed_instructions()

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).

◆ climate()

const ClimateEngine & mal_abm_fast::CoordinatorModel::climate ( ) const
inline

The env-NC climate reader (daily rainfall, daily air temperature and the static habitat planes); valid for the coordinator's lifetime.

◆ current_date() [1/2]

std::chrono::sys_days & mal_abm_fast::CoordinatorModel::current_date ( )
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.

◆ current_date() [2/2]

std::chrono::sys_days mal_abm_fast::CoordinatorModel::current_date ( ) const
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.

◆ habitat()

const HabitatEngine & mal_abm_fast::CoordinatorModel::habitat ( ) const
inline

The candidate-patch habitat registry read from the habitat gpkg; valid for the coordinator's lifetime.

◆ J_view()

JetView mal_abm_fast::CoordinatorModel::J_view ( ) const
inline

The read-only per-cell capacity K view for the current day, in absolute Beverton-Holt capacity units (individual-equivalent).

◆ patch_states_today()

const std::vector< PatchState > & mal_abm_fast::CoordinatorModel::patch_states_today ( ) const
inline

The per-patch state vector cached by the last to_dataframe() call (one PatchState per candidate cell); empty until that call runs.

◆ rng()

Prng & mal_abm_fast::CoordinatorModel::rng ( )
inline

The per-rollout PRNG sub-stream (derived from --seed). It is advanced by the seeding planners and by MosquitoSubmodel::advance_day.

◆ salinity_hi_tol_ppt()

float mal_abm_fast::CoordinatorModel::salinity_hi_tol_ppt ( ) const
inline

The species salinity high-tolerance in PSU (parts per thousand): patches whose water salinity reaches it cannot breed.

◆ set_climate_day()

void mal_abm_fast::CoordinatorModel::set_climate_day ( int32_t day_index)
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.

◆ set_host_landscape()

void mal_abm_fast::CoordinatorModel::set_host_landscape ( const HostLandscape * hosts)
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.

◆ set_salinity_hi_tol_ppt()

void mal_abm_fast::CoordinatorModel::set_salinity_hi_tol_ppt ( float ppt)
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.

◆ suitability_grid()

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.

◆ to_dataframe()

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.

◆ update_habitat_day()

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.

◆ warm_up_pluvial()

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).

◆ z_grid()

const std::vector< float > & mal_abm_fast::CoordinatorModel::z_grid ( ) const
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().


The documentation for this class was generated from the following file: