I'm working with the differential equation:
$$\frac{dP}{dt}=rP(1-\frac{P}K)-H(t)$$ $$P(0)=P_0$$
where $r$ and $K$ are known values. The idea is that $H(t)$ is a piecewise function such that from $t=0, H(t)=H_0$ (also a known value) but when $P(t)$ is below a certain value $p_1$ then $H(t)=0$ until $P(t)$ is greater than a certain value $p_2>p_1$.
After this, $H(t)=H_0$ again until $P(t)$ is below $p1$, and so on. I think the graph of the $P(t)$ function should look like a zig-zagging line.
I've been trying to numerically solve such equation but I don't know how to code such function. The only way I can think of describing such function $H(t)$ is by using a boolean variable that keeps track of the growth of $P$, but I don't think I can do that inside the NDSolve function.
Any ideas on how H would be so
NDSolve[{P'[t] == r (1 - P[t]/K)*P[t] - H[t], P[0] == P0}, P, {t, 0, 20}]
doesn't outputs errors?