필터 지우기
필터 지우기

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

조회 수: 5 (최근 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
Darshna Joshi
Darshna Joshi 2022년 1월 13일
Okay.. Thanks will check it that way @Alan Weiss, I appreciate your timely response always.

댓글을 달려면 로그인하십시오.

추가 답변 (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
  댓글 수: 2
Darshna Joshi
Darshna Joshi 2023년 5월 23일
@Alan Weiss, i used the code to optimize x3 using fmincon as you stated, i want to apply optimal control to the same, how should i apply optimal control?
Alan Weiss
Alan Weiss 2023년 5월 23일
Sorry, I have no idea.
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