How to express this objective function with max in CVX?


(Dipak Narayanan) #1

Let D\in\mathbb{R}^{1\times P} is a known vector.
S is also a vector os same size.

The objective is:

minimize \sum\max(D-S,0)

That is I want to perform: minimize \sum_{i=1}^P\max(D_i-S_i,0)

How can I write this in CVX?


(Mark L. Stone) #2

I think
minimize(sum(max(D-S,0)))
should work.


(Dipak Narayanan) #3

@Mark_L_Stone

Yes, it works! Thank you.