This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def ensure_amici_compatible(): | |
| minimum_amici_version = (0, 8, 4) | |
| current_amici_version = \ | |
| tuple([int(x) for x in amici.__version__.split('.')]) | |
| if current_amici_version < minimum_amici_version: | |
| raise RuntimeError(f'Must use AMICI version {minimum_amici_version}' | |
| ' or newer') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def globalize_parameters(sbml_model): | |
| """Turn all local parameters into global parameters""" | |
| for reaction in sbml_model.getListOfReactions(): | |
| law = reaction.getKineticLaw() | |
| # copy first so we can delete in the following loop | |
| local_parameters = [local_parameter for local_parameter | |
| in law.getListOfParameters()] | |
| for lp in local_parameters: | |
| # Create global parameter assuming names are globalized already | |
| p = sbml_model.createParameter() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef int (*objectiveFunction)(const double *, double *); | |
| typedef int (*objectiveFunctionGradient)(const double *, double *); | |
| int checkGradient(objectiveFunction objFun, objectiveFunctionGradient objFunGrad, int nParams, double *theta, double epsilon, int *indices, int nIndices); | |
| int checkGradient(objectiveFunction objFun, objectiveFunctionGradient objFunGrad, int nParams, double *theta, double epsilon, int *indices, int nIndices) { | |
| double gradient[nParams]; | |
| objFunGrad(theta, gradient); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void getLatinHyperCubeSamples(int numParameters, int numSamples, double *sample); | |
| int doubleSort(const void *x, const void *y); | |
| void rank(const double *in, double *out, int length); | |
| void getLatinHyperCubeSamples(int numParameters, int numSamples, double *sample) { | |
| for(int i = 0; i < numParameters; ++i) { | |
| double tmpSample[numSamples]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "ceres/ceres.h" | |
| class X2 : public ceres::FirstOrderFunction { | |
| public: | |
| virtual ~X2() {} | |
| virtual bool Evaluate(const double* parameters, | |
| double* cost, | |
| double* gradient) const { | |