当前位置: 首页>>代码示例>>Python>>正文


Python ScipyOdeSimulator.run方法代码示例

本文整理汇总了Python中pysb.simulator.ScipyOdeSimulator.run方法的典型用法代码示例。如果您正苦于以下问题:Python ScipyOdeSimulator.run方法的具体用法?Python ScipyOdeSimulator.run怎么用?Python ScipyOdeSimulator.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysb.simulator.ScipyOdeSimulator的用法示例。


在下文中一共展示了ScipyOdeSimulator.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parameter_sweep

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def parameter_sweep(model, sigma, ns):
    generate_equations(model)
    logp = [numpy.log10(p.value) for p in model.parameters]
    ts = numpy.linspace(0, 20*3600, 20*60)
    solver = Solver(model, ts)
    pf.set_fig_params()
    plt.figure(figsize=(1.8, 1), dpi=300)
    for i in range(ns):
        psample = sample_params(logp, 0.05)
        res = solver.run(param_values=psample)
        signal = res.observables['p53_active']
        plt.plot(signal, color=(0.7, 0.7, 0.7), alpha=0.3)
    # Highlighted
    colors = ['g', 'y', 'c']
    for c in colors:
        psample = sample_params(logp, 0.05)
        res = solver.run(param_values=psample)
        signal = res.observables['p53_active']
        plt.plot(signal, c)

    # Nominal
    solver = Solver(model, ts)
    res = solver.run()
    signal = res.observables['p53_active']
    plt.plot(signal, 'r')

    plt.xticks([])
    plt.xlabel('Time (a.u.)', fontsize=7)
    plt.ylabel('Active p53', fontsize=7)
    plt.yticks([])
    plt.ylim(ymin=0)
    pf.format_axis(plt.gca())
    plt.savefig(model.name + '_sample.pdf')
开发者ID:johnbachman,项目名称:indra,代码行数:35,代码来源:param_analysis.py

示例2: test_simres_dataframe

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def test_simres_dataframe():
    """ Test SimulationResult.dataframe() """

    tspan1 = np.linspace(0, 100, 100)
    tspan2 = np.linspace(50, 100, 50)
    tspan3 = np.linspace(100, 150, 100)
    model = tyson_oscillator.model
    sim = ScipyOdeSimulator(model, integrator='lsoda')
    simres1 = sim.run(tspan=tspan1)
    # Check retrieving a single simulation dataframe
    df_single = simres1.dataframe

    # Generate multiple trajectories
    trajectories1 = simres1.species
    trajectories2 = sim.run(tspan=tspan2).species
    trajectories3 = sim.run(tspan=tspan3).species

    # Try a simulation result with two different tspan lengths
    sim = ScipyOdeSimulator(model, param_values={'k6' : [1.,1.]}, integrator='lsoda')
    simres = SimulationResult(sim, [tspan1, tspan2], [trajectories1, trajectories2])
    df = simres.dataframe

    assert df.shape == (len(tspan1) + len(tspan2),
                        len(model.species) + len(model.observables))

    # Next try a simulation result with two identical tspan lengths, stacked
    # into a single 3D array of trajectories
    simres2 = SimulationResult(sim, [tspan1, tspan3],
                               np.stack([trajectories1, trajectories3]))
    df2 = simres2.dataframe

    assert df2.shape == (len(tspan1) + len(tspan3),
                         len(model.species) + len(model.observables))
开发者ID:LoLab-VU,项目名称:pysb,代码行数:35,代码来源:test_simulationresult.py

示例3: test_earm_integration

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def test_earm_integration():
    """Ensure earm_1_0 model simulates."""
    t = np.linspace(0, 1e3)
    # Run with or without inline
    sim = ScipyOdeSimulator(earm_1_0.model, tspan=t)
    sim.run()
    if sim._compiler != 'python':
        # Also run without inline
        ScipyOdeSimulator(earm_1_0.model, tspan=t, compiler='python').run()
开发者ID:alubbock,项目名称:pysb,代码行数:11,代码来源:test_simulator_scipy.py

示例4: test_earm_integration

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def test_earm_integration():
    """Ensure earm_1_0 model simulates."""
    t = np.linspace(0, 1e3)
    # Run with or without inline
    sim = ScipyOdeSimulator(earm_1_0.model, tspan=t)
    sim.run()
    if ScipyOdeSimulator._use_inline:
        # Also run without inline
        ScipyOdeSimulator._use_inline = False
        ScipyOdeSimulator(earm_1_0.model, tspan=t).run()
        ScipyOdeSimulator._use_inline = True
开发者ID:,项目名称:,代码行数:13,代码来源:

