Skip to content

Commit

Permalink
projections and ref points with mulitple fleets now fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
timjmiller committed Nov 10, 2022
1 parent c7194c6 commit 65c0130
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion R/fit_wham.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ fit_wham = function(input, n.newton = 3, do.sdrep = TRUE, do.retro = TRUE, n.pee
mod <- check_which_F_age(mod)
mod <- check_FXSPR(mod)
print(mod$env$data$n_fleets)
if(mod$env$data$n_fleets == 1 & mod$env$data$do_proj==1) mod <- check_projF(mod) #projections added.
#if(mod$env$data$n_fleets == 1 & mod$env$data$do_proj==1) mod <- check_projF(mod) #projections added.
if(mod$env$data$do_proj==1) mod <- check_projF(mod) #projections added.
if(do.sdrep) mod <- do_sdrep(mod, save.sdrep = save.sdrep)

# retrospective analysis
Expand Down
3 changes: 2 additions & 1 deletion R/project_wham.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ project_wham = function(model, proj.opts=list(n.yrs=3, use.last.F=TRUE, use.avg.
mod$rep = mod$report()
mod$parList <- mod$env$parList(x=mle)
mod <- check_FXSPR(mod)
if(mod$env$data$n_fleets == 1) mod <- check_projF(mod) #projections added.
#if(mod$env$data$n_fleets == 1) mod <- check_projF(mod) #projections added.
mod <- check_projF(mod) #projections added.
if(is.fit & do.sdrep) # only do sdrep if no error and the model has been previously fitted.
{
mod$sdrep <- try(TMB::sdreport(mod))
Expand Down
4 changes: 2 additions & 2 deletions src/helper_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ vector<Type> get_waa_y(array<Type> waa, int y, int na, int pointer){
}

template <class Type>
vector<Type> get_waacatch_y(array<Type> waa, int y, int na, vector<int> pointer){
matrix<Type> get_waacatch_y(array<Type> waa, int y, int na, vector<int> pointer){
matrix<Type> waay(pointer.size(), na);
for(int f = 0; f< pointer.size(); f++) for(int a = 0; a < na; a++) waay(f,a) = waa(pointer(f)-1, y, a);
return(waay);
Expand Down Expand Up @@ -937,7 +937,7 @@ matrix<Type> get_F_proj(int y, int n_fleets, vector<int> proj_F_opt, array<Type>
percentFMSY: percentage (0-100) of FMSY to use in catch.
*/
int n_toavg = avg_years_ind.size();
int n_ages = waacatch.size();
int n_ages = waacatch.cols();
int proj_F_opt_y = proj_F_opt(y-n_years_model);

//proj_F_opt == 1, last year F (default)
Expand Down
4 changes: 2 additions & 2 deletions src/wham_v0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,9 @@ Type objective_function<Type>::operator() ()
waacatch = get_waacatch_y(waa, yi, n_ages, waa_pointer_fleets);
for(int f = 0; f < n_fleets; f++) {
CAA_proj(f,i,a) = NAA(yi,a) * FAA(yi,f,a) * (1 - exp(-ZAA(yi,a)))/ZAA(yi,a);
catch_proj(i,f) += waacatch(f,a) * CAA_proj(i,a);
log_catch_proj(i,f) = log(catch_proj(i,f) + Type(1.0e-15));
catch_proj(i,f) += waacatch(f,a) * CAA_proj(f,i,a);
}
for(int f = 0; f < n_fleets; f++) log_catch_proj(i,f) = log(catch_proj(i,f) + Type(1.0e-15));
//CAA_proj(i,a) = NAA(yi,a) * FAA_tot(yi,a) * (1 - exp(-ZAA(yi,a)))/ZAA(yi,a);
//waacatch(a) = waa(waa_pointer_totcatch-1, yi, a);
}
Expand Down

0 comments on commit 65c0130

Please # to comment.