This thesis focuses on models and methods for large scale and complex systems, with applications to distributed electricity resources. It is organized into three parts. In the first part, we show how to formulate the participation of distributed electricity resources -- consisting of plug-in electric vehicles and residential photovoltaic panels -- in the real-time and day-ahead electricity markets using convex optimization models. We show how these large scale problems can be efficiently solved by distributing them using a dual splitting approach. Using this structure, we then derive algorithms that allow to solve these problems efficiently and study their convergence properties. Finally, we illustrate our approach with multiple study cases on different markets. In the second part, we develop novel first-order heuristics methods, called Hopfield methods, based on Hopfield Neural Networks; in order to find candidate solutions to large-scale combinatorial optimization problems. We study the geometry and the convergence of these new methods and show how they connect with known convex optimization models and algorithms. We then illustrate how these methods perform on large nonlinear problems. In the last part, we present a new class of optimization models, implicit optimization, which includes deep learning, nonlinear control, and mixed-integer programming as special cases. Implicit optimization provides a unified perspective on these different fields, leading to new algorithms and surprising connections. We propose two tractable algorithms to solve such problems based on their implicit equation structure: implicit gradient descent and the Fenchel alternative direction method of multipliers. We illustrate our theory and methods with numerical experiments and dedicate a whole chapter on implicit deep learning architectures and methods