Question regarding passing input arguments in fmincon

7 views (last 30 days)
Hi All,
I am solving an optimization problem.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,time_exp,expZ,tSpan,z0)
sol = ode45(@(t,z)model(t,z,c), tSpan, z0); % Is this step required?
ModelZ = deval(sol, time_exp);
cost = ModelZ-expZ;
Any help would be highly appreciated.
  14 Comments
Deepa Maheshvare
Deepa Maheshvare on 26 Apr 2019
Edited: Deepa Maheshvare on 26 Apr 2019
Hi Torsten,
Thanks a ton for all the clarifications.
Since my model is in xml file , I am using SimBiology toolbox .I have created a model object using
modelObj = sbmlimport('Model.xml')
cs = getconfigset(modelObj);
cs.SolverType = 'ode15s';
cs.StopTime = 24;
[t, x, names] = sbiosimulate(modelObj);
There is a function call available for parameter estimation in SimBiology toolbox.
sbiofit(model,estimatedParam,'fmincon')
However, I am not sure how the input arguments of the estimation method,fmincon, has to be passed.I have a confusion here,
I've already specified p0,lb,ub in estimatedParam array with properties Name, InitialValue and Bounds
estimatedParams = estimatedInfo(paramsToEstimate,'InitialValue',ParameterInitialValues,'Bounds',ParameterBounds)
Moreover, for the other arguments that have to be passed in the function call to fmincon,
fmincon(@objective,p0,A,b,Aeq,beq,lb,ub,nlcon)
p0 , lb,ub are already defined in estimatedParam in sbiofit(model,estimatedParam,'fmincon')
I'm not sure how to set up A=[],b=[],Aeq=[],beq = [] and define nlcon since the model is in xml format.
Could you please provide some suggestions on how to proceed?
Torsten
Torsten on 26 Apr 2019
Sorry, but I don't have experience with the SimBiology toolbox.

Sign in to comment.

Answers (1)

Alan Weiss
Alan Weiss on 23 Apr 2019
I am not sure that I understand what you mean by "I want to pass ODEs as a constraint to fmincon." What about the ODE solution is a constraint? Do you want the minimum value of the solution to be above zero? Do you want the ODE solution to lie in a certain box? Once you explicitly define what you mean by the ODE solution is a "constraint," then I think that the answer to your question will be obvious. You will solve the ODE, get sol, and then write the constraint in terms of sol, maybe fun(deval(sol,tspan)) for some appropriate function fun and set of times tspan.
Alan Weiss
MATLAB mathematical toolbox documentation
  4 Comments
Deepa Maheshvare
Deepa Maheshvare on 23 Apr 2019
Hi,
I'm sorry , I haven't explained it clearly.
"Maybe you are trying to fit your ODE solution to some observed (measured) values as a function of time."
No, the experimental measurements are all steady state values. For example , for the variable z1, there are 5 experimental studies that report the steady state value from experiment(z1_exp1,z1_exp2,z1_exp3,z1_exp4,z1_exp5). This gives me a range i.e. bound
z1_max and z1_min.
With z1_max and z1_min as the constraint , I wish to do the following
" restrict the values of the solution at all times to be in a certain range, not just the final values".Therefore, I am not sure whether it is appropriate to use lsqcurvefit ,used in the suggestions provided,for my problem.
Alan Weiss
Alan Weiss on 23 Apr 2019
Sorry, I am unable to understand what you are trying to do, so this will be my last reply. I suggest that you write out equations or inequalities describing your constraint. Seriously, write them down. Then, given those equations or inequalities, you can write a corresponding nonlinear constraint function in fmincon syntax, restricting the result by using deval on the solution at relevant times. If you don't understand what I am suggesting, sorry, maybe someone else can help.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!