Skip to content

Phase B: Household sampling, structural edges, identity clustering#64

Merged
DeveshParagiri merged 4 commits into
mainfrom
phase-b
Feb 15, 2026
Merged

Phase B: Household sampling, structural edges, identity clustering#64
DeveshParagiri merged 4 commits into
mainfrom
phase-b

Conversation

@DeveshParagiri
Copy link
Copy Markdown
Collaborator

Summary

  • B1 — Household sampling: sample_population produces household units with correlated partner demographics (age gap, assortative mating on education/religion/politics, intermarriage rates). NPC dependents generated. households table in study DB.
  • B2 — Structural edges: Deterministic edges (partner, household, coworker, neighbor, congregation, school_parent) generated before similarity edges. Protected from calibration pruning and rewiring.
  • B3 — Identity clustering: Similarity boost for agents sharing identity-relevant attributes. conformity added as standard personality attribute.
  • Merge compatibility: Clean merge with Phase A verified. Partners share surnames, both adults get first names from Phase A's generate_name().

Files changed

  • extropy/core/models/population.pyHouseholdType, Dependent, scope on AttributeSpec
  • extropy/core/models/network.pystructural, context on Edge
  • extropy/population/sampler/households.py — Census correlation tables + sampling helpers
  • extropy/population/sampler/core.py — Household-aware sample_population (backward compat)
  • extropy/population/network/generator.py_generate_structural_edges(), identity clustering boost
  • extropy/population/network/config.pydegree_distribution_target, identity_clustering_*
  • extropy/storage/study_db.pyhouseholds table
  • extropy/cli/commands/sample.py — Household stats in report

Test plan

  • test_household_sampling.py (24 tests) — models, helpers, household sampling, backward compat, correlated demographics
  • test_structural_edges.py (15 tests) — edge generation, model enhancements, config
  • All 142 existing tests pass (zero regressions)
  • Verified clean merge with Phase A (275 tests pass combined)

🤖 Generated with Claude Code

…tering (Phase B)

B1: Household-based sampling
- Add HouseholdType enum, Dependent model, scope field on AttributeSpec
- New households.py with Census-derived correlation tables for assortative mating
- Rewrite sample_population to produce household units with correlated partner demographics
- Add households table to study_db and save/get methods
- CLI reports household type distribution

B2: Structural edge generation
- Add structural/context fields to Edge model
- Generate deterministic edges: partner, household, coworker, neighbor, congregation, school_parent
- Structural edges protected from calibration pruning and rewiring
- Add degree_distribution_target and power_law_exponent to NetworkConfig

B3: Identity clustering + conformity
- Add identity_clustering_attributes and boost to NetworkConfig
- Boost similarity for agents sharing identity-relevant attributes
- Add STANDARD_PERSONALITY_ATTRIBUTES constant (includes conformity)

All 181 tests pass (39 new + 142 existing, zero regressions).
… household

Phase A's generate_name() was only called in _sample_single_agent.
Partner agents from _sample_partner_agent now also get first names,
and partners share the primary adult's last name.
@DeveshParagiri DeveshParagiri merged commit 94ecb0e into main Feb 15, 2026
4 of 5 checks passed
@DeveshParagiri DeveshParagiri deleted the phase-b branch February 16, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant