This paper describes how AI is used to plan, schedule, and optimise nightly engineering works for both the commuter and rapid transit lines in Hoag Kong. The MTR Corporation Limited operates and manages all the rail lines in Hong Kong. Its Engineering Works and Traffic Information Management System (ETMS) is a mission critical systemthat manages all information related to engineering works and their related track possessions and engineering train movements. The Al Engine described in this paper is a component of this ETMS. In Hong Kong, the maintenance, inspection, repair, or installation works along the rail lines are done during the very short non-traffic hours (NTH) of roughly 4 to 5 hours each night. These engineering works can be along the running tracks, track-side, tunnel, freightyards, sub-depots, depot maintenance tracks, etc. The proper scheduling of necessary engineering works is crucial to maintaining a reliable and safe train service during normal hours. The Al Engine optimizes resource allocation to maximize the number of engineering works that can be performed, while ensuring all safety, environment, and operational rules and constraints are met. The work described is part of a project to redesign and replace the existing ETMS, deployed in 2004 with an updated technology platform and modern IT architecture, to provide a more robust and scalable system that potentially can be deployed to other cities around the world.