I am trying to determine a battery's state of charge (SOC) $b(t)$ from generation and load curves, $g(t)$ and $l(t)$. The recursive expression for the SOC is:
$b(t+1) = min[C, max(0, b(t) + g(t) - l(t))]$
where $C$ is battery capacity. Is there any way to write this as a convex optimization problem? Of course, $b(t)$ can be found iteratively, but I later want to optimize over $g(t)$ and $l(t)$. I know the nesting of $min()$ and $max()$ is not convex in general, but here since I am taking $min()$ and $max()$ with a constant, it seems it should be possible. If I am misunderstanding convexity for this case, I would like to understand why.
The goal would be to put $g(t)$ and $l(t)$ into CVX and determine the vector $b(t)$.