示例5: test_robertson_integration

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def test_robertson_integration():
    """Ensure robertson model simulates."""
    t = np.linspace(0, 100)
    # Run with or without inline
    sim = ScipyOdeSimulator(robertson.model)
    simres = sim.run(tspan=t)
    assert simres.species.shape[0] == t.shape[0]
    if sim._compiler != 'python':
        # Also run without inline
        sim = ScipyOdeSimulator(robertson.model, tspan=t, compiler='python')
        simres = sim.run()
        assert simres.species.shape[0] == t.shape[0]
开发者ID:alubbock,项目名称:pysb,代码行数:14,代码来源:test_simulator_scipy.py

示例6: test_robertson_integration

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def test_robertson_integration():
    """Ensure robertson model simulates."""
    t = np.linspace(0, 100)
    # Run with or without inline
    sim = ScipyOdeSimulator(robertson.model)
    simres = sim.run(tspan=t)
    assert simres.species.shape[0] == t.shape[0]
    if ScipyOdeSimulator._use_inline:
        # Also run without inline
        ScipyOdeSimulator._use_inline = False
        sim = ScipyOdeSimulator(robertson.model, tspan=t)
        simres = sim.run()
        assert simres.species.shape[0] == t.shape[0]
        ScipyOdeSimulator._use_inline = True
开发者ID:,项目名称:,代码行数:16,代码来源:

示例7: TestScipyOdeCompilerTests

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
class TestScipyOdeCompilerTests(TestScipySimulatorBase):
    """Test vode and analytic jacobian with different compiler backends"""
    def setUp(self):
        super(TestScipyOdeCompilerTests, self).setUp()
        self.args = {'model': self.model,
                     'tspan': self.time,
                     'integrator': 'vode',
                     'use_analytic_jacobian': True}

        self.python_sim = ScipyOdeSimulator(compiler='python', **self.args)
        self.python_res = self.python_sim.run()

    def test_cython(self):
        sim = ScipyOdeSimulator(compiler='cython', **self.args)
        simres = sim.run()
        assert simres.species.shape[0] == self.args['tspan'].shape[0]
        assert np.allclose(self.python_res.dataframe, simres.dataframe)

    def test_theano(self):
        sim = ScipyOdeSimulator(compiler='theano', **self.args)
        simres = sim.run()
        assert simres.species.shape[0] == self.args['tspan'].shape[0]
        assert np.allclose(self.python_res.dataframe, simres.dataframe)

    @unittest.skipIf(sys.version_info.major >= 3, 'weave not available for '
                                                  'Python 3')
    def test_weave(self):
        sim = ScipyOdeSimulator(compiler='weave', **self.args)
        simres = sim.run()
        assert simres.species.shape[0] == self.args['tspan'].shape[0]
        assert np.allclose(self.python_res.dataframe, simres.dataframe)
开发者ID:alubbock,项目名称:pysb,代码行数:33,代码来源:test_simulator_scipy.py

示例8: test_integrate_with_expression

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def test_integrate_with_expression():
    """Ensure a model with Expressions simulates."""

    Monomer('s1')
    Monomer('s9')
    Monomer('s16')
    Monomer('s20')

    # Parameters should be able to contain s(\d+) without error
    Parameter('ks0',2e-5)
    Parameter('ka20', 1e5)

    Initial(s9(), Parameter('s9_0', 10000))

    Observable('s1_obs', s1())
    Observable('s9_obs', s9())
    Observable('s16_obs', s16())
    Observable('s20_obs', s20())

    Expression('keff', (ks0*ka20)/(ka20+s9_obs))

    Rule('R1', None >> s16(), ks0)
    Rule('R2', None >> s20(), ks0)
    Rule('R3', s16() + s20() >> s16() + s1(), keff)

    time = np.linspace(0, 40)
    sim = ScipyOdeSimulator(model, tspan=time)
    simres = sim.run()
    keff_vals = simres.expressions['keff']
    assert len(keff_vals) == len(time)
    assert np.allclose(keff_vals, 1.8181818181818182e-05)
开发者ID:alubbock,项目名称:pysb,代码行数:33,代码来源:test_simulator_scipy.py

示例9: test_unicode_obsname_nonascii

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
 def test_unicode_obsname_nonascii():
     """Ensure non-ascii unicode observable names error in python 2."""
     t = np.linspace(0, 100)
     rob_copy = copy.deepcopy(robertson.model)
     rob_copy.observables[0].name = u'A_total\u1234'
     sim = ScipyOdeSimulator(rob_copy)
     simres = sim.run(tspan=t)
开发者ID:alubbock,项目名称:pysb,代码行数:9,代码来源:test_simulator_scipy.py

