Closed skycolt closed 5 years ago
Not without modifying the Network
; e.g. model <= Species("X", 5)
will override the previous value.
There's not interface for handling uneven sampling times, but this is addressed in a future update.
Providing an easy-to-use simulate
is nice, but for my own work I'm finding I need to record quantities in the middle of a simulation. The goal is to have something like this working:
for (x, step) in enumerate(simulator)
# calculate some quantities
functionof(x)
# custom logging
push!(data, x)
# break early
if x[3] == 0; break end
end
where simulator
is an object that overloads Base.iterate
.
Thanks for the answer! record in the middle of the simulation is nice. I think it will also be useful to have data for each Gillespie step instead for specific time point. Is there a way to do it?
I looked through the manual again and I guess I should use the SamplePath method for output if I want to have each point of Gillespie simulation?
Yes, that's correct. It will save each step.
I tried to used the option Val(:full) but the program only returns two time points. The code I use is result1 = simulate(model1, Direct(), time = 10000.0, output_type = Val(:full), trials = 4) I also tried your example of "enzyme kinetics", with command result = simulate(model, Direct(), time = 50.0, trials = 1000, output_type = Val(:full)) It also only returns two time points, the result looks like
julia> result.simulation_data[1] BioSimulator.RegularPath{Float64,Int64}([0.0, 50.0], [301 5; 100 78; 0 22; 0 274])
Am I doing something wrong? Please let me know.
Thanks
Nothing wrong on your end. For some reason build_output
returns a RegularEnsemble
(hence RegularPath
in your example) instead of an Ensemble
.
EDIT: I'm mistaken; output_type
is a positional argument. You should run this as
result = simulate(model, Direct(), Val(:full), time = 50.0, trials = 1000)
This needs to be reworked and clarified in the manual.
Thank you! I didn't notice that to be a positional argument.
Is there an easy way to restart the simulation from the previous run? or can I set uneven sampling time like [0, 100, 200, 201, 202, 203, ... , 210] ?
Thanks