Maximization problem

12 views (last 30 days)
Julia
Julia on 24 May 2011
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.

Accepted Answer

Matt Tearle
Matt Tearle on 24 May 2011
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 Comments
Matt Tearle
Matt Tearle on 25 May 2011
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.

Sign in to comment.

More Answers (1)

Michael Johnston
Michael Johnston on 24 May 2011
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.
  1 Comment
Julia
Julia on 24 May 2011
It's S(n)^2 and it is a simple optimisation problem. The thing is I'm pretty bad at Matlab and I'm under time pressure. I guess it's just gonna be a very long night with Excel then. God help me.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!