This class is used to represent data of the instances of the corresponding
multi-action planning problem. It includes several methods for retrieving the information
of the instance (such as the spatial allocation of threats and species, the cost
of management actions or the structure of the spatial connectivity across
the area where the planning is carried out. This class is created using the
inputData()
function.
No return value.
list
object containing data.
integer
. Number of possible actions.
character
name):data.frame()
. Object stored in the data
field with the corresponding name
.
The argument name
indicates the name of arguments of the
problem
function ("pu", "features", "dist_features", "threats",
"dist_threats", "sensitivity"
or "boundary").
integer
. Number of features.
character
. Names of features.
numeric
vector()
. Cost of monitoring each planning unit.
integer
. Number of planning units.
numeric
vector()
. Cost of actions each planning unit and threat.
character
. Names of threats.
integer
. Number of threats.
Print basic information of the data instance.
Call print method.
## set seed for reproducibility
set.seed(14)
## Set prioriactions path
prioriactions_path <- system.file("extdata/example_input/", package = "prioriactions")
## Load in planning unit data
pu_data <- data.table::fread(paste0(prioriactions_path,"/pu.dat"),
data.table = FALSE)
head(pu_data)
#> id monitoring_cost status
#> 1 1 2 0
#> 2 2 2 0
#> 3 3 2 0
#> 4 4 2 0
#> 5 5 2 0
#> 6 6 2 0
## Load in feature data
features_data <- data.table::fread(paste0(prioriactions_path,"/features.dat"),
data.table = FALSE)
head(features_data)
#> id target_recovery name
#> 1 1 11 feature1
#> 2 2 16 feature2
#> 3 3 8 feature3
#> 4 4 9 feature4
## Load in planning unit vs feature data
dist_features_data <- data.table::fread(paste0(prioriactions_path,"/dist_features.dat"),
data.table = FALSE)
head(dist_features_data)
#> pu feature amount
#> 1 1 3 1
#> 2 2 3 1
#> 3 3 3 1
#> 4 4 3 1
#> 5 5 3 1
#> 6 6 3 1
## Load in the threats data
threats_data <- data.table::fread(paste0(prioriactions_path,"/threats.dat"),
data.table = FALSE)
head(threats_data)
#> id name blm_actions
#> 1 1 threat1 0
#> 2 2 threat2 0
## Load in the threats distribution data
dist_threats_data <- data.table::fread(paste0(prioriactions_path,"/dist_threats.dat"),
data.table = FALSE)
head(dist_threats_data)
#> pu threat amount action_cost status
#> 1 8 2 1 2 0
#> 2 9 2 1 2 0
#> 3 10 2 1 2 0
#> 4 11 1 1 3 0
#> 5 11 2 1 4 0
#> 6 12 1 1 3 0
## Load in the sensitivity data
sensitivity_data <- data.table::fread(paste0(prioriactions_path,"/sensitivity.dat"),
data.table = FALSE)
head(sensitivity_data)
#> feature threat
#> 1 1 1
#> 2 2 1
#> 3 3 1
#> 4 4 1
#> 5 1 2
#> 6 2 2
## Load in the boundary data
boundary_data <- data.table::fread(paste0(prioriactions_path,"/boundary.dat"),
data.table = FALSE)
head(boundary_data)
#> id1 id2 boundary
#> 1 1 1 0
#> 2 2 1 1
#> 3 3 1 2
#> 4 4 1 3
#> 5 5 1 4
#> 6 6 1 5
## Create instance
problem_data <- inputData(
pu = pu_data, features = features_data, dist_features = dist_features_data,
dist_threats = dist_threats_data, threats = threats_data, sensitivity = sensitivity_data,
boundary = boundary_data
)
## Summary
print(problem_data)
#> Data
#> planning units: data.frame (100 units)
#> monitoring costs: min: 1, max: 10
#> features: feature1, feature2, feature3, feature4 (4 features)
#> threats: threat1, threat2 (2 threats)
#> action costs: min: 1, max: 10
## Use class methods
problem_data$getData("features")
#> id target_recovery name target_conservation internal_id
#> 1 1 11 feature1 0 1
#> 2 2 16 feature2 0 2
#> 3 3 8 feature3 0 3
#> 4 4 9 feature4 0 4
problem_data$getFeatureAmount()
#> [1] 4
problem_data$getFeatureNames()
#> [1] "feature1" "feature2" "feature3" "feature4"
problem_data$getMonitoringCosts()
#> [1] 2 2 2 2 2 2 2 2 1 1 3 3 3 3 3 3 2 2 2 2 4 4 4 4 4
#> [26] 3 3 3 2 2 4 4 5 4 4 4 4 3 3 3 5 5 5 5 5 5 4 4 3 3
#> [51] 6 6 6 6 6 5 5 4 4 4 7 7 7 7 6 6 5 5 4 4 8 8 8 8 7
#> [76] 6 6 5 5 4 9 9 9 8 8 7 6 6 5 5 10 10 10 9 9 8 7 6 5 5
problem_data$getPlanningUnitsAmount()
#> [1] 100
problem_data$getActionCosts()
#> [1] 2 2 2 3 4 3 3 4 2 4 2 1 1 2 2 4 2 3 3 4 2 5 2 2 2
#> [26] 2 2 2 1 5 4 2 3 3 4 2 2 2 2 2 1 5 2 4 2 3 3 3 4 3
#> [51] 5 3 3 3 3 3 1 5 2 4 2 4 3 3 4 3 5 3 7 4 4 4 4 1 4
#> [76] 2 4 3 3 4 3 5 3 6 4 7 4 5 5 6 2 3 4 4 5 6 7 8 7 7
#> [101] 3 4 5 6 6 7 8 8 9 9 5 5 6 7 8 8 9 9 9 10
problem_data$getThreatNames()
#> [1] "threat1" "threat2"
problem_data$getThreatsAmount()
#> [1] 2
problem_data$print()
#> Data
#> planning units: data.frame (100 units)
#> monitoring costs: min: 1, max: 10
#> features: feature1, feature2, feature3, feature4 (4 features)
#> threats: threat1, threat2 (2 threats)
#> action costs: min: 1, max: 10