Micro-grids require active control to maintain quality of service and to interface with the power grid in a bi-directional manner. Further, micro-grids must be justified by environmental, governmental, and economic viability. We present a programmable architecture for active, optimal distributed control of elements of the grid to achieve desired behavior. A unique aspect of this architecture is to include a distributed inductive engine for learning the local dynamics of generators and loads in the micro-grid. It generates feedback laws that are adapted to the current status of the micro-grid, and responds to anomalous events in a resilient manner. An important novelty is that control laws are extracted online for bidirectional discontinuous nonlinear loads by mean field methods from physics outside the standard design methodologies for piecewise linear quadratic controls.Index Terms-Bidirectional power flow, computational and artificial intelligence, decentralized control, distributed parameter systems, learning systems, micro-grids, power engineering and energy, power system control, power system management, smart grids. He is currently collaborating with his long-term co-author in hybrid optimal control, W. Kohn, developing quantum hybrid control, and co-founded Kohn-Nerode LLC, Dover, DE, USA. With J. Myhill, he proved the Myhill-Nerode Theorem, specifying necessary and sufficient conditions for a formal language to be regular. His current research interests include mathematical logic, the theory of automata, computability and complexity theory, mathematics of artificial intelligence, control engineering, and quantum control of macroscopic systems.Prof.