I don 't see anything obviously wrong with the program,. However, please copy and paste code using Preformatted text icon, rather than posting an image.
Which statement is triggering the error message? Perhaps you can make a minimal reproducible version of this problem, with a self-contained small amount of input data.
Make sure you are using CVX 2.2, not CVX 3.0beta, which is riddled with bugs.
Thanks for your reply! I just replacee rel_entr() with log(), then the error disappeared. I don’t know the cause. Maybe it’s because I don’t install the package cvx_quad before using rel_entr().
CVXQUAD should not be necessary to use rel_entr
If you are using CVX 2.2, perhaps you encountered a not previously known bug in rel_entr
. It looks to me that you are following the rules. Specifically, the first argument being affine (which constant is), and the 2nd argument being concave, which should allow for nested -rel_entr
.
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.
My thanks to you again! It seems that the code is correct. I did use CVX 2.2, so as you say, that may be an unknown bug. Fortunately, it has been solved the other way.