| frlm | R Documentation |
Solves the Flow Refueling Location Model to optimally place refueling facilities along network paths. This model maximizes the volume of origin-destination flows that can be served given vehicle range constraints.
frlm(
flows,
candidates,
network = NULL,
vehicle_range,
n_facilities,
method = c("greedy"),
verbose = FALSE
)
flows |
A data frame or sf object containing flow information with columns:
|
candidates |
An sf object with candidate facility locations (points). |
network |
Optional. A distance matrix between candidates. If NULL (default), Euclidean distances are computed from candidate geometries. For network distances, compute externally using packages like r5r or dodgr and pass the resulting matrix here. |
vehicle_range |
Numeric. Maximum vehicle range (same units as network distances). |
n_facilities |
Integer. Number of facilities to place. |
method |
Character. Optimization method: "greedy" (default and currently only option). |
verbose |
Logical. Print progress messages. |
The Flow Refueling Location Model (Kuby & Lim, 2005) addresses the problem of locating refueling stations for range-limited vehicles (e.g., electric vehicles, hydrogen fuel cell vehicles) along travel paths.
A flow (origin-destination path) is "covered" if a vehicle can complete the round trip with refueling stops at the selected facilities. The model assumes:
Vehicles start at the origin with half a tank (can travel R/2)
At each open station, vehicles refuel to full (can travel R)
The round trip must be completable without running out of fuel
For a flow to be covered, three conditions must be met:
First open station must be within R/2 from origin (half-tank start)
Each subsequent open station must be within R of the previous
Last open station must be within R/2 of destination (to allow return)
This implementation uses a greedy heuristic that iteratively selects the facility providing the greatest marginal increase in covered flow volume.
A list with class "spopt_frlm" containing:
facilities: The candidates sf object with a .selected column
selected_indices: 1-based indices of selected facilities
coverage: Coverage statistics
Metadata is stored in the "spopt" attribute.
For simple cases, you can provide:
flows: Data frame with origin, destination, volume
candidates: sf points for potential facility locations
network: Pre-computed distance matrix (optional)
Kuby, M., & Lim, S. (2005). The flow-refueling location problem for alternative-fuel vehicles. Socio-Economic Planning Sciences, 39(2), 125-145. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.seps.2004.03.001")}
Capar, I., & Kuby, M. (2012). An efficient formulation of the flow refueling location model for alternative-fuel stations. IIE Transactions, 44(8), 622-636. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/0740817X.2011.635175")}
# Simple example with distance matrix
library(sf)
# Create candidate locations
candidates <- st_as_sf(data.frame(
id = 1:10,
x = runif(10, 0, 100),
y = runif(10, 0, 100)
), coords = c("x", "y"))
# Create flows (using candidate indices as origins/destinations)
flows <- data.frame(
origin = c(1, 1, 3, 5),
destination = c(8, 10, 7, 9),
volume = c(100, 200, 150, 300)
)
# Solve with vehicle range of 50 units
result <- frlm(flows, candidates, vehicle_range = 50, n_facilities = 3)
# View selected facilities
result$facilities[result$facilities$.selected, ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.