# Convex or nonconvex problem

(Elham) #1

I have a question that is

minimum trace Q(sigma)
Q=(SQRT(I*sigma))^p
where p and sigma are convex variable
AND I is IDENTITY MATRIX
is convex??
because my cvx give error. to solve this problem.
thanks

(Mark L. Stone) #2

(ya) #3

HI,
I also have a problem in which constraint is

\sum_{v=1}^{\infty} \sum_{u=1}^{u} 1/(u!v!) x^{u2.5} exp(-cx^2.5)< 0.5

x >100;

I am trying to write it in CVS format but it is showing log concave error.

(Mark L. Stone) #4

@tani You haven’t told us what the optimization variables or expressions are, so we don’t even know what this is,. I don’t know what x^(u2.5) is supposed to be.

Let’s look at x^2.5 * exp(-x^2.5) .That is neither convex nor concave even for x > 0. I don’t know how that relates to your attempted function. Anyhow, it is your responsibility to show that your constraint is convex. Please read the link in my previous post (to the other poster) in this thread.

(ya) #5

Optimization variable is ‘x’, the objective function is convex which is monotonically decreasing function.

Minimize over x, : k_1* (1+x) +K_2 * (P- norm[x H ])

constraint as i mentioned above.

About 2.5 that is a constant design parameter. Actually this 2.5 is making a big trouble in writing the constraint in cvx.

Now do you think i can write it.

(Mark L. Stone) #6

Please write out the constraint in MATLAB, even if it would be rejected by CVX.

(ya) #7

I updated my post here because I had space limitation since I am new user.

Dear Sir,
K_1=1.667, K_2=28000; D=1000;H=100;Tau=0.3;m=3;a=2;c=2;
cvx_begin
variable x
minimize (K_1*(1+norm([(D-x) H]))+K_2x)
subject to
0.29
(1-constraintMyProb(x,b,a,c))<=0.3;
0 <= x <= D
cvx_end
%% -----------
Here is the function to implement constraint,
function out= constraintMyProb(xVec,b,alpha,c),
for xx=1:length(xVec),
x=xVec(xx);
SumTermInner=0;
for v=1:100,
for u=1:v,
SumTermInner=SumTermInner+b^(u-1)/(factorial(v-1)* factorial ((u-1)))* x^((u-1)alpha);
end
end
temp(xx)=SumTermInner
exp(- c*x^alpha);
end
out=temp;

What I am trying here is to somehow write the constraint in CVX to get the optimal result. I hope this time it would be clear to you.

(Mark L. Stone) #8

I just want to see clearly what the constraint is mathematically. Write it in MATLAB CVX code, even if CVX would reject it.

You need to provide context of what you are trying to do with D- sqrt{x^2-H^2) .

(ya) #9

Dear Sir,
I wrote this code for the constraint.

D=20;
d=(0:2:D);H=5;
xVec=sqrt((D-d).^2+H^2);
c=0.02;
SNRLin=10000;
alpha=2.5;
b=2/SNRLin;
for xx=1:length(xVec),
x=xVec(xx);
SumTermInner=0;
for v=1:100,
for u=1:v,
SumTermInner=SumTermInner+b^(u-1)/(factorial(v-1)* factorial ((u-1)))* x^((u-1)*alpha);
end
end
temp(xx)=SumTermInner*exp(- c*x^alpha);

end
[Valueopt , index]=find (temp>= 0.7 );
x_opt=xVec(index(1));


If i want to transform
xVec=sqrt((D-d).^2+H^2) using d as a variable. Then I get ‘d=D-sqrt(xVec.^2-H^2)’; I dont know how i can write this in the format of NORM. This was my second question toward implementing the constraint.

I just want to see clearly what the constraint is mathematically. Write it in MATLAB CVX code, even if CVX would reject it.

You need to provide context of what you are trying to do with D- sqrt{x^2-H^2) .
[/quote]

(Mark L. Stone) #10

I still don’tunderstand what you are trying to do.

Please show a complete CVX program, with all input data provided, which implements the optimization problem you are trying to solve, even if some portions of the code do not comply with CVX’s DCP rules, and therefore produce an error message. Then it will be clear to forum readers what optimization problem you want to solve. it will be helpful if you provide comments discussing which portions of the code are not compliant with CVX’s rules, and therefore need reformulation.

(ya) #11

I updated my post here because I had space limitation since I am new user.

Dear Sir,

K_1=1.667, K_2=28000; D=1000;H=100;Tau=0.3;m=3;a=2;c=2;
cvx_begin
variable x
minimize (K_1*(1+norm([(D-x) H]))+K_2 <em>x)
subject to
0.29</em> (1-constraintMyProb(x,b,a,c))&lt;=0.3;
0 &lt;= x &lt;= D
cvx_end
%% -----------
Here is the function to implement constraint,
function out= constraintMyProb(xVec,b,alpha,c),
for xx=1:length(xVec),
x=xVec(xx);
SumTermInner=0;
for v=1:100,
for u=1:v,
SumTermInner=SumTermInner+b^(u-1)/(factorial(v-1)* factorial ((u-1)))* x^((u-1) <em>alpha);
end
end
temp(xx)=SumTermInner* exp(- c*x^alpha);
end
out=temp;


What I am trying here is to somehow write the constraint in CVX to get the optimal result. I hope this time it would be clear to you.

(Mark L. Stone) #12

Could you please copy and paste “clean” code without spurious characters and use the Preformatted text icon. And please verify it displays properly.

(ya) #13

The optimization problem is this:
Minimize x, : K_1 * (1 + \sqrt {(D-x)^2+H^2} + K_2 * x)

subject to: 1- \sum_{v=1}^{\infty} \sum_{u=1}^{u} b^(u-1)/(u!v!) x^{ua} exp(-cx^a) \le tau

0 < x < D ;

The code for optimization problem in CVX is ,

% Variable initialization
H=100;
D=1000;
Tau=0.3;
a=2;c=2;
K_1=1.667;
K_2=28000;

cvx_begin

variable x
% objective funtion
minimize ( K_1 * (1 + norm ([(D-x) H]) ) + K_2 * x)

subject to

% constraint in the form of infinite summation:
% I wrote its function as a optimization variable which is showing error
(1-constraintMyProb (x , b , a , c)) <= Tau;

% constraint domain of x
0 <= x <= D

cvx_end

The function used to implement the summation in constraint 'constraintMyProb ’ is,

function out= constraintMyProb(xVec,b,alpha,c),

for xx=1:length(xVec),

x=xVec(xx);

SumTermInner=0;

for v=1:100,

for u=1:v,

SumTermInner=SumTermInner+b^(u-1)/(factorial(v-1)* factorial ((u-1)))* x^((u-1)*alpha);

end

end

temp(xx)=SumTermInner*exp(- c*x^alpha);


end

out=temp;

The function i wrote to solve the constraint and I am having problem here only. This is where I need help. I hope this time I would have cleared the ambiguity. Thank you.

(Mark L. Stone) #14

Your constraint is non-convex. Consider just the first term in the nested for loops in the constraint function. That is non-convex as written, but can be reformulated.

With just that first term, the constraint could be written in the form
log(SumTermInner) + c*x^alpha <= -log(1 - Tau)
which will be accepted by CVX.