action_migrate.Rd
Add migration to a g3 model
g3a_migrate_normalize(row_total = 1)
g3a_migrate(stock, migrate_f, normalize_f = g3a_migrate_normalize(),
run_f = TRUE,
run_at = g3_action_order$migrate)
When calculating the proportion of individuals that will stay in place, use this total for what rows are expected to sum to.
The g3_stock
that will migrate in this action.
A formula describing the migration in terms of (source) area
and dest_area
.
Function to normalize a vector of possible destinations, to make sure fish aren't added or destroyed.
formula specifying a condition for running this action, default always runs.
Integer order that spawning actions will be run within model, see g3_action_order
.
To restrict movement to a particular step in a year, or a particular area, use run_f. For example:
cur_step == 1
Migration will happen on first step of every year
cur_step == 1 && cur_year >= 1990
Migration will happen on first step of every year after 1990
cur_step == 2 && area = 1
Migration will happen on second step of every year, in the first area
Multiple migration actions can be added, for a separate spring and autumn migration, for instance.
The action will define the following stock instance variables for each given stock:
\(a \times a\) array, containing proportion of (stock) moved from one area to another. If NaN, no movement has occurred
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())