Enhancement in both energy efficiency and spectral efficiency in cellular networks is made possible by means of an advanced technique called device-to device (D2D) communication. The enhancement of these efficiencies is done by utilizing the cellular user (CU) resources once again to make communication with nearby cellular devices in an effective manner by spectral means. As the D2D communication technology is capable of providing a direct communication link with nearby devices effectively with enhanced spectral efficacy, this approach is considered as an ideal solution for the futuristic cellular communication network. A flexible and reliable relay-assisted communication by means of D2D technology is required that acts as an intermediate relay when the attenuation between the channels across the D2D devices becomes high. The throughput of the system is increased by utilizing D2D communication technology as it uses direct data transmission within cellular devices. When the cellular user is far apart from one another, the data loss in the D2D communication system is minimized with the utilization of the relay. When the channels are good, then the relay nodes (RNs) serve the cellular user. However, it is noted that the D2D systems are affected by issues such as higher consumption of energy and spectral sharing. Also, the sum rate gets degraded as a result of mutual interference between resource-sharing cellular devices in the relay-assisted D2D communication system. The transmission of the data in a traditional relay-assisted D2D communication system is carried out between the D2D receiver (DR) and D2D transmitter (DT) only with the utilization of its own energy by the RN. The issues in relay selection and resource allocation in the conventional joint resource allocation schemes are tackled by executing a scheme for performing the task of optimal relay selection and joint resource allocation. The enhancement of the overall sum rate in the D2D communication is the main motive behind the implemented scheme. This goal is attained along with the minimization of the link rates in the cellular and D2D networks. The ideal selection of the relay and the execution of the joint resource allocation are done with the utilization of a new optimization scheme called the hybrid flow direction with the chameleon swarm algorithm (HFDCSA), in which the flow direction algorithm (FDA) is fused along with chameleon swarm algorithm. This optimal selection of the relays is assisted by considering constraints like the network’s sum rate and energy efficiency in the network to achieve high performance. The data obtained from distinct sources are given to the adaptive multi-layer perceptron (AMLP) in which optimal resource allocation and the relay selection are performed with the help of the suggested HFDCSA. The parameters in the MLP are tuned by the same HFDCSA. Finally, the performance validation is conducted in the stage to verify the working of the suggested approach.