示例10: test_unicode_exprname_nonascii

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
 def test_unicode_exprname_nonascii():
     """Ensure non-ascii unicode expression names error in python 2."""
     t = np.linspace(0, 100)
     rob_copy = copy.deepcopy(robertson.model)
     ab = rob_copy.observables['A_total'] + rob_copy.observables['B_total']
     expr = Expression(u'A_plus_B\u1234', ab, _export=False)
     rob_copy.add_component(expr)
     sim = ScipyOdeSimulator(rob_copy)
     simres = sim.run(tspan=t)
开发者ID:alubbock,项目名称:pysb,代码行数:11,代码来源:test_simulator_scipy.py

示例11: test_unicode_obsname_ascii

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def test_unicode_obsname_ascii():
    """Ensure ascii-convetible unicode observable names are handled."""
    t = np.linspace(0, 100)
    rob_copy = copy.deepcopy(robertson.model)
    rob_copy.observables[0].name = u'A_total'
    sim = ScipyOdeSimulator(rob_copy)
    simres = sim.run(tspan=t)
    simres.all
    simres.dataframe
开发者ID:alubbock,项目名称:pysb,代码行数:11,代码来源:test_simulator_scipy.py

示例12: test_unicode_exprname_ascii

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
def test_unicode_exprname_ascii():
    """Ensure ascii-convetible unicode expression names are handled."""
    t = np.linspace(0, 100)
    rob_copy = copy.deepcopy(robertson.model)
    ab = rob_copy.observables['A_total'] + rob_copy.observables['B_total']
    expr = Expression(u'A_plus_B', ab, _export=False)
    rob_copy.add_component(expr)
    sim = ScipyOdeSimulator(rob_copy)
    simres = sim.run(tspan=t)
    simres.all
    simres.dataframe
开发者ID:alubbock,项目名称:pysb,代码行数:13,代码来源:test_simulator_scipy.py

示例13: Earm10ODESuite

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
class Earm10ODESuite(object):
    def setup(self):
        self.nsims = 100
        self.timer = timeit.default_timer
        self.model = earm_1_0.model
        self.model.reset_equations()
        self.parameter_set = np.repeat(
            [[p.value for p in self.model.parameters]], self.nsims, axis=0)
        integrator_options_common = {
            'model': self.model,
            'tspan': np.linspace(0, 20000, 101),
            'param_values': self.parameter_set
        }

        self.sim_lsoda = ScipyOdeSimulator(
            integrator='lsoda',
            compiler='cython',
            integrator_options={'atol': 1e-6, 'rtol': 1e-6, 'mxstep': 20000},
            **integrator_options_common
        )
        self.sim_lsoda_no_compiler_directives = ScipyOdeSimulator(
            integrator='lsoda',
            compiler='cython',
            cython_directives={},
            integrator_options={'atol': 1e-6, 'rtol': 1e-6, 'mxstep': 20000},
            **integrator_options_common
        )

        self.sim_cupsoda = CupSodaSimulator(
            integrator_options={'atol': 1e-6, 'rtol': 1e-6, 'max_steps': 20000},
            **integrator_options_common
        )

    def time_scipy_lsoda(self):
        self.sim_lsoda.run()

    def time_scipy_lsoda_no_compiler_directives(self):
        self.sim_lsoda_no_compiler_directives.run()

    def time_cupsoda(self):
        self.sim_cupsoda.run()
开发者ID:LoLab-VU,项目名称:pysb,代码行数:43,代码来源:simulator.py

示例14: TestSimulationResultEarm13

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
class TestSimulationResultEarm13(object):
    def setUp(self):
        self.model = earm_1_3.model
        self.tspan = np.linspace(0, 100, 101)
        self.sim = ScipyOdeSimulator(self.model, tspan=self.tspan)
        self.simres = self.sim.run()

    @raises(ValueError)
    def test_dynamic_observable_nonpattern(self):
        self.simres.observable('cSmac')

    @raises(ValueError)
    def test_match_nonexistent_pattern(self):
        m = self.model.monomers
        self.simres.observable(m.cSmac() % m.Bid())

    def test_on_demand_observable(self):
        m = self.model.monomers
        assert isinstance(self.simres.observable(m.cSmac()), pd.Series)
开发者ID:LoLab-VU,项目名称:pysb,代码行数:21,代码来源:test_simulationresult.py

示例15: ScipyOdeSimulator

# 需要导入模块: from pysb.simulator import ScipyOdeSimulator [as 别名]
# 或者: from pysb.simulator.ScipyOdeSimulator import run [as 别名]
from __future__ import print_function
from pysb.simulator import ScipyOdeSimulator
from tutorial_a import model

t = [0, 10, 20, 30, 40, 50, 60]
simulator = ScipyOdeSimulator(model, tspan=t)
simresult = simulator.run()
print(simresult.species)
开发者ID:LoLab-VU,项目名称:pysb,代码行数:10,代码来源:run_tutorial_a.py


注:本文中的pysb.simulator.ScipyOdeSimulator.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。