Schedule optimization is crucial to reduce energy consumption of flexible manufacturing systems (FMSs) with shared resources and route flexibility. Based on the weighted p-timed Petri Net (WTPN) models of FMS, this paper considers a scheduling problem which minimizes both productive and idle energy consumption subjected to general production constraints. The considered problem is proven to be a nonconvex mixed integer nonlinear program (MINLP). A new reachability graph (RG)-based discrete dynamic programming (DP) approach is proposed for generating near energy-optimal schedules within adequate computational time. The nonconvex MINLP is sampled, and the reduced RG is constructed such that only reachable paths are retained for computation of the energy-optimal path. Each scheduling subproblem is linearized, and each optimal substructure is computed to store in a routing table. It is proven that the sampling-induced error is bounded, and this upper bound can be reduced by increasing the sampling frequency. Experiment results on an industrial stamping system show the effectiveness of our proposed scheduling method in terms of computational complexity and deviation from optimality.Note to Practitioners-Motivated by the need to optimize energy efficiency in manufacturing community, this paper considers an energy-optimal scheduling problem for FMSs with shared resources and flexible part routing. This class of FMSs class can be encountered nowadays in many realistic manufacturing plants such as flowlines, job shops, and material handling systems, etc. Therein, different resources require different productive powers (when resources hold parts) and processing times to perform the same job; and their idle powers (when resources release parts) are also variant. As such, the considered problem optimizes both productive and idle energy consumption, which is often omitted by other energy-efficient scheduling techniques in current literature. A novel and fundamental scheduling method is presented which is based on WTPNs and a newly proposed algorithm called RG-based DP. Given an FMS with complete information of part types, jobs, and resources, our proposed scheduling method is able to generate near energy-optimal schedules within adequate computational time. The practicality of the considered problem and the usability of our proposed scheduling method are verified using energy data logged from an industrial stamping system, in Manuscript which the stamping parts are various types of voice coil motor yokes used in commercial hard disk drive actuators. Beyond the energy-optimal scheduling application, our proposed scheduling method can be also applied to other industrial problems which involve the costs per time unit, including labor management and scheduling, aircraft landing scheduling, project management, and resource rental optimization, etc.Index Terms-Discrete event system, dynamic programming (DP), energy optimization, nonconvex programming, p-timed Petri Nets.