Help in solving a weird error with yalmip!

68 views
Skip to first unread message

David

unread,
Apr 12, 2013, 1:53:38 AM4/12/13
to yal...@googlegroups.com
Hello all,

I have the following code

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = 50;
h = 1/N;
H1 = [ones(1,N-10) zeros(1,10)].';
H2 = 5*[ones(1,N-10) zeros(1,10)].';
x = sdpvar(N,1);
y = sdpvar(N,1);
Objective = 0.5*h*(sum(log(x))+sum(log(1-y.^2)));
Constraints = set(sum(h*abs(H2).*sqrtm(x).*y.*sqrt(abs(H1).^2+1/var))-0.5*sum(h*abs(H2).^2.*(x-1))-sum(h*real(conj(H2).*H1)) == 0);
Constraints = Constraints + set(sum(h*x) == 1);
Constraints = Constraints + set(-1<=y<=1)+set(x>=0);
assign(x,1)
assign(y,1)
solvesdp(Constraints,-Objective)
solx = double(x);
soly= double(y);
Objective = 0.5*h*(sum(log(solx.*(1-soly.^2))));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Now, using this code, I obtained that the maximal objective value is equal to 0.0819. However, if I simply choose the following solution

solx = ones(N_partition,1);
soly = H1./sqrt(abs(H1).^2+1);

which satisfy all the constraints, then the obtained objective is bigger = 0.2773 !! 

1. Where is my mistake?

2. Why when I changed the objective function from 

Objective = 0.5*h*(sum(log(x))+sum(log(1-y.^2)))

to

Objective = 0.5*h*(sum(log(x.*(1-y.^2))))

which are essentially the same, I obtained different solutions?

Thanks a lot!

David

unread,
Apr 12, 2013, 2:05:35 AM4/12/13
to yal...@googlegroups.com
For completeness, the problem that I wish to solve is mathematically given by

MAX 0.5*h*(sum(log(x))+sum(log(1-y.^2)))
{x,y}

SUBJECT TO

sum(h*abs(H2).*sqrtm(x).*y.*sqrt(abs(H1).^2+1/var))-0.5*sum(h*abs(H2).^2.*(x-1))-sum(h*real(conj(H2).*H1)) == 0
&&
sum(h*x) == 1
&&
x>=0
&&
-1<=y<=1.



Johan Löfberg

unread,
Apr 12, 2013, 2:12:21 AM4/12/13
to yal...@googlegroups.com
Are you saying that you can generate a better solution than what is obtained by the solver? That is of absolutely no surprise, as the problem looks nastily non-convex, hence a local solver will only give you *some* locally optimal point, if it even finds a feasible solution.

BTW: var is undefined so I cannot run the code

BTW2: SET is obsolete, use concatenation  
Constraints = [Constraints, sum(h*x) == 1];

Johan Löfberg

unread,
Apr 12, 2013, 2:21:08 AM4/12/13
to yal...@googlegroups.com
You are assigning initial values to x and y, but these will not be used since you haven't told the solver to use these
solvesdp(Constraints,-Objective,sdpsettings('usex0',1))




David

unread,
Apr 12, 2013, 2:24:01 AM4/12/13
to yal...@googlegroups.com
> Are you saying that you can generate a better solution than what is obtained by the solver? That is of absolutely no surprise, as the problem looks nastily non-convex, hence a local solver will only give you *some* locally
> optimal point, if it even finds a feasible solution.

Yes, exactly. What about changing the first equality constraint to inequality?


> BTW: var is undefined so I cannot run the code

Ops, just take var=1.

> BTW2: SET is obsolete, use concatenation  

OK, thanks!

Johan Löfberg

unread,
Apr 12, 2013, 2:25:59 AM4/12/13
to yal...@googlegroups.com
I think you are making some sign error on the objetive.

You want to minimize -Objective. The solution I get (using var=1) with fmincon is 0.08

If I compute the value with you solution, -Objective equals  0.27726 which is worse than the computed one. Hence, fmincon computes a better solution.

(in other words, -0.08 is bigger than -0.27 which is good since you want to maximize that number)

David

unread,
Apr 12, 2013, 2:33:14 AM4/12/13
to yal...@googlegroups.com
I want to obtain the following quantity

R = 

-1 * MAX 0.5*h*(sum(log(x))+sum(log(1-y.^2)))
{x,y}

SUBJECT TO

sum(h*abs(H2).*sqrtm(x).*y.*sqrt(abs(H1).^2+1/var))-0.5*sum(h*abs(H2).^2.*(x-1))-sum(h*real(conj(H2).*H1)) == 0
&&
sum(h*x) == 1
&&
x>=0
&&
-1<=y<=1.

Thus, I use solvesdp(Constraints,-Objective) to solve a minimization problem instead. 

David

unread,
Apr 12, 2013, 2:35:29 AM4/12/13
to yal...@googlegroups.com
Sorry, please Ignore my last comment.

Johan Löfberg

unread,
Apr 12, 2013, 2:35:31 AM4/12/13
to yal...@googlegroups.com
Well, it boils the curvature of sqrt(x)*y, which is neither convex nor concave, so it will never be a convex  constraint

[X,Y] = meshgrid(0:0.01:2,-1:0.01:1);
mesh((X.^.5).*Y)
Reply all
Reply to author
Forward
0 new messages