optimiseSD_manual: Plot cost map for interactive adding and deleting of sensors

Description Usage Arguments Value Author(s) Examples

View source: R/optimiseSD_manual.R

Description

Given a costMap function and a set of sensors it computes the cost map and plots it. Then the user can interactively add or delete sensors and plot the resulting cost and cost map..

Usage

1
2
3
4
5
6
7
optimiseSD_manual(simulations, costFun,
  locationsAll = 1:nLocations(simulations), locationsFix = integer(0),
  locationsInitial = integer(0),
  aimCost = NA, aimNumber = NA,
  nameSave = NA, plot = TRUE, verbatim = FALSE,
  costMap = NA, maxIterations = 10, 
  valuesPlot = integer(0), colors = grey.colors)

Arguments

Some arguments are the same for all optimisation algorithms, they are marked by a *, for detail see optimiseSD. Others are directly forwarded to rbga.bin, they are marked by **

simulations

*

costFun

* ignored - cost is derived from costMap

locationsAll

*

locationsFix

*

locationsInitial

*

aimCost

* ignored

aimNumber

* ignored

nameSave

* ignored

plot

* ignored

verbatim

ignored

costMap

A function to return a list of
"cost": cost in general, a single value,
"costLocations": a cost value for each location(vector of length equal to nLocations(simulations)).
Needs to have the same parameters (simulations, locations) as costFun and may also be prepared by replaceDefault with type = "costFun.optimiseSD".

maxIterations

maximal number of iterations to add or delete sensors

valuesPlot

names of values in the data associated with the locations of simulations to be plotted in addition to the cost map

colors

color ramp for plotting - a function like grey.colors)

Value

A list, the first two entries are common to all optimisation algorithms, they are marked with *, see optimiseSD for details.

SD

* best sampling designs

evaluation

* cost and size of SD

report

a list of
cost: cost in each iteration, based on fix and current sensors
identify: identity of points chosen in each iteration; these identities are 'raw' -for "SpatialIndexDataFrame" and "SpatialPolygridDataFrame" they may differ from the indices of the actual locations as data is transformed into SpatialPixels before plotting, they may also include invalid and multiple choices.
locationsCurrent: indices of sampling design in each iteration; locationsFix are not included

Author(s)

Kristina B. Helle, kristina.helle@uni-muenster.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# prepare data and functions
data(radioactivePlumes)

meanFun = function(x){mean(x, na.rm = TRUE)}
spatialSpreadMinDist = replaceDefault(
  spatialSpread,
  newDefaults = list(
    weightByArea = TRUE,
    fun = minimalDistance,
    fun_R = meanFun),
  type = "costFun.optimiseSD"
  )[[1]]

radioactivePlumes@locations@data$p1 = getValues(
  subset(radioactivePlumes, plumes = 1, kinds = 1)@values)

optimSD_man_minDist = replaceDefault(
  optimiseSD_manual,
  newDefaults = list(
    costMap = spatialSpreadMinDist
    )
)[["fun"]]

## Not run: 
## interactive optimisation
# inside optimiseSD
optSD_manual1 = optimiseSD(simulations = radioactivePlumes,
                          costFun = spatialSpreadMinDist,
                          optimisationFun = optimSD_man_minDist,
                          locationsFix = seq(1, 2001, 300),
                          locationsInitial = seq(1, 2001, 70),
                          locationsAll = setdiff(1:2001, seq(1,2001, 30)))

# directly using optimiseSD_manual
optSD_manual2 = optimiseSD_manual(simulations = radioactivePlumes,
                                  costFun = spatialSpreadMinDist,
                                  costMap = spatialSpreadMinDist,
                                  locationsFix = seq(1, 2001, 300),
                                  locationsInitial = seq(1, 2001, 70),
                                  locationsAll = setdiff(1:2001, seq(1,2001, 30)))

## End(Not run)
## the result of such a manual optimisation is in data(SDmanual)

KristinaHelle/sensors4plumes documentation built on May 7, 2019, 12:31 p.m.