recmapGRASP | R Documentation |
Implements a metaheuristic for recmap
based on GRASP.
recmapGRASP(Map, fitness = .recmap.fitness, n.samples = nrow(Map) * 2,
fitness.cutoff = 1.7, iteration.max = 10)
Map |
defines the input map regions formatted as |
fitness |
a fitness function |
n.samples |
number of samples. |
fitness.cutoff |
cut-off value. |
iteration.max |
maximal number of iteration. |
returns a list of the input Map
, the best solution of GRASP,
and a recmap
object containing the cartogram.
Christian Panse
Feo TA, Resende MGC (1995). "Greedy Randomized Adaptive Search Procedures." Journal of Global Optimization, 6(2), 109-133. ISSN 1573-2916. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/BF01096763")}.
recmapGA
and recmap
## US example
getUS_map <- function(){
usa <- data.frame(x = state.center$x,
y = state.center$y,
# make the rectangles overlapping by correcting
# lines of longitude distance.
dx = sqrt(state.area) / 2
/ (0.8 * 60 * cos(state.center$y * pi / 180)),
dy = sqrt(state.area) / 2 / (0.8 * 60),
z = sqrt(state.area),
name = state.name)
usa$z <- state.x77[, 'Population']
US.Map <- usa[match(usa$name,
c('Hawaii', 'Alaska'), nomatch = 0) == 0, ]
class(US.Map) <- c('recmap', 'data.frame')
US.Map
}
## Not run:
res <- recmapGRASP(getUS_map())
plot(res$Map, main = "Input Map")
plot(res$Cartogram, main = "Output Cartogram")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.