This paper deals with the optimization of complex energy systems given a cost objective function. The optimization uses a decomposition strategy based on the second law of thermodynamics and a concept for costing the components of a system. A large number of nonlinear decision variables can be optimized with enhanced convergence to an optimum. The paper is in two parts. In this part, the methodology is described. In Part 2, the methodology is applied to a simple energy system of 10 components and 19 manipulated decision parameters. The system is treated once as a single purpose combined cycle and once as a power-heat cogenerating system. The results of the application are summarized and evaluated. Further development is encouraged.