### To Run: need to put all files in the same directory, set the relevant directories and other parameters in each file, then run ”simulation_script.R” #### Initialization options(stringsAsFactors=FALSE) rm(list=ls()) ## set user params # paths and dirs - ## THESE PATHS NEED TO BE MODIFIED ACCORDINGLY dataDIR="//analysis" tempDIR="//analysis/temp" srcPTH="//analysis/functions.R" #NEEDS TO POINT TO "functions.R" iniPTH="//analysis/MetaData.csv" # number of replicates bsReps=100 # load dependent functions source(srcPTH) #### Preliminary processing # load data iniDF=read.table(iniPTH, sep=",", header=TRUE, as.is=TRUE) ### Main processing # run optimisation process on each parameter combination for (i in 1:nrow(iniDF)){ dir.create(paste(tempDIR,"/temp",i,sep=""),showWarnings = FALSE) tempDIRNew <- paste(tempDIR,"/temp",i,sep="") startTime=Sys.time() # load data currRAST=raster(iniDF[i, "LandFile"]) currPTS=read.table(iniDF[i, "PtsFile"], sep=",", header=TRUE) currDISTS=read.table(iniDF[i, "DistFile"], sep=",", header=TRUE) # main retDF=optimSearch(rawRAST=currRAST, gdistDF=currDISTS, ptsDF=currPTS, tempDIR=tempDIRNew, bsReps=bsReps, starts=iniDF[i, c("Alpha","Gamma")]) # export write.table(retDF, iniDF[i, "OptDir"], sep=",", row.names=FALSE) # post cat("Run ",i, " finished after", difftime(Sys.time(),startTime,units="hours"), "hours\n") }