  We introduce StoDynProg, a small library created to solve Optimal Control
problems arising in the management of Renewable Power Sources, in particular
when coupled with an Energy Storage System. The library implements generic
Stochastic Dynamic Programming (SDP) numerical methods which can solve a large
class of Dynamic Optimization problems. We demonstrate the library capabilities
with a prototype problem: smoothing the power of an Ocean Wave Energy
Converter. First we use time series analysis to derive a stochastic Markovian
model of this system since it is required by Dynamic Programming. Then, we
briefly describe the "policy iteration" algorithm we have implemented and the
numerical tools being used. We show how the API design of the library is
generic enough to address Dynamic Optimization problems outside the field of
Energy Management. Finally, we solve the power smoothing problem and compare
the optimal control with a simpler heuristic control.
