I am trying to find the values of two parameters that allow for a specific result of my differential equations, under different initial conditions.
Given a system of equations:
TestSystem = {H'[t] == p - H[t] (k1 sh[t]), H[0] == H0,
sh'[t] == -k1 H[t] sh[t] + k2 ss[t], sh[0] == sh0,
st == sh[t] + ss[t]};
I use ParametricNDSolve
to compute the values of the dependent variables, while leaving k1
and k2
unspecified:
TestSolver[H0e_, st0_] :=
ParametricNDSolve[
TestSystem /. p -> 0 /. {H0 -> H0e}
/. sh0 -> st0 /. st -> st0
/. k2 -> k2estim /. k1 -> k1estim, {h, sh, st}, {t, 0,
300}, {k1estim, k2estim}];
The conditions that I want to evaluate are then specified by m,d,hh
, at t=300
:
m = 100 sh[k1estim, k2estim][300]/st;
d = 100 ss[k1estim, k2estim][300]/st;
hh = h[k1estim, k2estim][300];
cond1a[k1estim_, k2estim_] :=
Evaluate[m /. st -> 5.*^-6 /. TestSolver[1.*^-5, 5.*^-6]]
cond1b[k1estim_, k2estim_] :=
Evaluate[d /. st -> 5.*^-6 /. TestSolver[1.*^-5, 5.*^-6]]
cond1c[k1estim_, k2estim_] :=
Evaluate[hh /. TestSolver[1.*^-5, 5.*^-6]]
cond2a[k1estim_, k2estim_] :=
Evaluate[m /. st -> 5.*^-6 /. TestSolver[5.*^-5, 5.*^-6]]
cond2b[k1estim_, k2estim_] :=
Evaluate[d /. st -> 5.*^-6 /. TestSolver[5.*^-5, 5.*^-6]]
cond2c[k1estim_, k2estim_] :=
Evaluate[hh /. TestSolver[5.*^-5, 5.*^-6]]
Now, say that I wanted to find the following
1 < cond1a < 100,
0 < cond1b < 1,
1.*^-8 < cond1c < 1*^-5,
1 < cond2a < 50,
50 < cond2b < 100,
1.*^-8 < cond2c < 1*^-5,
How could I find the values of k1
and k2
that would satisfy such a thing?
I was considering using NMinimize
like this:
NMinimize[{1/cond1a+cond1b+cond1c+cond2a+1/cond2b+cond2c,cons},{k1,k2}]
(where cons
would be the required constrains).
Yet, this does not seem like an efficient and plausible way to solve this problem. Does anyone have any ideas on how I could approach this problem? Given that this is a multi-objective optimization problem, how would you suggest that I could specify the objective function?
Thank you so much!
k1,k2
. $\endgroup$NMinimize::incst:
error. I'll try to work around this. Also, would you like to post your suggestion as answer? $\endgroup$