Add constrained accessibility wrapper#59
Merged
rafapereirabr merged 4 commits intoipeaGIT:mainfrom Dec 7, 2025
Merged
Conversation
…rthcoming Soukhov et al. 2025. NOTE: attempted to copy the formatting pattern from spatial_availability.R.
Removed abstracts and file paths from references.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces an exported wrapper function
constrained_accessibility()and three internal helpers implementing the family of accessibility measures introduced in the "Family of accessibility measures derived from spatial interaction principles" by Anastasia Soukhov, Rafael H. M. Pereira, Christopher D. Higgins and Antonio Páez (2025):total_constrained()- total-constrained balancing factor, can be interpreted as associated with Wilson (1971)'s 'unconstrained' modelsingly_constrained()- uses Wilson (1971)'s single constraint (demand or supply side)doubly_constrained()- uses Wilson (1971)'s doubly-constrained model using iterative proportional fittingThese functions follow the patterns of existing functions like
spatial_availability()and support grouping, flexible decay functions, and optional detailed OD-level (flow) or aggregate (by origin or destination) outputs.Mathematical Basis
Total-Constrained
kappa_tot_ij = (W_j * f(c_ij)) / sum_k(W_k * f(c_ik))
Accessibility_i = sum_j(kappa_tot_ij * Total Opportunities)
Sum of accessibility equals total opportunities (supply) in the region. Note,
return_demand_side = TRUE(market potential variant) is also available.Singly-Constrained
Supply-constrained (destination totals fixed) when
return\_demand\_side = FALSE:kappa_singly_ij = (Demand_i * f(c_ij)) / sum_k(Demand_k * f(c_kj))
Accessibility_ij = kappa_singly_ij * Supply_j
Demand-constrained (origin totals fixed) when
return\\\_demand\\\_side = TRUE:hatkappa_singly_ij = (Supply_j * f(c_ij)) / sum_k(Supply_k * f(c_ik))
Accessibility_ij = hatkappa_singly_ij * Demand_i
In either case, totals match either the demand at each origin or supply at each destination, depending on variant.
Doubly-Constrained
Accessibility_ij = A_i * B_j * O_i * D_j * f(c_ij)
A_i = 1 / sum_j(B_j * D_j * f(c_ij))
B_j = 1 / sum_i(A_i * O_i * f(c_ij))
Iterative proportional fitting updates (A_i) and (B_j) until convergence. This ensures that row sums equal (O_i) (demand) and column sums equal (D_j) (supply).
Note, only OD-level outputs are available (as aggregate outputs just match inputs).
Usage Examples