Commit 1fc44397 by Victor

### updated docs

parent ca630363
Pipeline #75220 passed with stage
in 28 minutes and 12 seconds
 ... ... @@ -101,7 +101,7 @@ Plots.plot(get_tspan(sim),wsize, !!! notes "Callbacks" Note that one could also use a callback function to obtain time series of size of the world computed at simulation time. See [Simulation page](../manual/simulation.md). Note that one could also use a callback function to obtain time series of size of the world computed at simulation time. See [Callbacks page](../manual/callbacks.md). ### Position through time ... ...
 ... ... @@ -40,7 +40,7 @@ General workflow to launch any simulation is the following - Define mutation function - [Define initial population state and time](manual/world) - [Run the simulation according to some updating algorithm](manual/run_world.md) - [Obtain a summary of the population state](manual/simulation.md) - [Obtain a summary of the population state](manual/callbacks.md) ### Available algorithms As of now, three types of simulation algorithm can be used: ... ...
 # Callbacks Callbacks can be used to extract properties of the world at each dt_saving time steps of your simulation. ## Constructing the callbacks A callback has to be of the form julia cb = (names = String[], agg = Function[])  It is a tuple, with first value corresponding to the names of the aggregate properties of the world. The second correspond to the aggregation functions. We provide here an example on how to extract the \gamma diversity of a simulation biological population. \gamma diversity can be calculated as the variance of the trait distribution of the population. Here is how we write the function julia cb = (names = ["gamma_div"], agg = Function[w -> var((get_x(w,1)))])  Here is how we use it julia myspace = (RealSpace{1,Float64}(),) sigma_K = .9; sigma_a = .7; K0 = 1000; b(X) = gaussian(X[1],0.,sigma_K) d(X,Y) = gaussian(X[1],Y[1],sigma_a)/K0 D = (1e-2,) mu = [.1] NMax = 10000 tend = 1.5 p = Dict{String,Any}();@pack! p = d,b,D,mu,NMax myagents = [Agent(myspace,(0,),ancestors=true,rates=true) for i in 1:K0] w0 = World(myagents,myspace,p,0.) w1 = copy(w0) @time sim = run!(w1,Gillepsie(),tend,cb=cb,dt_saving = .1)  ## Accessing the callbacks You can easily access the properties, using sim as you would for a usual Dictionary. julia using Plots plot(get_tspan(sim),sim["gamma_div"]) 
 ... ... @@ -6,8 +6,8 @@ Returns a Simulation type. - worldall stores the world every p["dt_saving"] time steps. If dt_saving not specified, sim contains an array of two elements, first corresponding to initial conditions and last corresponding to world in the last time step. - cb correspond to callbacks function. Look at the documentation for more information - the run stops if the number of agents reachesp["NMax"]. >:warning: if you choose nagents = 1 then nothing is saved until the end of the simulation. """ function run!(w::World{A,S,T},alg::L,tend::Number; dt_saving=nothing, ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!