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)
Johan Poccard on 19 May 2020
Commented: Johan Poccard on 24 May 2020
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))
constraints:
I=1;
k01=0.1;
theta_0=deg2rad(5);
k12=0.1;
theta_2=deg2rad(5);
Fm=10;
Fg=0.1;
l=30*10^(-3);
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)));
end
[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.
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Alan Weiss on 20 May 2020
Perhaps the example Fit an Ordinary Differential Equation (ODE) can help.
Alan Weiss
MATLAB mathematical toolbox documentation
##### 7 CommentsShowHide 6 older comments
Johan Poccard on 24 May 2020
Thank you !

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!