How to use the gillespy2.solvers.auto.ssa_solver.get_best_ssa_solver function in gillespy2

To help you get started, we’ve selected a few gillespy2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github StochSS / stochss / stochss / handlers / util / generate_notebook_cells.py View on Github external
def get_run_settings(settings, show_labels, is_mdl_inf, algorithm):
    # Map algorithm for GillesPy2
    solver_map = {"SSA":"",
                  "V-SSA":'"solver":solver',
                  "ODE":'"solver":BasicODESolver',
                  "Tau-Leaping":'"solver":BasicTauLeapingSolver',
                  "Hybrid-Tau-Leaping":'"solver":BasicTauHybridSolver'}

    if get_best_ssa_solver().name == "SSACSolver":
        solver_map['SSA'] = '"solver":solver'

    # Map seed for GillesPy2
    if settings['seed'] == -1:
        settings['seed'] = None

    # Map number_of_trajectories for model inference
    if is_mdl_inf and settings['realizations'] < 30:
        settings['realizations'] = 100

    # Map algorithm settings for GillesPy2. GillesPy2 requires snake case, remap camelCase
    settings_map = { "number_of_trajectories":settings['realizations'], 
                     "seed":settings['seed'], 
                     "tau_tol":settings['tauTol'], 
                     "integrator_options" : str({ "rtol":settings['relativeTol'], "atol":settings['absoluteTol'] })
                   }
github StochSS / stochss / stochss / handlers / util / generate_notebook_cells.py View on Github external
def generate_imports_cell(json_data, gillespy2_model, is_ssa_c=False, settings=None):
    # Imports cell
    imports = 'import numpy as np\n'
    if json_data['is_spatial']:
        # Spatial
        imports += 'import spatialPy\n'
    else:
        # Non-Spatial
        imports += 'import gillespy2\n'
        imports += 'from gillespy2.core import Model, Species, Reaction, Parameter, RateRule, AssignmentRule, FunctionDefinition\n'
        imports += 'from gillespy2.core.events import EventAssignment, EventTrigger, Event\n'
        algorithm = get_algorithm(gillespy2_model, is_ssa_c) if settings is None or settings['isAutomatic'] else get_algorithm(gillespy2_model, is_ssa_c, algorithm=settings['algorithm'])
        if algorithm == "SSA" and get_best_ssa_solver().name == "SSACSolver":
            ssa = 'from gillespy2.solvers.cpp.ssa_c_solver import SSACSolver\n'
        else:
            ssa = '# To run a simulation using the SSA Solver simply omit the solver argument from model.run().\n'
        algorithm_map = {
                'SSA': ssa,
                'V-SSA': 'from gillespy2.solvers.cpp.variable_ssa_c_solver import VariableSSACSolver\n',
                'Tau-Leaping': 'from gillespy2.solvers.numpy.basic_tau_leaping_solver import BasicTauLeapingSolver\n',
                'Hybrid-Tau-Leaping': 'from gillespy2.solvers.numpy.basic_tau_hybrid_solver import BasicTauHybridSolver\n',
                'ODE': 'from gillespy2.solvers.numpy.basic_ode_solver import BasicODESolver'
                }

        for name, algorithm_import in algorithm_map.items():
            if settings is not None and not settings['isAutomatic'] and name == algorithm:
                imports += algorithm_import
            else:
                if not algorithm_import.startswith("#"):