Cooling systems play a key role in maintaining human comfort inside buildings. The key challenges that are facing conventional cooling systems are the rapid growth of total cooling energy and annual electricity consumption in commercial buildings. This is even more significant in countries with an arid climate, where the cooling systems are typically working 80% of the year. Thus, there has been growing interest in developing smart control models to assign optimal cooling setpoints in recent years. In the present work, we propose an occupancy-based control model that is based on a non-linear optimization algorithm to efficiently reduce energy consumption and costs. The model utilizes a Monte-Carlo method to determine the approximate occupancy schedule for building thermal zones. We compare our proposed model to three different strategies, namely: always-on thermostat, schedule-based model, and a rule-based occupancy-driven model. Unlike these three rule-based algorithms, the proposed optimization approach is a white-box model that considers the thermodynamic relationships in the cooling system to find the optimal cooling setpoints. For comparison, different case studies in five cities around the world were investigated. Our findings illustrate that the proposed optimization algorithm is able to noticeably reduce the cooling energy consumption of the buildings. Significantly, in cities that were located in severe hot regions, such as Doha and Phoenix, cooling energy consumption can be reduced by 14.71% and 15.19%, respectively.