Combines the spatial interaction models produced by the individual runs of
blvim() (see sim_runs()) with their summaries (see sim_logs()) in a
sim_df().
Usage
sim_df_runs(
sim,
unique = FALSE,
configuration_tolerance = NULL,
active_tolerance = NULL,
sim_column = "sim"
)Arguments
- sim
A spatial interaction model object produced by
blvim(), i.e. an object of classsimandsim_blvim- unique
A logical scalar. If
TRUE, only one model is returned for each distinct final configuration, the one with the largest potential (see details).- configuration_tolerance
NULLor a positive number: largest difference between the rescaled attractivenesses of two runs that reach the same final configuration (see details). The defaultNULLuses the value chosen byblvim(), the square root of itsprecision.- active_tolerance
NULLor a positive number: threshold on the rescaled attractivenesses above which a destination is active (see details). The defaultNULLuses \(10^{-5}\).- sim_column
the name of the
sim_listcolumn (default"sim")
Value
A sim_df with one row per run (or per final configuration when
unique is TRUE). In addition to the standard columns of sim_df(),
it contains the following columns, inserted before the sim_list
column:
run: index of the run (withunique = TRUE, the best run of the configuration);configuration: identifier of the final configuration;n_runs: number of runs that reach the configuration (only whenuniqueisTRUE);n_active: number of active destinations of the final configuration;selected: whether the run is the one returned byblvim();status,gap,evaluations: stopping status, final duality gap and number of evaluations reported by the algorithm (seesim_logs()).
The potential, iterations and converged values of sim_logs() are
given by the standard columns of the sim_df.
Details
The rows are in the order of the runs when unique is FALSE,
and in the order of the final configurations when unique is TRUE (see
sim_runs()). The final configurations are identified as explained in
sim_logs(), with the tolerances configuration_tolerance and
active_tolerance.
As the complete models are needed, multiple runs must be retained with
keep_runs = TRUE in blvim().
Examples
distances <- french_cities_distances[1:10, 1:10] / 1000
production <- rep(1, 10)
set.seed(1)
model <- blvim(distances, production, 1.5, 1 / 50,
blvim_initialise(n = 10),
bipartite = FALSE, keep_runs = TRUE
)
sim_df_runs(model)
#> alpha beta diversity potential iterations converged run configuration
#> 1 1.5 0.02 9.999985 -9.882603 7 TRUE 1 1
#> 2 1.5 0.02 9.999985 -9.882603 15 TRUE 2 1
#> 3 1.5 0.02 9.999985 -9.882603 16 TRUE 3 1
#> 4 1.5 0.02 9.999985 -9.882603 18 TRUE 4 1
#> 5 1.5 0.02 9.999985 -9.882603 13 TRUE 5 1
#> 6 1.5 0.02 9.999985 -9.882603 13 TRUE 6 1
#> 7 1.5 0.02 8.842168 -12.269134 20 TRUE 7 4
#> 8 1.5 0.02 8.827634 -11.436721 20 TRUE 8 2
#> 9 1.5 0.02 7.694467 -13.780108 15 TRUE 9 5
#> 10 1.5 0.02 8.704955 -11.446650 16 TRUE 10 3
#> n_active selected status gap evaluations sim
#> 1 10 FALSE converged 9.944287e-06 13 c(0.9872....
#> 2 10 FALSE converged 3.014473e-06 24 c(0.9872....
#> 3 10 FALSE converged 1.064560e-05 24 c(0.9872....
#> 4 10 FALSE converged 1.806911e-06 28 c(0.9872....
#> 5 10 FALSE converged 1.064817e-05 21 c(0.9872....
#> 6 10 TRUE converged 3.279968e-06 21 c(0.9872....
#> 7 9 FALSE converged 8.965801e-06 29 c(0.9875....
#> 8 9 FALSE converged 5.228435e-06 30 c(0.9872....
#> 9 8 FALSE converged 8.785174e-06 23 c(0.9908....
#> 10 9 FALSE converged 6.007746e-06 25 c(0.9997....
sim_df_runs(model, unique = TRUE)
#> alpha beta diversity potential iterations converged run configuration n_runs
#> 1 1.5 0.02 9.999985 -9.882603 13 TRUE 6 1 6
#> 2 1.5 0.02 8.827634 -11.436721 20 TRUE 8 2 1
#> 3 1.5 0.02 8.704955 -11.446650 16 TRUE 10 3 1
#> 4 1.5 0.02 8.842168 -12.269134 20 TRUE 7 4 1
#> 5 1.5 0.02 7.694467 -13.780108 15 TRUE 9 5 1
#> n_active selected status gap evaluations sim
#> 1 10 TRUE converged 3.279968e-06 21 c(0.9872....
#> 2 9 FALSE converged 5.228435e-06 30 c(0.9872....
#> 3 9 FALSE converged 6.007746e-06 25 c(0.9997....
#> 4 9 FALSE converged 8.965801e-06 29 c(0.9875....
#> 5 8 FALSE converged 8.785174e-06 23 c(0.9908....