This paper highlights the importance of accurate demand forecasting for effective inventory management in a dynamic and competitive environment characterized by uncertainty, financial constraints, and logistical limitations. While existing evaluation metrics, such as MAE and RMSE, offer complementary perspectives, they suffer from the potential for biased evaluations when applied individually. To address this, we propose the Hierarchical Evaluation Function (HEF), a composite function that integrates R2, MAE, and RMSE within a hierarchical and adaptive framework. HEF incorporates dynamic weights, a tolerance threshold derived from the statistical properties of time series, and a progressive penalty mechanism to ensure robustness against extreme errors and mispredictions. HEF optimizes multiple forecasting models using Grid Search, PSO, and Optuna, and is tested on the Walmart, M3, M4, and M5 benchmark datasets. Experimental results validated through statistical tests demonstrate that HEF consistently outperforms MAE as an evaluation function in global metrics such as R2, GRA, RMSE, and RMSSE, offering greater explanatory power, adaptability, and stability. While MAE maintains its advantages in simplicity and efficiency, HEF proves more effective in long-term planning and complex environments. Overall, HEF offers a robust and adaptive alternative for model selection and hyperparameter optimization in highly volatile demand forecasting environments.