recmapGRASP: Greedy Randomized Adaptive Search Procedure Wrapper Function...

View source: R/recmap.R

recmapGRASPR Documentation

Greedy Randomized Adaptive Search Procedure Wrapper Function for recmap

Description

Implements a metaheuristic for recmap based on GRASP.

Usage

recmapGRASP(Map, fitness = .recmap.fitness, n.samples = nrow(Map) * 2, 
  fitness.cutoff = 1.7, iteration.max = 10)

Arguments

Map

defines the input map regions formatted as data.frame having the column names c('x', 'y', 'dx', 'dy', 'z', 'name') as described above.

fitness

a fitness function function(idxOrder, Map, ...) returning a number which as to be maximized.

n.samples

number of samples.

fitness.cutoff

cut-off value.

iteration.max

maximal number of iteration.

Value

returns a list of the input Map, the best solution of GRASP, and a recmap object containing the cartogram.

Author(s)

Christian Panse

References

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")}.

See Also

recmapGA and recmap

Examples


## 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)


cpanse/recmap documentation built on Jan. 3, 2024, 11:45 p.m.