How to use the amici.petab_import.import_petab_problem function in amici

To help you get started, we’ve selected a few amici 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 ICB-DCM / pyABC / test / petab / test_petab.py View on Github external
benchmark_dir, depth=1)
    g = git.Git(benchmark_dir)

    # update repo if online
    try:
        g.pull()
    except git.exc.GitCommandError:
        pass

    # create problem
    petab_problem = petab.Problem.from_yaml(os.path.join(
        benchmark_dir, "Benchmark-Models",
        "Boehm_JProteomeRes2014", "Boehm_JProteomeRes2014.yaml"))

    # compile amici
    model = amici.petab_import.import_petab_problem(petab_problem)
    solver = model.getSolver()

    # import to pyabc
    importer = pyabc.petab.AmiciPetabImporter(petab_problem, model, solver)

    # extract required objects
    prior = importer.create_prior()
    model = importer.create_model()
    kernel = importer.create_kernel()

    # call model
    assert np.isclose(
        model(petab_problem.x_nominal_free_scaled)['llh'], -138.221996)

    # mini analysis
    temperature = pyabc.Temperature(
github ICB-DCM / pyABC / test / petab / test_petab_suite.py View on Github external
gt_simulation_dfs = solution[petabtests.SIMULATION_DFS]
    tol_chi2 = solution[petabtests.TOL_CHI2]
    tol_llh = solution[petabtests.TOL_LLH]
    tol_simulations = solution[petabtests.TOL_SIMULATIONS]

    # unique folder for compiled amici model
    output_folder = f'amici_models/model_{case}'

    # import petab problem
    yaml_file = os.path.join(case_dir, petabtests.problem_yaml_name(case))

    # create problem
    petab_problem = petab.Problem.from_yaml(yaml_file)

    # compile amici
    amici_model = amici.petab_import.import_petab_problem(
        petab_problem=petab_problem,
        model_output_dir=output_folder)
    solver = amici_model.getSolver()

    # import to pyabc
    importer = pyabc.petab.AmiciPetabImporter(
        petab_problem, amici_model, solver)
    model = importer.create_model(return_rdatas=True)

    # simulate
    problem_parameters = petab_problem.x_nominal_free_scaled
    ret = model(problem_parameters)

    llh = ret['llh']

    # extract results
github ICB-DCM / pyABC / pyabc / petab / amici.py View on Github external
def __init__(
            self,
            petab_problem: petab.Problem,
            amici_model: amici.Model = None,
            amici_solver: amici.Solver = None,
            free_parameters: bool = True,
            fixed_parameters: bool = False):
        super().__init__(
            petab_problem=petab_problem,
            free_parameters=free_parameters,
            fixed_parameters=fixed_parameters)

        if amici_model is None:
            amici_model = amici.petab_import.import_petab_problem(
                petab_problem)
        self.amici_model = amici_model

        if amici_solver is None:
            amici_solver = self.amici_model.getSolver()
        self.amici_solver = amici_solver