A visit does not always complete a unit: nobody is found, or access is
refused that day. The unit is then visited again on the next call, up to
max_calls calls. This function routes every call: the first through all
the units, the second through those the first left open, and so on, each
call as a routing problem of its own with the same depot and limits (see
route_fieldwork()). The outcomes are simulated from the contact rate,
for planning, or given in outcomes, to route what the field reported.
Usage
route_callbacks(
matrix,
units,
depot,
contact_rate = 0.7,
max_calls = 3,
outcomes = NULL,
max_length = Inf,
max_stops = Inf,
service_time = 0,
demand = 0,
capacity = Inf,
iterations = 200,
time_limit = NULL,
certify = 0,
alpha = 0.3,
seed = 1,
outcome_seed = seed,
cost_model = NULL
)
# S3 method for class 'fieldopt_callbacks'
tidy(x, ...)
# S3 method for class 'fieldopt_callbacks'
glance(x, ...)
# S3 method for class 'fieldopt_callbacks'
autoplot(object, ...)Arguments
- matrix
- units
Names (or indices in the matrix) of the units to visit, or a
select_units()sample, whose sampled units are visited.- depot
Name (or index) of the depot.
- contact_rate
Probability that a visit completes the unit: a single number, or a vector named by unit.
- max_calls
Maximum number of calls to a unit (1 for no call-backs).
- outcomes
Optional outcomes instead of simulated ones: a vector named by unit with the call that completes it (
NAfor a unit still open aftermax_calls).- max_length
Maximum length of a route, depot to depot: travel plus the service time of its units when
service_timeis given;Inffor none.- max_stops
Maximum units per route;
Inffor none.- service_time
Time spent at each unit (interviews, measurements), in the unit of the travel matrix: a single number, or a vector named by unit. It counts towards
max_lengthand is reported indurations.- demand
Load each unit adds to its route (interviews to make, samples to carry): a single number or a vector named by unit.
- capacity
Maximum load of a route;
Inffor none.- iterations
Offspring of the genetic search (ignored when the instance is solved exactly or when
time_limitis given).- time_limit
Seconds of search instead of
iterations(NULLfor none); the only stopping rule of the"vrpr"engine (default 5 s).- certify
Seconds allowed to prove each call's tour optimal, as in
route_fieldwork(); off by default.- alpha
Greediness of the constructions that seed the population, in
[0, 1](0 greedy, 1 random).- seed
Seed of the solver (advanced by one at each call).
- outcome_seed
Seed of the simulated outcomes.
- cost_model
Optional
field_cost_model()to price the solution.- x, object
A
fieldopt_callbacks.- ...
Unused.
Value
An object of class fieldopt_callbacks: calls (a tibble with
one row per call: call, visited, completed, open after the call,
routes, travel, lower_bound, gap and, with a cost model,
cost), routes (the fieldopt_routes of each call), outcome (a
tibble with unit and completed_at), total (travel over the calls),
visits, n_units, completed, completion (share completed),
expected (the multipliers of Hansen, Hurwitz and Madow for a single
contact rate: visits, travel, completed), cost (when a model is
given) and the inputs. tidy(), glance() and autoplot() are
available.
Details
Hansen, Hurwitz and Madow (1953, Vol. I, Chapter 6, Section 12) priced the
call-backs by adding to the travel among n units, C0 sqrt(n), one term
per call, C0 sqrt(q n) + C0 sqrt(q^2 n) + ..., with q the share of
units a call leaves open: fewer units, but sparser, so travel falls more
slowly than the number of visits. expected holds those multipliers for
comparison with what the routing finds; the routing also accounts for the
trips from the depot, the route limits and the actual places of the units
left open.
With a cost model, per_travel and per_route are charged on every
call, per_unit on every visit (completed or not), and per_interview
only for the units completed.
References
Hansen, M. H., Hurwitz, W. N. and Madow, W. G. (1953). Sample Survey Methods and Theory, Vol. I, Chapter 6, Sections 11-15. Wiley.
Examples
set.seed(1)
pts <- data.frame(
unit = c("depot", paste0("s", 1:30)),
x = c(5, runif(30, 0, 10)), y = c(5, runif(30, 0, 10))
)
m <- travel_matrix(pts, method = "euclidean")
cb <- route_callbacks(m,
units = paste0("s", 1:30), depot = "depot", contact_rate = 0.6,
max_calls = 3, iterations = 30
)
cb
#>
#> ── Field routes with call-backs ────────────────────────────────────────────────
#> 30 units from "depot", at most 3 calls (simulated outcomes): 47 visits, 28
#> completed (93.3%), total travel 98.72 distance.
#> Call 1: 30 visited, 17 completed, 1 route, travel 43.98, gap 3.7% to the lower
#> bound.
#> Call 2: 13 visited, 9 completed, 1 route, travel 32.31, proven optimal.
#> Call 3: 4 visited, 2 completed, 1 route, travel 22.43, proven optimal.
#> Travel is 2.24 times that of the first call (Hansen, Hurwitz and Madow's
#> square-root terms give 2.03; visits are 1.57 per unit).
cb$calls
#> # A tibble: 3 × 8
#> call visited completed open routes travel lower_bound gap
#> <int> <int> <int> <int> <int> <dbl> <dbl> <dbl>
#> 1 1 30 17 13 1 44.0 42.4 3.70e- 2
#> 2 2 13 9 4 1 32.3 32.3 2.20e-16
#> 3 3 4 2 2 1 22.4 22.4 1.58e-16