コード例 #1
0
def simulate_stoch(base,
                   vol,
                   t=None,
                   ntraj=1,
                   increment=0.01,
                   job_id='',
                   y0_pop=None,
                   nrep=1):

    stoch_fn = SSAModel(base, vol, nrep=nrep, y0_pop=y0_pop)
    trajectories = stk.stochkit(stoch_fn,
                                job_id='Oregonator' + str(job_id),
                                t=t,
                                number_of_trajectories=ntraj,
                                increment=increment)

    ts = trajectories[0][:, 0]
    traj = np.array(trajectories)[:, :, 1:]

    # Restructure trajectory array to recreate (replicate, time, state)
    # indexing scheme
    traj = traj.reshape((ntraj, len(ts), nrep, base.NEQ))  # Expand
    traj = traj.swapaxes(2, 1)  # Bring reps and traj to front
    traj = traj.reshape(
        (nrep * ntraj, len(ts), base.NEQ))  # Collapse to single axis
    traj = traj / vol  # return concentrations

    return ts, traj
コード例 #2
0
def simulate_stoch(base, vol, t=None, traj=100, increment=0.01, job_id=''):

    stoch_fn = SSAModel(base, vol)
    trajectories = stk.stochkit(stoch_fn,
                                job_id='brusselator' + str(job_id),
                                t=t,
                                number_of_trajectories=traj,
                                increment=increment)

    ts = trajectories[0][:, 0]
    traj = np.array(trajectories)[:, :, 1:] / vol
    return ts, traj