seacode / gmacs

A generic size-structured stock assessment model
https://seacode.github.io/gmacs
19 stars 14 forks source link

Generalise F penalty #165

Open quantifish opened 8 years ago

quantifish commented 8 years ago

This is what we want for SMBKC but I don't reckon it can stay this way! I'll fix it up at some point.

// 2) Penalty on mean F to regularize the solution.
int irow = 1;
if ( last_phase() ) irow = 2;
dvariable fbar;
dvariable ln_fbar;
for ( int k = 1; k <= nfleet; k++ )
{
    // Jim made penalty apply only to season 2 for Fbar ft(1,nfleet,1,nsex,syr,nyr,1,nseason);            ///> Fishing mortality by gear
    fbar = mean( trans(ft(k,1))(2) );
    // fbar = mean(ft(k,1) );
    if ( pen_fbar(k) > 0  && fbar != 0 )
    {
        ln_fbar = log(fbar);
        nlogPenalty(2) += dnorm(ln_fbar, log(pen_fbar(k)), pen_fstd(irow,k));
    }
}