$x \log(1+1/x)$ using CVX

My optimization program is

maximize(sum(x.*log( 1+1./x )))
subject to
    x >= 0
    sum(x) <= 1

and when running the code above, the following error occur
"cannot perform the operation: {positive constant}./{real affine}"
Does there exist some possible transformation that the problem can be dealt with cvx??

This seems highly nonconvex (especially given the affine constraints), in which case CVX cannot do much.

1 Like

Note that
$$x\log(1+x^{-1})= x\log(x+1)-x\log x.$$
The function rel_entr implements
$$f(x,y) = x\log(x/y) = x\log x-x\log y.$$
Therefore, I believe that -rel_entr(x,x+1) will give you the function you need.

That said, I must point you to the warning given by CVX when attempting to solve models using logarithms, exponentials, and entropy functions, which is elaborated on here in the user gude.

1 Like

mcg’s May 27, 2013 answer has a typo. It should be -rel_entr(x,x+1), not -rel_entr(x+1,x).

Thanks Mark, I’ve edited the post.

I’ve decided to make this post a FAQ…

how about xlog2(1+a/(bx+c)),how to solve it?