Learn R Programming

sensors4plumes (version 0.9.3)

mesurementsResultFunctions: Cost functions by plume-wise summary of values at locations

Description

singleDetection is average total dose of non-detected plumes.

multipleDetection is the average fraction of possible additional detections: given a plume can be detected in 10 locations and the given sensors detect it in 3, then the cost would be 7/10; this is averaged over all plumes.

earlyDetection is the average time between the plume entering the area and its detection.

Usage

singleDetection(simulations, locations, plot = FALSE)
multipleDetection(simulations, locations, plot = FALSE)
earlyDetection(simulations, locations, plot = FALSE)

Arguments

simulations

Simulations object, must contain the required data, see details.

locations

indices of locations, sensor positions

plot

if a map is generated (takes time), only implemented yet for singleDetection, else it is automatically set to FALSE

Value

"cost": global cost "costPlumes": plume-wise intermediate result, not to be interpreted as plume-specific cost

Examples

Run this code
# NOT RUN {
# load data
demo(radioactivePlumes_addProperties)

# define 'min' function without warning for empty sets
min_ = function(x, na.rm = TRUE){
  if (length(x) == 0){ 
    out = Inf
  } else {
    out = min(x, na.rm = na.rm)
  } 
  return(out)
} 

# preprocess data to provide required input  
### earliest possible detection of plume inside the area
radioactivePlumes@plumes$earliestDetection = 
  summaryPlumes(radioactivePlumes, fun = min_, kinds = "time", na.rm = TRUE)[[2]]
  
# sample locations (sensors)
sampleLocations1 = sample.int(nLocations(radioactivePlumes), 10)

# compute cost
singleDetection1 = singleDetection(
  simulations = radioactivePlumes,
  locations = sampleLocations1)
  
multipleDetection1 = multipleDetection(
  simulations = radioactivePlumes,
  locations = sampleLocations1)
  
earlyDetection1 = earlyDetection(
  simulations = radioactivePlumes,
  locations = sampleLocations1)
# }

Run the code above in your browser using DataLab