Hello all, how I can solve ODE simultaneously with fmincon?

조회 수: 3 (최근 30일)
Muna Shehan
Muna Shehan 2016년 6월 26일
댓글: Alan Weiss 2021년 3월 3일
I have a system subject to ordinary differential equations (ODE) which are the linear equality constraints and at the same time i want to minimize the objective function which depends on the parameters which are the solution of the (ODE). I try to follow MathWorks Support Team answer
The problem I have a confuse to follow MathWorks Support Team answer ; I do not know if I have to solve ODE first then I send the ODE solution to the objective function via fmincon as a passing parameters OR I have to solve the ODE inside the objective function. Thanks
  댓글 수: 3
Arjun Manoj
Arjun Manoj 2021년 3월 3일
How do you pass the ode integrator inside nonlcon function?
Alan Weiss
Alan Weiss 2021년 3월 3일
For example,
function [c,ceq] = nonlcon(x,extraParams)
ceq = [];
sol = ode45(@odefun,tspan,y0); % You can include tspan or y0 in extraParams
y = deval(sol,extraParams.mytimes); % Assume you want the values at some times
% Figure out the constraint value, for example,
c = y - 25; % You want y to be less than 25
end
You would call this as
nlcon = @(x)nonlcon(x,extraParams);
where extraParams is a structure with the extra parameters, if any, that you want to pass to the nonlinear constraint function.
Alan Weiss
MATLAB mathematical toolbox documentation

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by