/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000146.xml diagram  at 2008.03.20 15:09:27
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000146 extends JavaBaseModel
{

/*
 * Write rules to calculate equation parameters
 */
    private void __internalVarInitFunc_0(double time, double[] x)
    {
        RP_percent = (x[32] + x[18] + x[19] + x[20] + x[21] + x[22])*200/80;
        PI3Kstar_percent = x[12]*100/10;
        Rafstar_percent = x[24]*100/100;
        ERKPP_percent = x[6]*100/1000;
        AktPP_percent = x[3]*100/10;
        MEKPP_percent = x[10]*100/120;
        ShP_percent = x[28]*100/1000;
    }


/*
 * Write rules to calculate equation parameters excluding internal variables.
 */
    public void __internalRateVarInitFunc_0(double time, double[] x)
    {
        rate_reaction_0000001 = compartment_0000001*(k1*x[15]*x[7] - k_1*x[16]);
        rate_reaction_0000002 = compartment_0000001*(k2*Math.pow(x[16], 2) - k_2*x[17]);
        rate_reaction_0000003 = compartment_0000001*(k3*x[17] - k_3*x[32]);
        rate_reaction_0000004 = compartment_0000001*V4*x[32]/(K4 + x[32]);
        rate_reaction_0000005 = compartment_0000001*(k5*x[32]*x[29] - k_5*x[22]);
        rate_reaction_0000006 = compartment_0000001*(k6*x[22] - k_6*x[21]);
        rate_reaction_0000007 = compartment_0000001*(k7*x[21]*x[31] - k_7*x[20]);
        rate_reaction_0000008 = compartment_0000001*(k8*x[20] - k_8*x[27]*x[32]);
        rate_reaction_0000009 = compartment_0000001*(k9*x[27] - k_9*x[31]*x[28]);
        rate_reaction_0000010 = compartment_0000001*V10*x[28]/(K10 + x[28]);
        rate_reaction_0000011 = compartment_0000001*(k11*x[27]*x[25]/(K11 + x[25]));
        rate_reaction_0000012 = compartment_0000001*(V12*x[26]/(K12 + x[26]));
        rate_reaction_0000013 = compartment_0000001*(k13*x[26]*x[23]/(K13 + x[23]));
        rate_reaction_0000014 = compartment_0000001*k14*(x[3] + E)*x[24]/(K14 + x[24]);
        rate_reaction_0000015 = compartment_0000001*k15*x[24]*x[8]/(K15*(1 + x[9]/K17) + x[8]);
        rate_reaction_0000016 = compartment_0000001*k16*PP2A*x[9]/(K16*(1 + x[10]/K18 + x[1]/K31 + x[3]/K33) + x[9]);
        rate_reaction_0000017 = compartment_0000001*k17*x[24]*x[9]/(K17*(1 + x[8]/K15) + x[9]);
        rate_reaction_0000018 = compartment_0000001*k18*PP2A*x[10]/(K18*(1 + x[9]/K16 + x[3]/K31 + x[3]/K33) + x[10]);
        rate_reaction_0000019 = compartment_0000001*k19*x[10]*x[4]/(K19*(1 + x[5]/K21) + x[4]);
        rate_reaction_0000020 = compartment_0000001*k20*MKP3*x[5]/(K20*(1 + x[6]/K22) + x[5]);
        rate_reaction_0000021 = compartment_0000001*k21*x[10]*x[5]/(K21*(1 + x[4]/K19) + x[5]);
        rate_reaction_0000022 = compartment_0000001*k22*MKP3*x[6]/(K22*(1 + x[5]/K20) + x[6]);
        rate_reaction_0000023 = compartment_0000001*(k23*x[32]*x[11] - k_23*x[18]);
        rate_reaction_0000024 = compartment_0000001*(k24*x[18] - k_24*x[19]);
        rate_reaction_0000025 = compartment_0000001*(k25*x[19] - k_25*x[32]*x[12]);
        rate_reaction_0000026 = compartment_0000001*V26*x[12]/(K26 + x[12]);
        rate_reaction_0000027 = compartment_0000001*k27*x[12]*x[14]/(K27 + x[14]);
        rate_reaction_0000028 = compartment_0000001*(V28*x[13]/(K28 + x[13]));
        rate_reaction_0000029 = compartment_0000001*(k29*x[13]*x[0] - k_29*x[2]);
        rate_reaction_0000030 = compartment_0000001*V30*x[2]/(K30*(1 + x[1]/K32) + x[2]);
        rate_reaction_0000031 = compartment_0000001*k31*PP2A*x[1]/(K31*(1 + x[9]/K16 + x[10]/K18 + x[3]/K33) + x[1]);
        rate_reaction_0000032 = compartment_0000001*V32*x[1]/(K32*(1 + x[2]/K30) + x[1]);
        rate_reaction_0000033 = compartment_0000001*k33*PP2A*x[3]/(K33*(1 + x[9]/K16 + x[10]/K18 + x[1]/K31) + x[3]);
        rate_reaction_0000034 = compartment_0000001*(k34*x[32] - k_34*x[30]);
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        compartment_0000001 = 1.0; // initial value of $compartment_0000001
        E = 7.0; // initial value of E
        K10 = 340.0; // initial value of K10
        K11 = 0.181; // initial value of K11
        K12 = 0.0571; // initial value of K12
        K13 = 11.7; // initial value of K13
        K14 = 8.07; // initial value of K14
        K15 = 317.0; // initial value of K15
        K16 = 2200.0; // initial value of K16
        K17 = 317.0; // initial value of K17
        K18 = 60.0; // initial value of K18
        K19 = 146000.0; // initial value of K19
        K20 = 160.0; // initial value of K20
        K21 = 146000.0; // initial value of K21
        K22 = 60.0; // initial value of K22
        K26 = 3680.0; // initial value of K26
        K27 = 39.1; // initial value of K27
        K28 = 9.02; // initial value of K28
        K30 = 80000.0; // initial value of K30
        K31 = 4.35; // initial value of K31
        K32 = 80000.0; // initial value of K32
        K33 = 12.0; // initial value of K33
        K4 = 50.0; // initial value of K4
        MKP3 = 2.4; // initial value of MKP3
        PP2A = 11.4; // initial value of PP2A
        V10 = 0.0154; // initial value of V10
        V12 = 0.289; // initial value of V12
        V26 = 2620.0; // initial value of V26
        V28 = 17000.0; // initial value of V28
        V30 = 20000.0; // initial value of V30
        V32 = 20000.0; // initial value of V32
        V4 = 62.5; // initial value of V4
        k1 = 0.0012; // initial value of k1
        k11 = 0.222; // initial value of k11
        k13 = 1.53; // initial value of k13
        k14 = 0.00673; // initial value of k14
        k15 = 3.5; // initial value of k15
        k16 = 0.058; // initial value of k16
        k17 = 2.9; // initial value of k17
        k18 = 0.058; // initial value of k18
        k19 = 9.5; // initial value of k19
        k2 = 0.01; // initial value of k2
        k20 = 0.3; // initial value of k20
        k21 = 16.0; // initial value of k21
        k22 = 0.27; // initial value of k22
        k23 = 0.1; // initial value of k23
        k24 = 9.85; // initial value of k24
        k25 = 45.8; // initial value of k25
        k27 = 16.9; // initial value of k27
        k29 = 507.0; // initial value of k29
        k3 = 1.0; // initial value of k3
        k31 = 0.107; // initial value of k31
        k33 = 0.211; // initial value of k33
        k34 = 0.0010; // initial value of k34
        k5 = 0.1; // initial value of k5
        k6 = 20.0; // initial value of k6
        k7 = 60.0; // initial value of k7
        k8 = 2040.0; // initial value of k8
        k9 = 40.8; // initial value of k9
        k_1 = 7.6E-4; // initial value of k_1
        k_2 = 0.1; // initial value of k_2
        k_23 = 2.0; // initial value of k_23
        k_24 = 0.0985; // initial value of k_24
        k_25 = 0.047; // initial value of k_25
        k_29 = 234.0; // initial value of k_29
        k_3 = 0.01; // initial value of k_3
        k_5 = 1.0; // initial value of k_5
        k_6 = 5.0; // initial value of k_6
        k_7 = 546.0; // initial value of k_7
        k_8 = 15700.0; // initial value of k_8
    }

    /*
     * Model variables initial values
     */
    protected double rate_reaction_0000001;
    protected double rate_reaction_0000002;
    protected double rate_reaction_0000003;
    protected double rate_reaction_0000004;
    protected double rate_reaction_0000005;
    protected double rate_reaction_0000006;
    protected double rate_reaction_0000007;
    protected double rate_reaction_0000008;
    protected double rate_reaction_0000009;
    protected double rate_reaction_0000010;
    protected double rate_reaction_0000011;
    protected double rate_reaction_0000012;
    protected double rate_reaction_0000013;
    protected double rate_reaction_0000014;
    protected double rate_reaction_0000015;
    protected double rate_reaction_0000016;
    protected double rate_reaction_0000017;
    protected double rate_reaction_0000018;
    protected double rate_reaction_0000019;
    protected double rate_reaction_0000020;
    protected double rate_reaction_0000021;
    protected double rate_reaction_0000022;
    protected double rate_reaction_0000023;
    protected double rate_reaction_0000024;
    protected double rate_reaction_0000025;
    protected double rate_reaction_0000026;
    protected double rate_reaction_0000027;
    protected double rate_reaction_0000028;
    protected double rate_reaction_0000029;
    protected double rate_reaction_0000030;
    protected double rate_reaction_0000031;
    protected double rate_reaction_0000032;
    protected double rate_reaction_0000033;
    protected double rate_reaction_0000034;
    protected double compartment_0000001;
    protected double AktPP_percent;
    protected double E;
    protected double ERKPP_percent;
    protected double K10;
    protected double K11;
    protected double K12;
    protected double K13;
    protected double K14;
    protected double K15;
    protected double K16;
    protected double K17;
    protected double K18;
    protected double K19;
    protected double K20;
    protected double K21;
    protected double K22;
    protected double K26;
    protected double K27;
    protected double K28;
    protected double K30;
    protected double K31;
    protected double K32;
    protected double K33;
    protected double K4;
    protected double MEKPP_percent;
    protected double MKP3;
    protected double PI3Kstar_percent;
    protected double PP2A;
    protected double RP_percent;
    protected double Rafstar_percent;
    protected double ShP_percent;
    protected double V10;
    protected double V12;
    protected double V26;
    protected double V28;
    protected double V30;
    protected double V32;
    protected double V4;
    protected double k1;
    protected double k11;
    protected double k13;
    protected double k14;
    protected double k15;
    protected double k16;
    protected double k17;
    protected double k18;
    protected double k19;
    protected double k2;
    protected double k20;
    protected double k21;
    protected double k22;
    protected double k23;
    protected double k24;
    protected double k25;
    protected double k27;
    protected double k29;
    protected double k3;
    protected double k31;
    protected double k33;
    protected double k34;
    protected double k5;
    protected double k6;
    protected double k7;
    protected double k8;
    protected double k9;
    protected double k_1;
    protected double k_2;
    protected double k_23;
    protected double k_24;
    protected double k_25;
    protected double k_29;
    protected double k_3;
    protected double k_34;
    protected double k_5;
    protected double k_6;
    protected double k_7;
    protected double k_8;
    protected double k_9;

    public double[] extendResult(double time,double [] x)
    {
        this.time = time;

        __internalVarInitFunc_0(time, x);

        double[] y = new double[40];
        y[0] = x[0];
        y[1] = x[1];
        y[2] = x[2];
        y[3] = x[3];
        y[4] = x[4];
        y[5] = x[5];
        y[6] = x[6];
        y[7] = x[7];
        y[8] = x[8];
        y[9] = x[9];
        y[10] = x[10];
        y[11] = x[11];
        y[12] = x[12];
        y[13] = x[13];
        y[14] = x[14];
        y[15] = x[15];
        y[16] = x[16];
        y[17] = x[17];
        y[18] = x[18];
        y[19] = x[19];
        y[20] = x[20];
        y[21] = x[21];
        y[22] = x[22];
        y[23] = x[23];
        y[24] = x[24];
        y[25] = x[25];
        y[26] = x[26];
        y[27] = x[27];
        y[28] = x[28];
        y[29] = x[29];
        y[30] = x[30];
        y[31] = x[31];
        y[32] = x[32];
        y[33] = AktPP_percent;
        y[34] = ERKPP_percent;
        y[35] = MEKPP_percent;
        y[36] = PI3Kstar_percent;
        y[37] = RP_percent;
        y[38] = Rafstar_percent;
        y[39] = ShP_percent;
        return y;
    }
    public double[] getInitialValues()
    {
        double [] x = new double[33];
        this.time = 0.0;
        x[0] = 10.0; // - $"compartment_0000001.Akt"
        x[1] = 0.0; // - $"compartment_0000001.AktPIP"
        x[2] = 0.0; // - $"compartment_0000001.AktPIP3"
        x[3] = 0.0; // - $"compartment_0000001.AktPIPP"
        x[4] = 1000.0; // - $"compartment_0000001.ERK"
        x[5] = 0.0; // - $"compartment_0000001.ERKP"
        x[6] = 0.0; // - $"compartment_0000001.ERKPP"
        x[7] = 330.0; // - $"compartment_0000001.HRG"
        x[8] = 120.0; // - $"compartment_0000001.MEK"
        x[9] = 0.0; // - $"compartment_0000001.MEKP"
        x[10] = 0.0; // - $"compartment_0000001.MEKPP"
        x[11] = 10.0; // - $"compartment_0000001.PI3K"
        x[12] = 0.0; // - $"compartment_0000001.PI3Kstar"
        x[13] = 0.0; // - $"compartment_0000001.PIP3"
        x[14] = 800.0; // - $"compartment_0000001.P_I"
        x[15] = 80.0; // - $"compartment_0000001.R"
        x[16] = 0.0; // - $"compartment_0000001.RHRG"
        x[17] = 0.0; // - $"compartment_0000001.RHRG2"
        x[18] = 0.0; // - $"compartment_0000001.RPI3K"
        x[19] = 0.0; // - $"compartment_0000001.RPI3Kstar"
        x[20] = 0.0; // - $"compartment_0000001.RShGS"
        x[21] = 0.0; // - $"compartment_0000001.RShP"
        x[22] = 0.0; // - $"compartment_0000001.RShc"
        x[23] = 100.0; // - $"compartment_0000001.Raf"
        x[24] = 0.0; // - $"compartment_0000001.Rafstar"
        x[25] = 120.0; // - $"compartment_0000001.RasGDP"
        x[26] = 0.0; // - $"compartment_0000001.RasGTP"
        x[27] = 0.0; // - $"compartment_0000001.ShGS"
        x[28] = 0.0; // - $"compartment_0000001.ShP"
        x[29] = 1000.0; // - $"compartment_0000001.Shc"
        x[30] = 0.0; // - $"compartment_0000001.internalization"
        x[31] = 10.0; // - $compartment_0000001.GS
        x[32] = 0.0; // - $compartment_0000001.RP

        __internalVarInitFunc_0(time, x);
        __internalRateVarInitFunc_0(time, x);

        return x;
    }

/*
 * code for algebraic rules calculations
 */

/*
 * end of code for algebraic rules calculations
 */

    protected void calculateRates(double time, double[] x)
    {

        __internalVarInitFunc_0(time, x);
        __internalRateVarInitFunc_0(time, x);

    }

        /*
         * calculate dy/dt for 'BIOMD0000000146.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = -rate_reaction_0000029;
        result[1] = +rate_reaction_0000030-rate_reaction_0000031-rate_reaction_0000032+rate_reaction_0000033;
        result[2] = +rate_reaction_0000029-rate_reaction_0000030+rate_reaction_0000031;
        result[3] = +rate_reaction_0000032-rate_reaction_0000033;
        result[4] = -rate_reaction_0000019+rate_reaction_0000020;
        result[5] = +rate_reaction_0000019-rate_reaction_0000020-rate_reaction_0000021+rate_reaction_0000022;
        result[6] = +rate_reaction_0000021-rate_reaction_0000022;
        result[7] = -rate_reaction_0000001;
        result[8] = -rate_reaction_0000015+rate_reaction_0000016;
        result[9] = +rate_reaction_0000015-rate_reaction_0000016-rate_reaction_0000017+rate_reaction_0000018;
        result[10] = +rate_reaction_0000017-rate_reaction_0000018;
        result[11] = -rate_reaction_0000023+rate_reaction_0000026;
        result[12] = +rate_reaction_0000025-rate_reaction_0000026;
        result[13] = +rate_reaction_0000027-rate_reaction_0000028-rate_reaction_0000029;
        result[14] = -rate_reaction_0000027+rate_reaction_0000028;
        result[15] = -rate_reaction_0000001;
        result[16] = +rate_reaction_0000001-rate_reaction_0000002*2;
        result[17] = +rate_reaction_0000002-rate_reaction_0000003+rate_reaction_0000004;
        result[18] = +rate_reaction_0000023-rate_reaction_0000024;
        result[19] = +rate_reaction_0000024-rate_reaction_0000025;
        result[20] = +rate_reaction_0000007-rate_reaction_0000008;
        result[21] = +rate_reaction_0000006-rate_reaction_0000007;
        result[22] = +rate_reaction_0000005-rate_reaction_0000006;
        result[23] = -rate_reaction_0000013+rate_reaction_0000014;
        result[24] = +rate_reaction_0000013-rate_reaction_0000014;
        result[25] = -rate_reaction_0000011+rate_reaction_0000012;
        result[26] = +rate_reaction_0000011-rate_reaction_0000012;
        result[27] = +rate_reaction_0000008-rate_reaction_0000009;
        result[28] = +rate_reaction_0000009-rate_reaction_0000010;
        result[29] = -rate_reaction_0000005+rate_reaction_0000010;
        result[30] = +rate_reaction_0000034;
        result[31] = -rate_reaction_0000007+rate_reaction_0000009;
        result[32] = +rate_reaction_0000003-rate_reaction_0000004-rate_reaction_0000005+rate_reaction_0000008-rate_reaction_0000023+rate_reaction_0000025-rate_reaction_0000034;
    }
    protected double [] calculateResult(double time, double[] x)
    {
        double[] result = new double[33];
        __internalDyDt_0(time, x, result);
        return result;
    }
    public double[] dy_dt(double time, double[] x)
    {
        this.time = time;
        calculateRates( time,x );

        return calculateResult( time,x );
    }

} // class ...