0
$\begingroup$

This is a follow up to my previous question posted here. I am solving an optimization problem using fmincon in MATLAB. There are no equality constraints in my model. I want to pass ODEs as constraint to fmincon using, non-linear constraint, nlcon argument. The function model contains odes

function dz = model(t, z, c)  
              dz(1) = ..
              dz(2) = ..

I'd like to ask how the ode intergrator has to be called in the place of nlcon in fmincon(@objective,p0,A,b,Aeq,beq,lb,ub,nlcon).

%p0 = Initial Value of Parameters
A = [];
b = [];
Aeq = [];
beq = [];
nlcon  = ode45(@(t,z)model(t,z,x), tSpan, z0); % Is this correct?
p = fmincon(@objective,p0,A,b,Aeq,beq,lb,ub,nlcon); 

Since the ode function is already called in nlcon , is it required to call the function model again inside the objective function?

function cost = objective(c,expZ,tSpan,z0)
sol = ode45(@(t,z)model(t,z,c), tSpan, z0); % Is this step required?
ModelZ = sol(end,:)%  the solutions obtained from model at end point of tSpan
cost = ModelZ-expZ; %expZ contains steady state values of z1,z2.. 

Any help would be highly appreciated.

$\endgroup$
2
  • $\begingroup$ Did you find a solution for your previous question? $\endgroup$
    – nicoguaro
    Apr 23, 2019 at 13:09
  • $\begingroup$ @nicoguaro In order to find a solution I am implementing this based on the suggestion received in the previous post $\endgroup$
    – Natasha
    Apr 23, 2019 at 15:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.