Mathematical Methods for Managing Distributed Energy Resources