Why this error,Cannot perform the operation: {real affine} .* {convex}


#1

for example: A is a variable, B is a varizble
the goal function: A* -log(B) this is error

the goal function: A*-log(B/A) this is reeor too,but all of this is the convex

what should i do?


(Mark L. Stone) #2

A*(-log(B)) is indefinite, and therefore non-convex.

A*(-log(B/A)) can be handled using rel_entr…
A*(-log(B/A)) = A*log(A/B) = rel_entr(A,B)

help rel_entr

rel_entr Scalar relative entropy.
rel_entr(X,Y) returns an array of the same size as X+Y with the
relative entropy function applied to each element:
{ X.*LOG(X./Y) if X > 0 & Y > 0,
rel_entr(X,Y) = { 0 if X == 0 & Y >= 0,
{ +Inf otherwise.
X and Y must either be the same size, or one must be a scalar. If X and
Y are vectors, then SUM(rel_entr(X,Y)) returns their relative entropy.
If they are PDFs (that is, if X>=0, Y>=0, SUM(X)==1, SUM(Y)==1) then
this is equal to their Kullback-Liebler divergence SUM(KL_DIV(X,Y)).
-SUM(rel_entr(X,1)) returns the entropy of X.

Disciplined convex programming information:
    rel_entr(X,Y) is convex in both X and Y, nonmonotonic in X, and
    nonincreasing in Y. Thus when used in CVX expressions, X must be
    real and affine and Y must be concave. The use of rel_entr(X,Y) in
    an objective or constraint will effectively constrain both X and Y 
    to be nonnegative, hence there is no need to add additional
    constraints X >= 0 or Y >= 0 to enforce this.

#3

thanks,
the 2th function is the same as the rel_entr
but the 1th function isn’t,it can’t accept this rel_entr


(Mark L. Stone) #4

As i wrote above, A*(-log(B)) is indefinite, and therefore non-convex. It will not be accepted by CVX and can not be transformed into a form which will be accepted by CVX.