# This script contains the management procedure function: mngmtprocedure
# ToDo:
# search ??? and address questions/issues
# search placeholder for variables/structures where info still needed
#' @title Determine management procedure settings
#'
#' @description This function takes inputs for recreational summer flounder management and translates these inputs to produce and adjust input control settings.
#'
#' @param decisionArea A string specifying the management decision areas for the simulation, no default.
#' "Coastline" = All nine states in which summer flounder are caught combined to form a single decision area.
#' "FiveArea" = Connecticut, New York and New Jersey form a combined decision area; Delaware, Maryland and Virginia form a combined decision area; Massachusetts, Rhode Island and North Carolina each treated as independent decision areas.
#' "SixArea" = Connecticut and New York form a combined decision area; Delaware, Maryland, and Virginia form a combined decsion area; Massachusetts, Rhode Island, New Jersey and North Carolina each treated as independent decision areas.
#' "IndividualStates" = All nine states in which summer flounder are caught are treated as independent decision areas
#' @param quotaMethod A string specifying which method should be used to allocate quota to decision areas: "HistoricRef" "UpdatedRef" or "BioAvailability", no default.
#' "HistoricRef" = Quota allocated based on participation in the recreational Summer flounder fishery during historic reference period from 1980-1989 as is done in the current (2018) stock assessment.
#' "UpdatedRef" = Quota allocated based on participation in the recreational Summer flounder fishery during updated reference period during most recent ten years from 2010-2019.
#' "BioAvailability" = Quota allocation to decision areas based on proportional biomass availability in each state.
#' @param TAC A number representing the total allowable catch based on the most recent simulated stock assessment, no default
#' @param bioAvailable Vector of proportional biomass availablity in each state listed in order: MA, RI, CT, NY, NJ, DE, MD, VA, NC, no default only required when quotaMethod = "BioAvailability".
@param iYear A number specifying the simulation year.
@param CatchObs A matrix of catch observations by year (rows) and state (columns in the following order: MA, RI, CT, NY, NJ, DE, MD, VA, NC), no default.
@param BagSize A matrix of management settings for bag size by year (rows) and state (columns in the following order: MA, RI, CT, NY, NJ, DE, MD, VA, NC), no default.
@param MinSize A matrix of management settings for minimum landing size by year (rows) and state (columns in the following order: MA, RI, CT, NY, NJ, DE, MD, VA, NC), no default.
@param SeasonLength A matrix of management settings for season length (days) by year (rows) and state (columns in the following order: MA, RI, CT, NY, NJ, DE, MD, VA, NC), no default.
@param InputMngmtMethod A string specifying what input controls should be adjusted selected from the following options: "AdjustBagSize", "AdjustMinSize", "AdjustSeason", "AdjustAll", "AdjustMixed", and "AdjustSpecific". No default.
"AdjustBagSize" Specifies that only bag size should be adjusted to alter recreational catch, minimum landing size and season length remain unchanged throughout simulated projection.
"AdjustMinSize" Specifies that only minimum landing size should be adjusted to alter recreational catch, bag size and season length remain unchanged throughout simulated projection.
"AdjustSeason" Specifies that only season length should be adjusted to alter recreational catch, bag size and minimum landing size remain unchanged throughout simulated projection.
"AdjustAll" Specifies that bag size, minimum landing size, and season length should all be be adjusted to alter recreational catch.
"AdjustMixed" Randomly select to adjust between 0 and 3 input controls for each state & then randomly select that number of input controls from: bag size, minimum size, and season length to implement together in each state, this setting only functions if DecisionArea == "StatesIndependent".
"AdjustSpecific" Specifies that bag size, minimum landing size, and season length be fixed at specified settings for entire projection to test the settings of interest, requires an additional argument: adjustspecific.
@param adjustspecific Optional matrix required by InputMngmtMethod = "AdjustSpecific" setting, contains specific settings for bag size, minimum landing size, and season length (rows labeled: "bagsize" "minsize" "seasonlength") by state (columns in the following order: MA, RI, CT, NY, NJ, DE, MD, VA, NC), no default.
#' @return A list containing:
#' A number for commercial quota
#' A vector of recreational quota by decision area
BagSize, MinSize, and SeasonLength matrices with updated management settings appended in the final row
#' @family management procedure functions
@examples
#'
mngmtprocedure <- function(decisionArea = NULL,
quotaMethod = NULL,
iYear = NULL,
CatchObs = NULL,
BagSize = NULL,
MinSize = NULL,
SeasonLength = NULL,
InputMngmtMethod = NULL, ...){
# Set decision area indexing
decisionareaindex <- decisionarea(decisionArea = DecisionArea,
NStates = ncol(BagSize)) # returns decision area indexing that remains consistent throughout simulation
# Allocate quota to decision areas
quotaOutput <- allocatequota(quotaMethod = quotaMethod,
TAC = TAC,
areaindex = decisionareaindex,
bioAvailable = bioAvailable) # returns recreational quota by decision area and total commercial quota
# # Adjust input controls
# controlOutput <- inputcontrols(areaindex = decisionareaindex,
# CatchObs = CatchObs,
# areaquotas = quotaOutput$areaQuotas,
# iYear = iYear,
# BagSize = BagSize,
# MinSize = MinSize,
# SeasonLength = MinSize,
# InputMngmtMethod = InputMngmtMethod, ...)
return(list(AreaQuota = quotaOutput$areaQuotas, CommercialQuota = quotaOutput$commercialQuota,
# BagSize = controlOutput$BagSize, MinSize = controlOutput$MinSize, SeasonLength=controlOutput$SeasonLength))
}
# ##### Test Management #####
# # Read in test data
# test_Bag <- read.csv("/Users/ahart2/Research/temp_Summer_Flounder_MSE/Data/RecBagSize.csv", header = TRUE, row.names = 1) # ??? correct path
# test_Min <- read.csv("/Users/ahart2/Research/temp_Summer_Flounder_MSE/Data/RecMinSize.csv", header = TRUE, row.names = 1) # ??? correct path
# test_Season <- read.csv("/Users/ahart2/Research/temp_Summer_Flounder_MSE/Data/RecSeasonLength.csv", header = TRUE, row.names = 1) # ??? correct path
# test_Catch <- read.csv("/Users/ahart2/Research/temp_Summer_Flounder_MSE/Data/RecreationalCatch.csv", header = TRUE, row.names = 1) # ??? correct path
# test_Quota <- 6384158 # this is the 2018 total commercial & recreational quota
# test_Availability <- matrix(c(0.1,0.1,0.1,0.2,0.2,0.2,0.3,0.3,0.3,0.4,0.4,0.4,0.5,0.5,0.5,0.6,0.6,0.6,0.7,0.7,0.7,0.8,0.8,0.8,0.9,0.9,0.9), ncol=9, nrow=3, byrow = TRUE)
#
# # ??? test function
# mngmtprocedure(DecisionArea = "StatesIndependent",
# QuotaMethod = "BioAvailability",
# Availability = test_Availability,
# TotalQuota = test_Quota,
# iYear = 2, # iYear=1 tests random selection of starting values, iYear=2 tests adjustment of only 1 setting
# CatchObs = test_Catch,
# BagSize = test_Bag,
# MinSize = test_Min,
# SeasonLength = test_Season,
# InputMngmtMethod = "AdjustBagSize") # ??? finish testing, tested already: "AdjustBagSize", "AdjustMinSize", "AdjustSeason"
#
# # ??? test function
# AreaIndex <- decisionarea(DecisionArea = "StatesIndependent", NStates = 9)
#
# # ??? test function
# store <- allocatequota(QuotaMethod = "BioAvailability", Availability = test_Availability, areaindex = AreaIndex, TotalQuota = test_Quota)
#
# # ??? test function
# inputcontrols(areaindex = AreaIndex, CatchObs = test_Catch, areaquotas = store$areaQuotas, iYear=2, BagSize = test_Bag,
# MinSize = test_Min, SeasonLength = test_Season, InputMngmtMethod = "AdjustSeason")
#
#
# ########## example data sets #####################
#
# # Data must have same dimensions
# BagSize_example_matrix <- matrix(nrow=5,ncol=9,c(1,2,3,4,5,6,7,8,9,10,rep(1,35))) #FullMSEInput
# colnames(BagSize_example_matrix) <- c("MA", "RI", "CT", "NY", "NJ", "DE", "MD", "VA", "NC")
# rownames(BagSize_example_matrix) <- c("year1", "year2", "year3", "year4", "year5")
#
# adjustspecific_example <- matrix(ncol=9, nrow=3, byrow = TRUE, data = c(1,1,1,2,2,2,3,3,3, 4,4,4,5,5,5,6,6,6, 7,7,7,8,8,8,9,9,9))
# rownames(adjustspecific_example) <- c("bagsize", "minsize", "seasonlength")
# # adjustspecific is optional
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.