pdolder / MixFishSim

Code for mixed fishery multi-stock simulation model
GNU General Public License v3.0
3 stars 3 forks source link

Recruitment and spawning clarification #7

Open Blevy2 opened 2 years ago

Blevy2 commented 2 years ago

Hi @pdolder ,

I wanted to start a dialogue about the timing and function of recruitment and spawning in the model. I have done a number of tests related to these functions in the model and notice that when the spawning weeks and recruitment weeks do not overlap, the population dies out.

I believe what is happening is as follows...

In lines 137-140 of run_sim, Recruit is determined TRUE/FALSE based on the spawning weeks.

As a result, the Recruitment matrix is only created in lines 188-211, during spawning weeks. As a side note, my understanding is that these lines paired with the function Recr_mat produce recruitment on the entire domain rather than only in the spawning grounds as suggested in lines 175-181.

Later on in the Population Dynamics section lines 336-380, a1 and a1m1 are only nonzero during recruitment weeks.

All together this means that when recruitment is added into the population in delay_diff, the product a1R and a1m1R have a nonzero value only during weeks in which recruitment and spawning overlap.

I think this means that if a species has 4 weeks of recruitment but only 1 of those weeks overlaps with spawning, then 1/4 of the yearly recruitment will take place on the entire domain in just 1 week (rather than 4).

I have done some tests to try to understand this, but it is certainly possible I am mistaken. Let me know if you would like to discuss this in more detail.

best,

Ben Levy

pdolder commented 2 years ago

Hi Ben,

From memory the intended behaviour was that there is a period of spawning migration where fish concentrate/aggregate in certain areas for spawning, but due to the need to have some movement towards these areas over time (advective movement) reflecting pop movement rates spawning does not take place during this entire period but at the end only.

