This study examined the optimal size of an autonomous hybrid renewable energy system (HRES) for a residential application in Buea, located in the southwest region of Cameroon. Two hybrid systems, PV-Battery and PV-Battery-Diesel, have been evaluated in order to determine which was the better option. The goal of this research was to propose a dependable, low-cost power source as an alternative to the unreliable and highly unstable electricity grid in Buea. The decision criterion for the proposed HRES was the cost of energy (COE), while the system’s dependability constraint was the loss of power supply probability (LPSP). The crayfish optimization algorithm (COA) was used to optimize the component sizes of the proposed HRES, and the results were contrasted to those obtained from the whale optimization algorithm (WOA), sine cosine algorithm (SCA), and grasshopper optimization algorithm (GOA). The MATLAB software was used to model the components, criteria, and constraints of this single-objective optimization problem. The results obtained after simulation for LPSP of less than 1% showed that the COA algorithm outperformed the other three techniques, regardless of the configuration. Indeed, the COE obtained using the COA algorithm was 0.06%, 0.12%, and 1% lower than the COE provided by the WOA, SCA, and GOA algorithms, respectively, for the PV-Battery configuration. Likewise, for the PV-Battery-Diesel configuration, the COE obtained using the COA algorithm was 0.065%, 0.13%, and 0.39% lower than the COE provided by the WOA, SCA, and GOA algorithms, respectively. A comparative analysis of the outcomes obtained for the two configurations indicated that the PV-Battery-Diesel configuration exhibited a COE that was 4.32% lower in comparison to the PV-Battery configuration. Finally, the impact of the LPSP reduction on the COE was assessed in the PV-Battery-Diesel configuration. The decrease in LPSP resulted in an increase in COE owing to the nominal capacity of the diesel generator.