Maximization problem
조회 수: 6 (최근 30일)
이전 댓글 표시
I was wondering if someone could help me with maximisation problem in MATLAB.
I need to maximise sum[-ln(v(i)) - u^2(i)/v(i)], where v(i) = S^2(i) and the following formula is given for S^2:
S^2(n) = w + A*u^2(n-1) + B*S^2(n-1).
I have data set for u(i) for i=1....n. i.e. u(i)'s are given.
Additional info:
w = G*V; V = w/(1-A-B).
A + B + G = 1.
Basically, I need to find optimal parameter values for w, A and B which maximise the sum I gave above.
My data set is too long, so I can't use Excel and I would really appreciate it if someone could help me out with the code. Thanks.
댓글 수: 0
채택된 답변
Matt Tearle
2011년 5월 24일
If I'm interpreting correctly, your v (aka S^2) is recursively defined. So presumably you have some way to determine u(0) and S(0)^2. Based on that, you can write a function to determine v(k) either as a matrix calculation or using a loop.
v = @(x) (diag(ones(n,1),0)+diag(-x(3)*ones(n-1,1),-1))\(x(1)+[x(2)*u0^2+x(3)*v0;x(2)*u(1:end-1).^2]);
Now define your objective function
f = @(x) sum(-log(v(x)) - u.^2./v(x));
Then apply a minimization routine
xmin = fminsearch(f,x0)
were x0 is your initial guess for x = [w;A;B].
EDIT TO ADD Based on comments below, here's a fuller solution:
n = 123;
v0 = 0;
u = %get u;
u0 = u(1,1);
v = @(x) (diag(ones(n,1),0)+diag(-x(3)*ones(n-1,1),-1))\(x(1)+[x(2)*u0^2+x(3)*v0;x(2)*u(1:end-1).^2]);
f = @(x) -sum(-log(v(x)) - u.^2./v(x));
x0 = [0.001; 0.0626; 0.8976];
xmin = fmincon(f,x0,[0,1,1],1,[],[],[-Inf;0;0],[Inf;1;1],[],optimset('Algorithm','interior-point'))
-f(xmin)
If you have Global Optimization Toolbox, you can do this multiple times:
ms = MultiStart;
problem = createOptimProblem('fmincon','x0',x0,...
'objective',f,'lb',[-Inf;0;0],'ub',[Inf;1;1],'Aineq',[0,1,1],'bineq',1,'options',optimset('Algorithm','interior-point'));
xmin = run(ms,problem,30)
-f(xmin)
(change the 30 to whatever you consider sufficient). If you don't have Global Opt TB, you could program it yourself. Make a grid of initial points, loop over them, and keep the best solution. Or do a loop and use a random x0 each time.
댓글 수: 7
Matt Tearle
2011년 5월 25일
OK... but just for the record: the 7th and 8th arguments of fmincon ([-Inf;0;0] & [Inf;1;1]) are the constraints on the values of w, A, and B. If V>0 then w>0 also, so you can change these to [0;0;0] & [Inf;1;1].
When I run it, I don't get G=0. If you want to force >0 rather than >=0, you can use realmin instead of 0 in the bounds.
추가 답변 (1개)
Michael Johnston
2011년 5월 24일
It's somewhat confusing the way you've written the question (e.g., it's not clear if by S^2(n) you mean S^2*n or S(n)^2 or what). But basically it looks like a simple constrained optimization problem. Look through the documentation, give it your best shot. If you get stuck, come back and post your code and the error.
참고 항목
카테고리
Help Center 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!