Ejemplo n.º 1
0
def simulate_default():

    # initial conditions
    x0 = np.array([-8.0, 7.0, 27])
    
    # time domain and step size
    t0, T, h = 0, 25, 0.01
    
    time_points, data = train_lmmNet.create_training_data(t0, T, h, f_lorenz, x0)
    
    return time_points, data
Ejemplo n.º 2
0
def simulate_default():
    """
    Simulate the default 2-D damped harmonic oscillator cubic dynamics
    """

    # time domain
    t0, T, h = 0, 25, 0.01

    x0 = np.array([2, 0])  # initial conditions -- default cubic problem

    time_points, cubic_data = train_lmmNet.create_training_data(
        t0, T, h, f_cubic, x0)

    return time_points, cubic_data
Ejemplo n.º 3
0
def simulate_custom(tstart=0, tend=25, step=.01, xinit=2, yinit=0):
    """
    Simulate the default 2-D damped harmonic oscillator cubic dynamics
    """

    # time domain
    t0, T, h = tstart, tend, step

    x0 = np.array([xinit,
                   yinit])  # initial conditions -- default cubic problem

    time_points, cubic_data = train_lmmNet.create_training_data(
        t0, T, h, f_cubic, x0)

    return time_points, cubic_data
Ejemplo n.º 4
0
def report_linear_sindy():
    
    error_list = []
    
    for _ in range(10):
    
        error_dict = {}
        xi = np.random.uniform(-4, 4, 1)[0]
        yi = np.random.uniform(-4, 4, 1)[0]
        zi = np.random.uniform(0, 2, 1)[0]
        time_points, test_data = linear.simulate_custom(xinit=xi, yinit=yi, zinit=zi)

        t0, T, h = 0, 50, .01
        _, pred = train_lmmNet.create_training_data(t0, T, h, sindy_linear, test_data[0,0,:])
        predictions = pred[0]
        e1 = wasserstein_distance(predictions[:,0], test_data[0,:,0])
        e2 = wasserstein_distance(predictions[:,1], test_data[0,:,1])
        e3 = wasserstein_distance(predictions[:,2], test_data[0,:,2])
        error_dict['wasserstein'] = (e1, e2, e3)

        e1, _ = fastdtw(predictions[:,0], test_data[0,:,0], dist=euclidean)
        e2, _ = fastdtw(predictions[:,1], test_data[0,:,1], dist=euclidean)
        e3, _ = fastdtw(predictions[:,2], test_data[0,:,2], dist=euclidean)
        e1 /= np.linalg.norm(test_data[0,:,0], 2)**2
        e2 /= np.linalg.norm(test_data[0,:,1], 2)**2
        e3 /= np.linalg.norm(test_data[0,:,2], 2)**2

        error_dict['dtw'] = (e1, e2, e3)

        e1 = predict_lmmNet.compute_MSE(predictions, test_data[0], 0)
        e2 = predict_lmmNet.compute_MSE(predictions, test_data[0], 1)
        e3 = predict_lmmNet.compute_MSE(predictions, test_data[0], 2)
        error_dict['mse'] = (e1, e2, e3)

        # plot
        plt.plot(time_points, test_data[0,:,0], 'r.', label='x_1')
        plt.plot(time_points, test_data[0,:,1], 'y.', label='x_2')
        plt.plot(time_points, test_data[0,:,2], 'g.', label='x_3')
        plt.plot(time_points, predictions[:,0], 'b--', label='predicted x_1')
        plt.plot(time_points, predictions[:,1], 'b--')
        plt.plot(time_points, predictions[:,2], 'b--')
        plt.legend()
        plt.show()

        error_list.append(error_dict)
        
    return error_list
Ejemplo n.º 5
0
def simulate_custom(tfirst=0, tlast=300, step_size=0.2, cyclin=0, MPF=0,
                   wee1_total=1, cdc25_total=5, APC_total=1, IE_total=1,
                   k1=1, v2_1 = .005, v2_2 = .25, noise=0.):
    """
    Simulate the Novak Tyson Cell Cycle Model with custom parameters.
    
    Arguments:
    - cdc25_total = Total cdc25 (needed to maintain cyclin and MPF oscillations)
    - k1 = synthesis of cyclin
    - v2_1 = degradation of cyclin by APC off
    - v2_2 = degradation of cyclin by APC on
    - noise = strength of Gaussian noise to be added to the integrated dynamics
    
    Returns:
    - time points
    - virtual time-series measurements for each biochemical species
    """
    
    globals()['wee1_total'] = wee1_total
    globals()['cdc25_total'] = cdc25_total
    globals()['APC_total'] = APC_total
    globals()['IE_total'] = IE_total
    globals()['k1'] = k1
    globals()['v2_1'] = v2_1
    globals()['v2_2'] = v2_2
    
    # define initial conditions
    preMPF = 0
    cdc25P = 0
    wee1P = 0
    IEP = 1
    APC = 1
    x0 = np.array([cyclin,MPF,preMPF,cdc25P,wee1P,IEP,APC])
    
    # define default parameters
    default = {'k3':0.005, 'ka':.02,'Ka':.1,'kb':.1,'Kb':1, 'kc':.13, 'Kc':.01, 'kd':.13, 'Kd':1,
               'vwee_1':.01, 'vwee_2':1, 'v25_1':0.5*.017, 'v25_2':0.5*.17,
             'ke':.02, 'Ke':1, 'kf':.1, 'Kf':1, 'kg':.02, 'Kg':.01, 'kh':.15, 'Kh':.01, 'PPase':1, 'CDK_total':100, 'IE_total':1, 'APC_total':1}
    
    for key,val in default.items():
        globals()[key]=val
    
    time_points, novak_data = create_training_data(tfirst, tlast, step_size, f_NovakTyson, x0, noise_strength=noise)
    
    return time_points, novak_data
Ejemplo n.º 6
0
def simulate_default(debug=False):
    """
    Simulate the Novak Tyson Cell Cycle Model with default parameters.
    The parameters can be categorized into a few classes:
    * The lowercase k's are maximal rates (usually kcat)
    * The uppercasse K's are Michaelis constants
    * Total protein concentrations
    * The v's are weighting parameters for computing intermediate constants
    
    Returns:
    - time points
    - virtual time-series measurements for each biochemical species
    """
    
    # define the simulation time
    tfirst, tlast = 0, 1500
    step_size = 0.2

    # define initial conditions
    cyclin = 0
    MPF = 0
    preMPF = 0
    cdc25P = 0
    wee1P = 0
    IEP = 1
    APC = 1
    x0 = np.array([cyclin,MPF,preMPF,cdc25P,wee1P,IEP,APC])
    
    # define default parameters
    default = {'k1':1, 'k3':0.005,
              'ka':.02,'Ka':.1,'kb':.1,'Kb':1, 'kc':.13, 'Kc':.01, 'kd':.13, 'Kd':1,
             'v2_1':.005, 'v2_2':.25, 'vwee_1':.01, 'vwee_2':1, 'v25_1':0.5*.017, 'v25_2':0.5*.17,
             'ke':.02, 'Ke':1, 'kf':.1, 'Kf':1, 'kg':.02, 'Kg':.01, 'kh':.15, 'Kh':.01,
             'wee1_total':1, 'PPase':1, 'CDK_total':100, 'cdc25_total':5,'IE_total':1, 'APC_total':1}
    for key,val in default.items():
        globals()[key]=val
        
    if debug:
        return f_NovakTyson(x0, 0)
    
    time_points, novak_data = create_training_data(tfirst, tlast, step_size, f_NovakTyson, x0)
    
    return time_points, novak_data