Skip to content

Partition demand configuration #1587

Description

@szu-yun-ko

Summary

Add a partition demand setting so users can choose which outputs are materialized: pooled only (same as existing output), female-only, male-only, or both sexes. This is separate from infrastructure, which works on how strata are defined, indexed, and stored. Configuring partition demand tells the model which partition slices should be written to DQs, and demand-based computation is the key to maintaining model efficiency after partitions are added.

Current status

After the PR #1581:

  • PartitionSpec, GroupSelector, and IndexLayout exist, each Population is initialized with a default sex partition in CatchAtAge::Initialize().
  • Fleet *_by_partition containers are registered with DimensionInfo {"n_strata", "n_years", "n_ages"}.
  • No user-facing option controls partitioning.
  • Evaluation still fills pooled DQs only, partitioned containers are never written.

Implementation details

PR Scope: demand configuration and routing only, starting with the sex-ratio model (scalar split). The goal is to split pooled values into partitioned containers on write when demand requires it. Explicit/implicit two-sex dynamics are out of scope at the moment.

Demand representation

Recap: Demand maps to the existing GroupSelector API. "pooled" means no partitioned output. "female" / "male" select one stratum. "both" uses a wildcard and expands to all strata. Default is "pooled" for backward compatibility.

  • Add PartitionDemand on Population.
  • Provide conversion from user demand to GroupSelector per axis.
  • Add helper: requested_strata() returning std::vector<size_t> via partition_spec.expand_group_to_strata().
  • Set the default partition demand to pooled.

R / interface exposure

Recap: Users configure demand at the population (or model) level from R, similar to other Population settings. The R interface should use clear, string type names rather than integer codes. C++ stores the resolved GroupSelector or demand enum.

population <- Population()
population$partition_demand <- "pooled"   # default
# population$partition_demand <- "female"
# population$partition_demand <- "male"
# population$partition_demand <- "both"
  • Expose partition_demand on Population Rcpp interface
  • Validate allowed values ("pooled", "female", "male", "both").
  • Wire through create_default_parameters.R / initialize_modules.R if using the standard parameter path.

Conditional DQ registration

Recap: Infrastructure currently registers all *_by_partition fleet DQs unconditionally. Demand should gate registration so pooled-only users pay no storage or reporting cost.

  • Gate *_by_partition registration in rcpp_models.hpp on partition_demand != pooled.
  • Update test_population_test_fixture.hpp InitializeCAA() to reflect demand.
  • Add gtests to check that pooled demand creates no *_by_partition keys while "both" creates partitioned DQs present with correct size.

Evaluation routing (sex-ratio model)

Recap: When demand is not "pooled", keep pooled evaluation unchanged, then split into partitioned containers for requested strata only, using proportion_female and index_layout.i_stratum_age_year().

  • Route CalculateLandingsNumbersAA, CalculateLandingsWeightAA, and index equivalents
  • Write only strata in requested_strata()
  • Gtests: if female-only demand is configured, male stratum stays zero and vice versa. The pooled demand output should be identical to the existing model behavior.

Notes and Design Directions

At this stage this issue is drafted mainly off the GSoC Project Proposal to keep track of project progress prior to the midterm evaluation. Details will be modified based on the final implementation of PR #1581.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions