--- title: "Cost Breakdown" author: "Vignette Author" date: "`r Sys.Date()`" output: html_document: code_folding: hide theme: united vignette: > %\VignetteIndexEntry{Cost Breakdown} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=T, warning=F, message=F} knitr::opts_chunk$set( eval=T, collapse = TRUE, message =F, warning =F, fig.width = 8, fig.height = 8, comment = "#>" ) library(dplyr) library(purrr) library(tidyr) library(ggplot2) library(sf) library(BASSr) library(patchwork) bcv <- BASSr::cost_vars ``` ## Cost model parts The cost model is comprised of three access types: * Truck * ATV * Helicopter The basic cost is based on the number of ARUs to be deployed per study area ($N$). The base rate is 30. The cost of accessing a site is the sum of the cost of surveying a site by truck, atv and helicopter, each weighted by the proportion that is accessible by that access type. Truck access is assumed to be preffered first, then ATV, then helicopter. $$ C = \sum p_iC_i = p_TC_T + p_AC_A + p_HC_H $$ Truck access is based on primary roads plus a buffer of 1000m. A truck cost is based on the following formula. $$ C_{T} = \frac{T_dn_c N}{N_Tn_c} = \frac{T_d N}{N_T} $$ Where $T_d$ is the daily cost of truck usage, set initially to `r bcv$truck_cost_per_day`. $N_T$ is the number of ARUs a truck crew can deploy (`r bcv$truck_arus_per_crew_per_day`). This can be changed later to allow for differing daily costs based on the number of truck crews, however as written now, the number of crews ($n_c$) increases deployment rate and cost equivanetly and therefore drops out of the equation. The cost of ATV deployment is equivalent to truck costs in structure, but the rate of deployment and costs are different between deployment types: $$ C_{A} = \frac{A_dn_c N}{N_An_c} = \frac{A_d N}{N_A} $$ The cost of helicopter deployment has more details. It can be broken down into four pieces: 1. The cost per litre of fuel - $C_l$ 2. The cost of setting up a basecamp - $C_b$ 3. The cost of moving to/from the study area - $C_{f}$ 4. The cost of moving within the study area - $C_{sa}$ The distances between the study area, basecamp and nearest airport drive most of the cost. The distance between the nearest airport and the study area is $D_{s-a}$, between the study area and basecamp $D_{s-b}$, and between basecamp and the airport $D_{a-b}$. If the distance from the airport to the study area is less than a maximum helicopter range $D_{s-a}% runcost(maxARUs,.) cost_test <- bind_rows(cost_heli, cost_truck, cost_atv, cost_heli2,cost_heli3, cost_mixed) %>% group_by(narus) %>% mutate(logcost = log10(RawCost), scLogCost = logcost / max(logcost)) %>% ungroup ggplot(cost_test, aes(narus,RawCost, colour = StudyAreaID )) + geom_line(size = 1) + scale_colour_viridis_d(direction = -1) + labs(colour = "Access type", x = "Number of ARUs deployed", y = "Raw Cost Value") # scale_y_continuous(trans = 'log1p') ``` ```{r fig2, fig.cap = "The same calculation shown in the figure above but now cost is shown as the cost relative to the most expensive access type for each ARU deployment size (here it is 'Helicopter - Fuel Cache' for all ARU numbers). The scaled cost is calculated as the raw cost divided by the maximum raw cost for that ARU number."} ggplot(cost_test, aes(narus,scLogCost, colour = StudyAreaID )) + geom_line(size = 1) + scale_colour_viridis_d(direction = -1) + labs(colour = "Access type", x = "Number of ARUs deployed", y = "Scaled Log Cost") ``` -------------------------- ## Baseline variables ```{r, results='asis'} BASSr::cost_vars %>% as_tibble() %>% dplyr::select(-helicopter_airport_cost_per_l) %>% pivot_longer(names_to = "Variable", values_to = "Value", cols = everything()) %>% # BASSr::cost_vars$helicopter_airport_cost_per_l knitr::kable() ``` With current version, you can adjust cost of fuel based on airport type ```{r, results='asis'} BASSr::cost_vars$helicopter_airport_cost_per_l %>% knitr::kable() ```