gadget-framework / gadget3

TMB-based gadget implemtation
GNU General Public License v2.0
8 stars 6 forks source link

Perfomance: Removing age looping / order of stock dimensions #134

Open lentinj opened 6 months ago

lentinj commented 6 months ago

@bthe mentioned that a model without age optimises significantly faster. In general removing the age loops when not required is hard, but there's a bunch of housekeeping in predation that could do stock_ssinv(stock__predby_predstock, 'area') instead of stock_ss(stock__predby_predstock), and remove the need for looping over each age this way.

However, TMB say no:-

Error in convert_subset(tail(in_call, -2)) :
  Missing values must be at start of subset, can't restructure array: fish__predby_comm[, fish__area_idx, ]
Calls: g3_to_tmb ... cpp_code -> paste0 -> cpp_code -> paste0 -> convert_subset

Age being on the end means that bumping everything up one is a much easier operation, but maybe it's a poor choice in retrospect? There's always going to be more age dimensions than area.