Problem in inputting constrains for fmincon with ODE45
Show older comments
I have the following problem:
I am trying to regress a set of parameters of a set of reactions. My reaction rate expressions are formulated as shown below:
R1 = beta(1)*k1*y(1);
R2 = beta(2)*k2*y(2);
R3 = beta(3)*k3*k4*y(1)*y(2);
k1, k2, k3, k4 are all constants fed to the code.
The rate of change of specie y(1) and y(2) are formulated using ode functions
dydz(1) = -R1+R2;
dydz(2) = R3;
these ODEs are implemented in matlab's ode45 solver.
in order to regress the fitting parameters (beta), I am using fmincon to determine the values of these fitting parameters.
Now, my question is:
I have some linear and non-linear constraints on the values of y(1), y(2) that I want to put in the optimisation. but I don't know how to do that. This is because matlab deals with the constraints as function of the optimisation variables (beta(1), beta(2), beta(3)).
Do you have any idea on how to solve this problem??
Thanks
2 Comments
Torsten
on 1 Aug 2016
Since y(1), y(2) are functions of z, you will have to tell us the z-value(s) at which you want to constrain y(1) and y(2).
Best wishes
Torsten.
Mohamed Al Jamri
on 1 Aug 2016
Answers (1)
Torsten
on 1 Aug 2016
0 votes
If you want to set the constraint y1(z=1) <= 3, e.g, you can just set
c(1)=y(end,1)-3.0
in fmincon's "nonlcon" function.
Best wishes
Torsten.
2 Comments
Mohamed Al Jamri
on 1 Aug 2016
Torsten
on 1 Aug 2016
You get the actual parameters "params" to be fitted handed to nonlcon:
function [c,ceq] = nonlcon(params)
Now with these parameters, solve your differential equations
[T,Y]=ode45(...)
and return
ceq(1) = Y(end,1)-0.158;
c=[];
Best wishes
Torsten.
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!