How can I formulate this in CVX

Hello, Thanks for posting.

It looks like there is nothing preventing d[n] from being negative, in which case summands in the objective function can be concave.