Description Usage Arguments Details Value Author(s) Examples
View source: R/optimiseSD_greedy.R
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.
1 2 3 4 5 6 |
Some arguments are the same for all optimisation algorithms, they are marked by a *
, for detail see optimiseSD
simulations |
|
costFun |
|
locationsAll |
|
locationsFix |
|
locationsInitial |
|
aimCost |
|
aimNumber |
|
nameSave |
|
plot |
not implemented yet |
verbatim |
|
maxIterations |
maximal number of iterations, then it stops |
swap |
|
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.
A list, the first two entries are common to all optimisation algorithms, they are marked with *
, see optimiseSD
for details.
SD |
|
evaluation |
|
report |
a list of |
Kristina B. Helle, kristina.helle@uni-muenster.de
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.