A delay-differential system for variables {y[t],z[t]} is defined by time-lag w
{y'[t] == (r (1 - y[t] - z[t]) - 1) y[t], z'[t] == (y[t] - y[t - w])}; The important constraint is 0<z[t]<1. When z crosses 0, the lagged term y[t-w] should be switched off. I tried WhenEvent with discrete 'switch' variable c[t]->0, and 'switch timing' Tc[t] =(t+w), to prevent z-decay, when z becomes negative. So after time Tc, the 'switch' on the loss term -y[t-w] could be turned on (c[t]->1)
(case r=1.2; w=20)
Ys = NDSolveValue[ {{Derivative[1][y][t] == y[t] (-1 + 1.2` (1 - y[t] - z[t])), Derivative[1][z][t] == -c[t] y[-20 + t] + y[t]}, {y[t /; t < 0], z[t /; t < 0]} == {.01, 0}, c[0] == 1, Tc[0] == 0, WhenEvent[t > 0 && z[t] == 0, {c[t] -> 0, Tc[t] -> t + 20}], WhenEvent[t == Tc[t], c[t] -> 1]}, {x@t, y@t, z@t}, {t, 0, t1 = 100}, DiscreteVariables -> {c, Tc}] The code run, but ignored all event controls, and produce unphysical solution with z[t] crossing into negative range. Any suggestions welcome.
P.S. The system formulated in integro-differential form:
y'[t] == (r (1 - y[t] - z[t]) - 1) y[t] z[t]=Integrate[y[s],{s,t-w,t}] But I don't know if that would make it more tractable


