  We consider the problem of behind-the-meter EV charging by a prosumer,
co-optimized with rooftop solar, electric battery, and flexible consumptions
such as water heaters and HVAC. Under the time-of-use net energy metering
tariff with the stochastic solar production and random EV charging demand, a
finite-horizon surplus-maximization problem is formulated. We show that a
procrastination threshold policy that delays EV charging to the last possible
moment is optimal when EV charging is co-optimized with flexible demand, and
the policy thresholds can be computed easily offline. When battery storage is
part of the co-optimization, it is shown that the net consumption of the
prosumer is a two-threshold piecewise linear function of the behind-the-meter
renewable generation under the optimal policy, and the procrastination
threshold policy remains optimal, although the thresholds cannot be computed
easily. We propose a simple myopic solution and demonstrate in simulations that
the performance gap between the myopic policy and an oracle upper bound appears
to be 0.5-7.5%.
