In this work, a mathematical optimization procedure was used to improve the gas exchange process of a single-cylinder compression ignition naturally aspirated engine. Duct lengths and valve timing were chosen as optimization variables while volumetric efficiency was defined as the objective function. Calculations were carried out using a parallelized computational code consisting of (i) a one-dimensional model for the unsteady compressible gas flow taking place in intake and exhaust ducts; (ii) a single-zone combustion model for the in-cylinder processes; and (iii) an optimization routine based on the Differential Evolution technique. Three sets of optimization calculations were conducted. In the first one, the intake duct length was the only optimization variable and it was found that optimal inlet duct lengths vary becoming shorter as engine speed is increased. In the second set of calculations, both intake and exhaust duct lengths have been taken as the optimization variables, and the resulting optimal intake duct lengths were quite similar to those of the first set. In addition, optimal exhaust duct lengths resulted very close in value to optimal intake duct lengths, except at the highest speeds, when the decreasing tendency as engine speed is raised was supplanted by the opposite tendency. In the third set of calculations, the crank angles defining valve synchronism were the optimization variables. It was found that optimal valve timing produced a gain in volumetric efficiency, which is similar to that obtained with optimal duct lengths. (C) 2016 Elsevier Ltd. All rights reserved.