# Simple quadratic sequence makes Invalid quadratic form(s): not a square. error

Hi, here is the function and constraints that I’m going to maximize

``````cvx_begin
variable v_1_1
variable v_1_2
variable v_2_1
variable v_2_2
variable v_3_1
variable v_3_2
variable v_4_1
variable v_4_2

maximize( (v_1_1*v_2_1 + v_1_2*v_2_2)*w(1,2) + (v_3_1*v_4_1 + v_3_2*v_4_2)*w(3,4) + (1-
(v_1_1*v_3_1 + v_1_2*v_3_2))*w(1,3) + (1-(v_1_1*v_4_1 + v_1_2*v_4_2))*w(1,4) + (1-
(v_2_1*v_3_1 + v_2_2*v_3_2))*w(2,3) + (1-(v_2_1*v_4_1 + v_2_2*v_4_2))*w(2,4) )

subject to
v_1_1 + v_1_2 <= 1
v_2_1 + v_2_2 <= 1
v_3_1 + v_3_2 <= 1
v_4_1 + v_4_2 <= 1

v_1_1 + v_1_2 + v_2_1 + v_2_2 + v_3_1 + v_3_2 + v_4_1 + v_4_2 <= 4

v_1_1 >= 0
v_1_2 >= 0
v_2_1 >= 0
v_2_2 >= 0
v_3_1 >= 0
v_3_2 >= 0
v_4_1 >= 0
v_4_2 >= 0

v_1_1 <= 1
v_1_2 <= 1
v_2_1 <= 1
v_2_2 <= 1
v_3_1 <= 1
v_3_2 <= 1
v_4_1 <= 1
v_4_2 <= 1

cvx_end
``````

However i got the following error

``````Error using  .*  (line 262)
Disciplined convex programming error:
Invalid quadratic form(s): not a square.

Error in  *  (line 36)
z = feval( oper, x, y );
``````

Is my function not convex? is there something i can do to fix this?

You haven;t told us what W is. if W is all zeros, then the objective function is zero and hence, trivially concave, and the optimization problem is convex. Otherwise, this is not a convex optimization problem and you will need a tool which can handle non-convex Quadratic Programs.

Hi Mark, w is either 1 or -1.

Well, the problem s not convex. The objective function is indefinite, i.e., neither concave nor convex.