# NOT RUN {
# 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
)
# }
# NOT RUN {
## this result is also in data(SDgreedy)
# }
Run the code above in your browser using DataLab