Find best input combinations that will maximize the output of a non-linear ODE mathematical model
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Darshna Joshi
le 7 Août 2021
Commenté : Alan Weiss
le 23 Mai 2023
How to find the best combinations of inputs (3 inputs) that will give the maximum output. Please note that I have a non-linear ODE model with output also as differential eqn. Also, i have SBML file, how to proceed for the same?
2 commentaires
Réponse acceptée
Alan Weiss
le 6 Sep 2021
Add the parameters to optimize as a vector in your ODE calculation:
function rest = Scrpt1(t,X,params)
x2 = X(1);
x3 = X(2);
%Parameters
if t<15
x1 = params(1); %Input 1 could vary from 1e-9 to 1e-6
else
x1 = 0;
end
x5 = params(2); %Input 2 (Input 2 is a state variable and could vary in range of 4 to 15 while performing optimization)
kst = params(3); %Input 3 (Input 3 is in terms of rate constant, it could vary from 0.1 to 2)
xo = params(4); %Input 4 (Input 4 is a state variable and could vary in range of 4 to 10)
k1 = 6e7;
km1 = 0.20;
km4 = 0.003;
k3 = 2500.00;
k4 = km4/9;
km3 = km1;
LAP = 1.5;
%Differential equations
dx2dt = km1*x3 + km3*LAP - k1*x1*x2 + km4*x3 - k4*x2;
dx3dt = k1*x1*x2 - km1*(x3+x5+xo) - k3*x3*kst;
rest = [dx2dt; dx3dt];
end
Write your objective function as follows:
function y = objfun(params)
options = odeset('InitialStep',0.0001,'RelTol',1e-09);
[~,Y] = ode15s(@(t,X)Scrpt1(t,X,params),[0 60],[9e-13,0],options);
y = -Y(end,2); % Negative because you want to maximize
% I assume that you want the value of Y at the last time
end
Obtain the solution:
lb = [1e-9,4,0.1,4];
ub = [1e-6,15,2,10];
x0 = [1e-7,5,1,4];
opts = optimoptions("fmincon","PlotFcn","optimplotfval");
[sol,fval] = fmincon(@objfun,x0,[],[],[],[],lb,ub,[],opts)
% The true function value is -fval because you negated y
Alan Weiss
MATLAB mathematical toolbox documentation
16 commentaires
Alan Weiss
le 12 Jan 2022
Sorry, I am not sure that I understand what you are asking. If you are asking how to use ga instead of fmincon as the optimizer, just put ga instead of fmincon. The only difference in syntax is that for ga you give the number of variables in the second argument, nvar instead of an initial point x0. The nvar argument is the length of the x0 vector. Also, ga expects row vectors as arguments, so you might need to change some things, I didn't examine your problem in detail to see whether some of your arguments are matrices or column vectors.
Alan Weiss
MATLAB mathematical toolbox documentation
Plus de réponses (1)
Alan Weiss
le 8 Août 2021
I don't know what an SBML file is. But to optimize an ODE you can look at these examples:
Alan Weiss
MATLAB mathematical toolbox documentation
2 commentaires
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!