optimiseSD_greedy: Greedy optimisation algorithm

Description Usage Arguments Details Value Author(s) Examples

View source: R/optimiseSD_greedy.R

Description

Runs greedy optimisation for a given Simulations object and cost function. The aim may be given as a number of sensors or as cost value, then the algorithm determines if sensors need to be added or deleted. Greedy optimisation adds (or respectively deletes) sensors one by one, always checking all possibilities and adding/deleting the sensor that yields minimal cost, given the already defined sensors; it stops when the aim is reached. In addition this algorithm can continue search when the greedy optimum is found by adding and deleting sensors in turns, this can help to get rid of redundant sensors and thus may improve the result. The algorithm may take into account fix sensors and start from a given initial sensor set.

Usage

1
2
3
4
5
6
optimiseSD_greedy(simulations, costFun,
  locationsAll = 1:nLocations(simulations), locationsFix = integer(0),
  locationsInitial = integer(0),
  aimCost = NA, aimNumber = NA,
  nameSave = NA, plot = FALSE, verbatim = FALSE,
  maxIterations = 100, swap = FALSE)

Arguments

Some arguments are the same for all optimisation algorithms, they are marked by a *, for detail see optimiseSD

simulations

*

costFun

*

locationsAll

*

locationsFix

*

locationsInitial

*

aimCost

*, ignored

aimNumber

*

nameSave

*

plot

not implemented yet

verbatim

logical, not implemented yet

maxIterations

maximal number of iterations, then it stops

swap

logical if algorithm continues, when greedy optimum is found, by adding and deleting sensors in turns

Details

In general the function is used within the wrapper optimiseSD. The parameters maxIterations and swap are specific to optimiseSD_greedy, they may be changed beforehand via replaceDefault with type = "optimisationFun.optimiseSD"; all other parameters are forwarded from optimiseSD.

If aimCost and aimNumber are given, aimNumber is ignored with a warning.

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
SDsa list of the sampling designs of all iterations
evalSDs a data.frame: cost and number of sensors for the sampling designs SDs.

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
# optimisation function: is to be used inside of optimiseSD
# change parameters 'swap' and 'maxIterations'
optGr_20_true = replaceDefault(
  optimiseSD_greedy,
  newDefaults = list(
    maxIterations = 20,
    swap = TRUE)
)
# cost function
meanFun = function(x){mean(x, na.rm = TRUE)}
minDist = replaceDefault(
  spatialSpread, newDefaults = list(
    fun = minimalDistance,
    fun_R = meanFun
  ), type = "costFun.optimiseSD"
)[["fun"]]

# define possible, fix, and initial sensors
data(SimulationsSmall)
I = nLocations(SimulationsSmall)
set.seed(9345872)
locInit1 = sample.int(I, 2)
locKeep1 = sample(setdiff(1:I, locInit1), 2)
locAll1 = c(sample(setdiff(1:I, c(locInit1, locKeep1)), 4), locInit1)

# run optimisation
## Not run: 
## takes some time
optSD_greedy = optimiseSD(
  simulations = SimulationsSmall,
  costFun = minDist,
  optimisationFun = optGr_20_true[[1]],
  locationsAll = locAll1,
  locationsFix = locKeep1,
  locationsInitial = locInit1,
  aimNumber = 7
)


## End(Not run)
## this result is also in data(SDgreedy)

sensors4plumes documentation built on May 1, 2019, 10:27 p.m.