MATLAB Answers

Solve optimization problem that iterates on parameters with constraints defined with numerical solutions to differential equations depending on those parameters

3 views (last 30 days)
I want to search for an optimum in a problem where the constraints are numerical solutions of differential equations (these equations don't have analytical solutions) but the parameters I want to iterate on are parameters that appear in the differential equation so that the solver would need to:
  • compute the numerical solution to the differential equations with current parameters
  • check if my constraints on the numerical solutions are verified and compute
  • if they are not, change parameters and compute the numerical solutions again to see if it gets closer
  • once they are, try to minimize my objective function (which is also a function of these parameters) which to complicate even more is the maximum value in a vector
I don't have a lot of code to show because I don't know where to begin but basically I would like to do this :
objective: minimize (max(k))
tspan = [0 5];
theta0 = [deg2rad(10) 0];
function dthetadt = odefcn(t,theta,k,I,theta_0,theta_2,Fm,Fg,l,n)
dthetadt = zeros(2,1);
dthetadt(1) = theta(2);
dthetadt(2) = (1/I)*(-k(1)*(theta(1)-theta_0)-k(2)*(theta(1)-theta_2)+Fm*l*sin(theta(1))-Fg*l*cos(theta(1)));
[t,theta] = ode45(@(t,theta) odefcn(t,theta,k), tspan, theta0);
theta(t_final)-theta_objective < tol
I guess come optimization toolboxes offer this possibility but I can't find one.
Thanks in advance.

Accepted Answer

Alan Weiss
Alan Weiss on 20 May 2020
Perhaps the example Fit an Ordinary Differential Equation (ODE) can help.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by