T=24;

cvx_begin

variable P(T)

minimize OBJ

subject to

Here T is the time which is equal to T=24 hours. How can I write the difference as an inequality? i mean

P(T)-P(T-1)<10 ؟

for example for for 6 o’clock P(6)-P(5)<10

Unfortunately, `diff`

is not supported for CVX variables or expressions. Also, CVX interprets `<`

as `<=`

, so use `<=`

, perhaps modified as shown below;

`P(2:T) - P(1:T-1) <= 10 - small_positive_number`

is a vectorized way of specifying 23 constraints.

If there’s some special logic for 24:00 clock, and circular wrapping or whatever, I’ll let you deal with that.