Gasoline compression ignition (GCI) engines are considered an attractive alternative to traditional spark-ignition and diesel engines. In this work, a Machine Learning-Grid Gradient Algorithm (ML-GGA) approach was developed to optimize the performance of internal combustion engines. Machine learning (ML) offers a pathway to transform complex physical processes that occur in a combustion engine into compact informational processes. The developed ML-GGA model was compared with a recently developed Machine learning Genetic Algorithm (MLGA). Detailed investigations of optimization solver parameters and variables limits extension were performed in the present ML-GGA model to improve the accuracy and robustness of the optimization process. Detailed descriptions of the different procedures, optimization tools and criteria that must be followed for a successful output are provided here. The developed MLGGA approach was used to optimize the operating conditions (case 1) and the piston bowl design (case 2) of a heavy-duty diesel engine running on a gasoline fuel with a Research Octane Number (RON) of 80. The ML-GGA approach yielded > 2% improvements in the merit function, compared to the optimum obtained from a thorough computational fluid dynamics (CFD) guided system optimization. The predictions from the ML-GGA approach were validated with engine CFD simulations. This study demonstrates the potential of ML-GGA to significantly reduce the time needed for optimization problems, without loss in accuracy compared to traditional approaches.