Selects the most suitable partner for a previously selected primary partner.
Usage
findSecondaryPartner(
object,
mask,
primary_partner,
primary_position_value,
backup_position_values,
gap_start,
gap_end,
gender
)Arguments
- object
A
ReplicaStructureobject.- mask
Logical vector identifying agents eligible for partner selection.
- primary_partner
Single-row data frame or data.table representing the already-selected primary partner.
- primary_position_value
Character vector identifying household-position values eligible for secondary-partner selection.
- backup_position_values
Character vector containing alternative household-position categories that may be used when suitable candidates are unavailable in the primary pool.
- gap_start
Lower age-gap bound.
- gap_end
Upper age-gap bound.
- gender
Character string specifying the required gender of the secondary partner.
Value
A single-row data frame or data.table representing the selected partner.
Returns NULL if no suitable candidate can be found.
Details
Candidate partners are ranked according to age-gap suitability and filtered according to household-position and gender requirements.
This function is used internally by
pair_partners during couple formation.
The function:
Generates a ranked candidate list using
findCoupleCandidates.Restricts candidates to the required gender.
Selects the highest-ranked compatible candidate.
Returns
NULLif no compatible candidate is available.
Candidate suitability is determined using:
Age-gap constraints.
Household-position constraints.
Availability of agents not already assigned.
More advanced workflows may use backup-position replacement logic via:
