bfm_sim_cost_function.R

Home   »   bfm_sim_cost_function.R

# function to increment node resources by probabilistic cost & growth (mathematical) function
graph_sim_increment <- function(graf){

  graf <- graf %>% activate(nodes) %>% 
    # cost / growth function = current resources * average of random normal variable 
    # plus previous stochastic growth probability, minus .5
    mutate(resources = resources * (1 + ( ((rnorm(150,.5,.07) + growth) / 2) - .5)),
           endangered = resources < 15)   
  return(graf)  
}

Leave a Reply

Your email address will not be published. Required fields are marked *