Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
obj.amici_solver.setSensitivityOrder(sensi_order)
# run amici simulation
rdatas = amici.runAmiciSimulations(
obj.amici_model,
obj.amici_solver,
obj.edatas,
num_threads=min(obj.n_threads, len(obj.edatas)),
)
# check if any simulation failed
if any([rdata['status'] < 0.0 for rdata in rdatas]):
return obj.get_error_output(rdatas)
# edatas to numpy arrays (TODO cache this?)
edatas = [amici.numpy.ExpDataView(edata)
for edata in obj.edatas]
# compute optimal parameters (code base same for fw+ad)
# create matrices from optimal parameters (only fw)
# compute objective and derivatives (only fw)
# compute optimal parameters
#optimal_scalings = compute_optimal_scaling_matrix(self.problem, edatas, rdatas)
# compute optimal surrogate data
if self.problem.optimalScalingOptions['timeInnerProblem']:
import time
from datetime import date
num_repeat = 50
#edatas = [amici.numpy.ExpDataView(edata)
def qualitative_inner_problem_from_petab_problem(
petab_problem: petab.Problem,
amici_model: 'amici.Model',
edatas: List['amici.ExpData']):
# inner parameters
inner_parameters = inner_parameters_from_parameter_df(
petab_problem.parameter_df)
x_ids = [x.id for x in inner_parameters]
# used indices for all measurement specific parameters
ixs = ixs_for_measurement_specific_parameters(
petab_problem, amici_model, x_ids)
# print(ixs)
# transform experimental data
edatas = [amici.numpy.ExpDataView(edata)['observedData']
for edata in edatas]
# print(edatas)
# matrixify
ix_matrices = ix_matrices_from_arrays(ixs, edatas)
# print(ix_matrices)
# assign matrices
for par in inner_parameters:
par.ixs = ix_matrices[par.id]
return OptimalScalingProblem(inner_parameters, edatas)