Find best input combinations that will maximize the output of a non-linear ODE mathematical model

3 次查看(过去 30 天)
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 个评论
Darshna Joshi
Darshna Joshi 2021-9-6
@darova@Alan Weiss Below is my matlab code for solving ODE. How to use fmincon for the same. As i am new to it even after looking into the help section of fmincon, couldn't solve the issue.
The problem is to find the optimum(maximum) value of x3 in range of (-8e-4 to 2e-4) by varying kst,x1,x5 and xo)
x5=5 %Input 2 (Input 2 is a state variable and could vary in range of 4 to 15 while performing optimization)
kst=1 %Input 3 (Input 3 is in terms of rate constant, it could vary from 0.1 to 2)
xo=4 %Input 4 (Input 4 is a state variable and could vary in range of 4 to 10)
x1=1e-7 %Input 1 could vary from 1e-9 to 1e-6
%MATLAB CODE%
%Script file
function rest = Scrpt1(t,X)
x2 = X(1);
x3 = X(2);
%Parameters
if t<15
x1 = 1e-7; %Input 1 could vary from 1e-9 to 1e-6
else x1 = 0;
end
x5=5 %Input 2 (Input 2 is a state variable and could vary in range of 4 to 15 while performing optimization)
kst=1 %Input 3 (Input 3 is in terms of rate constant, it could vary from 0.1 to 2)
xo=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
% Function file for ODE solution
options = odeset('InitialStep',0.0001,'RelTol',1e-09);
[T,Y]=ode15s(@Scrpt1,[0 60],[9e-13,0],options);
X3= Y(:,2);
plot(T,X3)
How to use fmincon or any other optimization solver for this to solve the mentioned optimization problem of finding maximum value of x3. For which values of x5,kst,xo,x1 we get maximum x3?
My objective function is Maximize(x3).

请先登录,再进行评论。

采纳的回答

Alan Weiss
Alan Weiss 2021-9-6
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 个评论
Alan Weiss
Alan Weiss 2022-1-12
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

请先登录,再进行评论。

更多回答(1 个)

Alan Weiss
Alan Weiss 2021-8-8
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

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by