So it was intentional that they need to overlap for recruitment to occur. By extension it's logical that no recruitment takes place when they don't overlap (though not explicitly something I'd considered). There might be a more elegant way to do this, but I'd need to think on that some more. It may be also that terminology is not clear, and could be improved.

Happy to chat about this but am travelling at the moment for the holidays (actually, just down the road from you in Chelmsford, MA)..and will pick this up at weekend or early next week when I'm back.

All the best, Paul

On Wed, 5 Jan 2022, 10:39 Blevy2, @.***> wrote:

Hi @pdolder https://github.com/pdolder ,

I wanted to start a dialogue about the timing and function of recruitment and spawning in the model. I have done a number of tests related to these functions in the model and notice that when the spawning weeks and recruitment weeks do not overlap, the population dies out.

I believe what is happening is as follows...

In lines 137-140 of run_sim https://github.com/pdolder/MixFishSim/blob/f4be072ef8328845a635e68d69a290be4b944fa5/R/run_sim.R#L137-L140, Recruit is determined TRUE/FALSE based on the spawning weeks.

As a result, the Recruitment matrix is only created in lines 188-211 https://github.com/pdolder/MixFishSim/blob/f4be072ef8328845a635e68d69a290be4b944fa5/R/run_sim.R#L188-L211, during spawning weeks. As a side note, my understanding is that these lines paired with the function Recr_mat produce recruitment on the entire domain rather than only in the spawning grounds as suggested in lines 175-181 https://github.com/pdolder/MixFishSim/blob/f4be072ef8328845a635e68d69a290be4b944fa5/R/run_sim.R#L175-L181 .

Later on in the Population Dynamics section lines 336-380 https://github.com/pdolder/MixFishSim/blob/f4be072ef8328845a635e68d69a290be4b944fa5/R/run_sim.R#L175-L181, a1 and a1m1 are only nonzero during recruitment weeks.

All together this means that when recruitment is added into the population in delay_diff https://github.com/pdolder/MixFishSim/blob/f4be072ef8328845a635e68d69a290be4b944fa5/R/delay_difference.R#L34-L41, the product a1R and a1m1R have a nonzero value only during weeks in which recruitment and spawning overlap.

I think this means that if a species has 4 weeks of recruitment but only 1 of those weeks overlaps with spawning, then 1/4 of the yearly recruitment will take place on the entire domain in just 1 week (rather than 4).

I have done some tests to try to understand this, but it is certainly possible I am mistaken. Let me know if you would like to discuss this in more detail.

best,

Ben Levy

— Reply to this email directly, view it on GitHub https://github.com/pdolder/MixFishSim/issues/7, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4F4SOCTJCY73YDELFZCCLUURQ2LANCNFSM5LKGPSMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

Blevy2 commented 2 years ago

Hi Paul,

Thanks for the response. Very funny to hear you are so close by in Chelmsford.

Fish ecology is new to me so I appreciate your guidance. Maybe we could have a quick chat about the timing of the two events so I can fully understand the intention of the setup and timing.

My main concern is that in the population dynamics equation (1) in the publication, the middle term never comes into play (since R is zero during times when alpha_(d-1) is nonzero) and the third recruitment term is only nonzero during one week (the overlapping week) and thus only brings over a fraction of the intended yearly recruitment.

Sorry if I am not being clear. I think a quick meeting would help me illustrate what I am saying if you are up for it.

Enjoy the rest of your trip,

Ben

pdolder commented 2 years ago

Hi Ben,

Sure, a chat would be great. Say middle next week? That will give me chance to t review the equations and code when I get back so I can be better informed.

Best, Paul

On Wed, 5 Jan 2022, 12:45 Blevy2, @.***> wrote:

Hi Paul,

Thanks for the response. Very funny to hear you are so close by in Chelmsford.

Fish ecology is new to me so I appreciate your guidance. Maybe we could have a quick chat about the timing of the two events so I can fully understand the intention of the setup and timing.

My main concern is that in the population dynamics equation (1) in the publication, the middle term never comes into play (since R is zero during times when alpha_(d-1) is nonzero) and the third recruitment term is only nonzero during one week (the overlapping week) and thus only brings over a fraction of the intended yearly recruitment.

Sorry if I am not being clear. I think a quick meeting would help me illustrate what I am saying if you are up for it.

Enjoy the rest of your trip,

Ben

— Reply to this email directly, view it on GitHub https://github.com/pdolder/MixFishSim/issues/7#issuecomment-1005939589, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4F4SOAZH2ZJG7H6NP6TCTUUR7TLANCNFSM5LKGPSMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

Blevy2 commented 2 years ago

The middle of next week works for me. Let me know when you have had a chance to look at the code.

Thanks for being willing to talk to me.

Ben

Blevy2 commented 2 years ago

Hi Paul,

Great speaking with you today. Thank you for taking the time. Per our conversation, I think one way to get alpha and alpha_(t-1) on the same scale as the population dynamics would be to change these lines in run_sim from

1/length(pop_init[["dem_params"]][[x]][["rec_wk"]])

to

1/(length(pop_init[["dem_params"]][[x]][["rec_wk"]]) * sim[["idx"]][["ndf"]] )

I doing this the alphas will account for the number of days being fished in a week ( sim[["idx"]][["ndf"]] ) and the recruitment will be spread across the correct number of days.

I will let you know if/when I have ideas for the other things we discussed.

best,

Ben

Note: I edited the denominator to sim[["idx"]][["ndf"]], which I think will be the number of days per week in the model because the index for the model is fishing days.

pdolder commented 2 years ago

Hi Ben,

An update for you:

I have made changes as we discussed, and from testing it appears to be working correctly (i.e. spawning occurring at the required times and scale). Briefly, the changes:

The net result should be something more predictable and even within a year. I've tested a bit, but if you have code and plots as you showed me it might be worth running before I submit the changes?

It's in a branch of the repo, can be installed devtools::install_github('pdolder/MixFishSim@fix_rec').

I haven't yet cleared up the terminology (spawning v recruitment) but wanted to get the mechanisms updated first.

For clarity, recruitment still occurs across the domain but should be more concentrated on spawning grounds.

Thanks for the helpful discussions about all this!

Paul

Blevy2 commented 2 years ago

Hi Paul,

I looked through the code just now and can see how recruitment is fixed once and how al and alm1 have been corrected so that the values are distributed across the correct number of days. I also see how you based recruitment in the first year on the starting values, which is a great idea.

I cannot tell how the recruitment might be more concentrated in the spawning grounds. Since spawning takes place during or after recruitment, the movement that ultimately would concentrate the recruitment the spawning grounds does not take place early enough for this to happen.

My solution for this is to base recruitment on the population value at the end of spawning in the previous year. That way when recruitment is applied to the domain the population will be concentrated in the spawning grounds and thus recruitment will be concentrated there as well. In the first year I am just blasting out the recruitment in the final week of spawning to get things started.

Ill take a more careful look at your update and plot a few things when I can. I will report back after I do.

best,

Ben

pdolder commented 2 years ago

Hi Ben,

I should have clarified, I have not changed anything on the timing of movements towards spawning grounds and recruitment and their interactions, yet.

My suggestion is to change the conditional here to rec_wk: https://github.com/pdolder/MixFishSim/blob/7be85d645b16c5213c38bbd4c19efd8278c1c219/R/run_sim.R#L513 https://github.com/pdolder/MixFishSim/blob/7be85d645b16c5213c38bbd4c19efd8278c1c219/R/run_sim.R#L517

The a1 and a1m1 inputs to the delay_diff function would then also change to spwn_wk here: https://github.com/pdolder/MixFishSim/blob/7be85d645b16c5213c38bbd4c19efd8278c1c219/R/run_sim.R#L381 https://github.com/pdolder/MixFishSim/blob/7be85d645b16c5213c38bbd4c19efd8278c1c219/R/run_sim.R#L383

That way the user specifies the recruitment week ahead of the spawning and that's the time movement occurs. And all recruitment functions operate on spwn_wk, so that should be properly specified.

However, it then remains confusing in terms of parameter names. So ultimately it would need revising the terminology so that:

spwn_wk --> rec_wk rec_wk --> mig_wk (or something to specify migration week).

And the helpfiles updated.

Does that sound sufficient to you?

Thanks, Paul

Blevy2 commented 2 years ago

Hi Paul,

Sorry, I didn't realize you had asked a question here. I think what you are proposing sounds appropriate and I agree that the change in terminology would be helpful as well.

best,

Ben