The goal of this paper is to demonstrate the implementation of technological solutions that will enable the optimization of 5G network resources and services in an automated and self-configured manner. At first, the practical implementation of intelligence loops in the 5G network architecture is presented, according to the O-RAN specifications. Then, the development of an open source, general-purpose simulator, compliant with 3GPP specifications for generating physical-layer measurement reports from the radio access network is presented, while its functional logic and configuration capabilities are fully highlighted. Moreover, this paper illustrates how effectively trained machine learning (ML) models can be incorporated into the architecture for network configuration and optimization. In this context, an indicative use case is presented and evaluated, focusing on closed-loop power adjustment of the transmitters in a 5G cellular orientation, via the appropriate deployment of a deep reinforcement learning agent. The simulation results outline the interaction loop between the developed 5G simulator and the deployed ML model, targeting at increasing the network-wide throughput of user equipment.