ams.core.service.MinDurWindow#

class ams.core.service.MinDurWindow(u: Callable, u2: Callable, name: str = None, tex_name: str = None, unit: str = None, info: str = None, vtype: Type = None, no_parse: bool = True, sparse: bool = False)[source]#

Build the Rajan-Takriti window-sum coefficient matrix for the interior minimum on/off duration constraints in UC.

Returns a sparse (n_gen * n_ts, n_gen * n_ts) block-diagonal matrix W with:

W[(g, t), (g, s)] = 1   iff   s ∈ [t - TU_g + 1, t]
                        AND   t >= TU_g - 1

where TU_g = ceil(td[g] / Δt) (the duration in periods). Used in UC as:

cp.reshape(Wup @ cp.vec(vgd, order='C'), vgd.shape, order='C')
    - ugd <= 0

so that each (g, t) row enforces Σ_{s window} v[g, s] u[g, t] (and symmetrically for wgd on the off-side). Boundary periods t < TU_g - 1 get all-zero rows — Phase 2 (MinDurInit) covers those via the initial-state lock.

The block-diagonal structure makes the LP relaxation of UC tight in the Rajan-Takriti convex-hull sense, while the sparse representation keeps memory linear in the number of nonzeros.

Parameters:
uCallable

Var with horizon — used for shape (n_gen, n_ts) only.

u2Callable

RParam carrying the per-device duration in hours (td1 for on-side, td2 for off-side).

name, tex_name, unit, info, vtype, no_parse, sparseoptional

Forwarded to MinDur / NumOpDual.

Notes

Returns scipy.sparse.csr_matrix regardless of the sparse flag — the dense fallback would defeat the size advantage. The flag is accepted for API parity with MinDur only. Defaults no_parse=True because the sparse output cannot be wrapped in cvxpy.Parameter; the e_str eval substitutes the raw matrix at parse time.

__init__(u: Callable, u2: Callable, name: str = None, tex_name: str = None, unit: str = None, info: str = None, vtype: Type = None, no_parse: bool = True, sparse: bool = False)[source]#

Methods

assign_memory(n)

Assign memory for self.v and set the array to zero.

evaluate(*args, **kwargs)

get_all_idxes()

Return all the indexes of this item.

get_idx()

get_names()

Return name in a list

parse(*args, **kwargs)

update()

Update the Parameter value.

Attributes

class_name

Return the class name

e

Return the calculated numerical value of the underlying expression.

formulation_source

Where the live CVXPY object for this item came from.

n

Return the count of values in self.v.

shape

Return the shape of the service.

size

Return the size.

v

Value of the service.

v0

v1