The CVX program bug for SOCP problem

this my problem for location agorithm
@Mark_L_Stone @mcg

i am counter a problem that matlab report as
Error using <= (line 22)
Disciplined convex programming error:
Invalid constraint: {real affine} <= {positive convex}

Error in location (line 45)
r2 <= norm( x-a2 ,2)

follows my code

d1=12.5
d2=6.9
d3=6.1
d4=13.5
d5=2.3
a1 = [-0.3,3.28]’
a2 = [8.34,-0.5]’
a3 = [6.1,6.34]’
a4 = [1.09,-1]’
a5 = [12.49,3.16]’
c1=[-tan(0.277),1]
c2=[-tan(1.418),1]
c3=[-tan(-0.465),1]
c4=[-tan(0.3249),1]
c5=[-tan(-3.14),1]
n=2;
cvx_begin
variable x(n)
variable t1
variable t2
variable z1
variable z2
variable z3
variable z4
variable z5
variable g1
variable g2
variable g3
variable g4
variable g5
variable r1
variable r2
variable r3
variable r4
variable r5
minimize(t1+t2)
subject to
z1==r1-d1
z2==r2-d2
z3==r3-d3
z4==r4-d4
z5==r5-d5
r1 <= norm( x-a1 ,2)
r2 <= norm( x-a2 ,2)
r3 <= norm( x-a3 ,2)
r4 <= norm( x-a4 ,2)
r5 <= norm( x-a5 ,2)
g1==c1*(x-a1)
g2==c2*(x-a2)
g3==c3*(x-a3)
g4==c4*(x-a4)
g5==c5*(x-a5)
norm( [2z1,2z2,2z3,2z4,2z5,t1-1],2)<=t1+1
norm( [2
g1,2g2,2g3,2g4,2g5,t2-1],2)<=t2+1
cvx_end

Hi. There is no need to address your question to individuals. Whoever can answer it will answer it.

Your problem is not a SOCP. Your first constraint type, ri <= norm( x-ai ,2) is going in the wrong direction to be convex. That is why you got an error message.

Also note that using vector variables will make your code simpler and easier to modify if you change the value of N. However you version is still correct (other than constraint type I mentioned going in the wrong direction).

@Mark_L_Stone Thank you very much!
The first constraint type whether I can covert into other type? such as change the equation or introduce other parameters for the constraint. I don’t understand the problem about the wrong direction well Thank you !

Convex expression <= affine is a convex constraint.
Convex expression >= affine, which is your first constraint type, is not a convex constraint.

So your problem, as formulated, is not a convex optimization problem. I am not saying whether or not your formulation is “correct” for the real world problem you are trying to model.

You might benefit from reading http://stanford.edu/~boyd/cvxbook/ , and working some of the problems in the book.