Optimization. Convex nonlinear function. Exponential mixture

1 次查看(过去 30 天)
Dear comrades, I am trying to solve the problem on resolving the mixture of two exponentials. The data comes in the Y(response measured from the system) over t (time) histogram. The task I have formulated sounds like this: Minimize |yhat(c,t)-y|; where yhat = c(3)*exp(-t*c(1)) + c(4)*exp(-t*c(2)) subject to c(1-4)>=1 and c(3)+c(4)=1.
Here are my attempts in solving it (2 in total):
(1)With the use of Optimization Toolbox:
close all, clear all
t = [0 .3 .8 1.1 1.6 2.3]';
y = [.82 .72 .63 .60 .55 .50]';
plot(t,y,'o')
yhat = @(c,t) c(3)*exp(-t*c(1)) + c(4)*exp(-t*c(2));
c0=[0.5; 0.5; 2; 30]
c = fmincon(@(c)yhat(c,t)-y, c0, [1,1,1,1], 0, [0,0,1,1], 1, [],[])
I receive an error:
??? Error using ==> fmincon at 647
User supplied objective function must return a scalar value.
(2) With the use of MATLAB Package bayesf
http://statmath.wu.ac.at/~fruehwirth/monographie/
Demo_mix_exponential.m in particular
Here I fail to plug my data into the problem.
I am greatly thankful for your suggestions and help.

回答(1 个)

Alan Weiss
Alan Weiss 2013-8-1
I am sorry, I do not understand your first constraint. You say "c(1-4)>=1" is the constraint, but this is neither mathematical nor in MATLAB notation. Perhaps you mean the sum of the values is at least 1: sum(c) >= 1. But maybe this is a complete misprint, and you really mean that all the c(i) are at least 0. You represent this as a bound constraint:
lb = zeros(4,1);
To represent the equality constraint, you did the right thing:
Aeq = [0,0,1,1];
beq = 1;
You should change c0 to be feasible:
c0 = [3,30,.5,.5];
The error you have is because your objective function does not return a scalar value. Use the following:
fun = @(c) sum(yhat(c,t) - y).^2;
Now you are ready to proceed:
c = fmincon(fun,c0,[],[],Aeq,beq,lb)
plot(t,yhat(c,t),t,y)
You will see that the fit is not very good. This is primarily because your data has y(1) = .82, whereas your restriction c(3) + c(4) = 1 imply that y(1) should be 1.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Community Treasure Hunt

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

Start Hunting!

Translated by