trophia / sna1

A model of the SNA1 fishery
2 stars 2 forks source link

Thoughts on adding preference functions? #26

Open Craig44 opened 6 years ago

Craig44 commented 6 years ago

Hi all,

I am looking at adding preference movement into the IBM and thought I would open up a discussion with you all.

My initial thoughts

Then the movement process could be just drawing from that distribution and updating lat and long based on the new cell.

It would get complicated later on if you wanted to add some density dependence into the preference calculation because then that preference distribution would have to be calculated on the fly, but perhaps park that for now

nokome commented 6 years ago

Yes, yes, yes from me :) It's something that I was hoping would get added sometime.

Your initial thoughts match my initial thinking on this.

Add two new attributes to fish (Lat, Long)

Yep, two float attributes, or could consider using two short int to save memory.

add a new class/perhaps new source file that manages layers of environmental variables e.g. sst and npp etc

The class Environ was intended for exactly that :) I was thinking of having different environmental layers stored in there (structured for fast look up according to lat/lon) These layers might vary by period but should at least vary by season.

and generates an overall 'preference' layer

The actual generation of a preference should probably live in the Fish or Fishes class in a method that takes the Environ as an argument.

which would describe the probability to moving to a lat long bin. Thoughts on how you would draw from this distribution efficiently so that when you iterate over your population you have the spread expected with large numbers?

In a previous SNA 1 model we used an advection-diffusion approach based on a preference function. You just move the individual fish according to the advection-diffusion model, you don't have to draw from a spatial distribution, the spatial distribution emerges from the process.

Craig44 commented 6 years ago

@nokome do you happen to have code for moving a fish/particle along the habitat preference layer? I am looking at the diffusion-advection equation and am struggling a bit, I have found the following referencewhich uses biased random walk. Or is there an easier implementation, I have attached some R code that I am using to consider how to implement the movement of an individual through the advection-diffusion case.

Diffusion_model_rcode.txt

mckenziej commented 6 years ago

Hi Craig I have emailed you the following paper it might be useful.

"An individual-based model of skipjack tuna (Katsuwonus pelamis) movement in the tropical Pacific ocean"

Cheers

Jeremy

Jeremy.

Craig44 commented 6 years ago

Cool cheers for that, that is interesting and far more advanced that I am currently thinking. Tthe best paper that I have found for implementing these models is here if anyone is interested for future. I have simple bias random walk up and running in R so will start to transfer this stuff into the codebase. You can ignore my earlier comment, I have had a breakthrough today

Craig44 commented 6 years ago

I thought I would document the way I am currently thinking of implementing environmental preference movement.

These folders will contain a matrix of numbers for example for SST with 6 longitude bins and 3 latitude bins it would look like this. 22 22 22 21 20 21 21 22 21 20 19 21 18 19 17 19 16 18

Craig44 commented 6 years ago

So I have been playing around with this spec and have got to a point where it is starting to do what I think it should be doing. Along the way there are a few things that I have done that I should have asked before hand but let me know thoughts especially @nokome from a development perspective. To view the changes you can see my dev branch here. Let me know what you think about the points below.