minimise two functions simultaneously

13 次查看(过去 30 天)
Hello,
I have an ODE15s function with 4 simultaneous equations, there are a 7 chemical kinetic rate constants (K) to derive the time changes in four parameters. I am using three of these rate constants to minimise two of the equations simultaneously to two sets of data obtained from the same experiment.
I have tried fminsearch but this only allows the minimisation of one of the functions to one of the data sets based on the difference in the sum of squares error.
I am presently trying fgoalattain to try to get two minimum SSE from two functions against the data but I cannot see how to code it, the goals are presently the SSEs but I need it to change the K values so that the SSEs are minimised. I am also looking at gamultiobj but need to work out how fgoalattain works first and if it will do the job. I have the global optimisation toolbox.
Any help or advice.
Thanks, matt

采纳的回答

Sarah Wait Zaranek
It may be brute force. But, I first would try fmincon. fmincon is usually what I try first! You probably have limits for your constraints (K values, like they can't be less than zero). Your objective function would then be the difference between your calculated values to your experimental values. You can use whatever metric you want - but I would tend to use something like SSE, as well.
The syntax would be the following:
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)
where x0 is your initial guess for you chemical rate constants. fun would be a function handle to a function that takes these constants and calculates the SSE for both your data sets. If you want any relationship between your constants, you can set those in A and b or Aeq or beq -- if not you can set them to []. lb and ub can be used to set minimum and maximum values for your rate constant parameters.
You can then use the multistart option and/or the globalsearch options in the Global Optimization toolbox to ensure that you did not find a local minimum.

更多回答(1 个)

Andrew Newell
Andrew Newell 2011-3-7
I'm not sure if I understand your problem, so here is my interpretation. Let's say
eqs = f(t,K)
is your system, where
K = [K0 kvals]
is composed of a 4-vector K0 (fixed) and a 3-vector kval (variable). Let's say that
[t,y] = ode15s(@(t) f(t,K),tspan,y0)
is the way you calculate the output (and tspan is a vector, so t = tspan ). The output y is a matrix with 4 rows, one for each equation. You want to fit, say, equations 1 and 2 to data ydata, so you're trying to minimize a residual sum of squares
res = sum(sum((y(1:2,:)-ydata).^2)).
Then, if you create a function
res = predictData(kvals)
you should be able to apply fminsearch.
EDIT: If you want to use fmincon (I think Sarah is right about that), you could make a function
res = predictData(K)
and then constrain the four variables in Aeq. This would make it easier to modify your constraints on the K values.
  3 个评论
Matthew jones
Matthew jones 2011-3-7
I am presently coding up your above answers but this is not my strong point so I'll get back to you soonish with the results. As an aside as it is two sets of data I have will Matlab automatically in res = sum(sum((y(1:2,:)-ydata).^2))
compare y(1,:) to ydata(1,:) and y(2,:) to ydata(2,)?
Sarah Wait Zaranek
If you set up ydata to do a 2xnumber of time points matrix, then yes - MATLAB will do what you want. It will do a element-wise subtraction. The .^2 will do an element-wise power. Then when you do the first sum - you will sum over column, basically summing the sum of error squared per solution - and then the next sum will sum those two values together. Does that make sense?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by