# Illegal operation: {real affine} .^ {3}

(JLo) #1

Hi, I’m new in CVX programming and I want to maximize one function F that is a concave function such as:
f(a) = … + repmat(a,1,60) .^(D) + … where D is a NxM matrix and a is a row vector with Nx1
When I’m trying to maximize the F function I get the following error:

``````Error using cvx/pow_cvx (line 142)
Disciplined convex programming error:
Illegal operation: {real affine} .^ {3}
(Consider POW_P, POW_POS, or POW_ABS instead.)

Error in  .^  (line 55)
z = pow_cvx( x, y, 'power' );
``````

Someone can help?

(Mark L. Stone) #2

Look up pow_p, pow_pos, and pow_abs in the CVX Users’ Guide http://cvxr.com/cvx/doc/funcref.html#new-functions or online help, and determine whether one of them is applicable to your problem (for instance, if you know the real affine expression is always non-negative).

The context in which you describe this in your first paragraph seems rather unclear and inconsistent, so I am not very clear what you are really trying to do. You say a is a row vector, which makes repmat(a,1,60) a row vector, but you also say a is N by 1. And somehow you are doing element-wise exponentiation to a matrix, which MATLAB won’t allow unless it is 1 by 1. So you must not be doing this, or you wouldn’t even get to the point of receiving the error you got. And of course the objective function must evaluate to a scalar.

EDIT: Note that if you use pow_p, pow_pos, or pow_abs, with p = 3, this will produce a convex expression, which can be minimized in CVX, but not maximized. As indicated above, the context of the error within your program is not clear from your description, so at this time, I do not know whether you have a convex problem or not, and whether CVX can be used to solve it.