library(magrittr)
areas <- list(a=1, b=2, c=3, d=4)
# NB: stock doesn't live in b, so won't figure in stock_acd__migratematrix
stock_acd <- (g3_stock('stock_acd', seq(10, 40, 10))
%>% g3s_livesonareas(areas[c('a', 'c', 'd')]))
movement_action <- list(
g3a_migrate(
stock_acd,
# In spring, individuals in area 'a' will migrate to 'd'.
~if (area == area_a && dest_area == area_d) 0.8 else 0,
run_f = ~cur_step == 2),
g3a_migrate(
stock_acd,
# In autumn, individuals in all areas will migrate to 'a'
~if (dest_area == area_a) 0.8 else 0,
run_f = ~cur_step == 4),
list())
Run the code above in your browser using DataLab