# A JuMP Formulation for the Minimum Up/Down Time Unit Commitment constraint

Hi I’m new to JuMP and i’m currently struggling to generate a working constraint for the Minimum Up/Down Time.

Indeed these are the “mathematical” formulation of what I wanna write:

Σv(i) <= u(t) for i in range [t-UpTime+1 ; t]
Σw(i) <= 1 - u(t) for i in range [t-DownTime+1 ; t]

To implement these constraints, this is how I proceeded :

``````    @variable(uc_m, u[g in gen_names, t in time_periods], Bin)
@variable(uc_m, v[g in gen_names, t in time_periods], Bin)
@variable(uc_m, w[g in gen_names, t in time_periods], Bin)
# MinUpTime
if t <= UpT
@constraint(uc_m, sum(v[name, i] for i in t-1:-1:1) <= u[t] )
else
@constraint(uc_m, sum(v[name, i] for i in (t-1):-1:(t-UpT+1))  <= u[t] )
end
# MinDownTime
if t <= DownT
@constraint(uc_m, sum(w[name, i] for i in t-1:-1:1) <= 1 - u[t] )
else
@constraint(uc_m, sum(w[name, i] for i in (t-1):-1:(t-DownT+1)) <= 1 - u[t] )
end
``````

The error I get is “Key 2.0 not found”. But my intuition was that the values below instant “t” would have already been computed by the optimization algorithm.

I would really be thankfull if someone could give me hints on how to write such constraints.

Thankss

This message suggests that `u` and/or `v` is a `Dict`, `t` is a `Float64`, and the keys of the `Dict`(s) are not `Float64`.

1 Like

Thank you very much.
Worked when I casted the indices to Int.

1 Like