My iMac (27-inch, Mid 2011) had the same rebooting problem. It would reboot several times after Sleeping or if powered on. However, after a few self initiated reboots the iMac would be stable as long as I kept it on. I tried installing a different brand (WD) new SSD and worked upwards from Yosemite to High Sierra. I also swapped various certified sodimm memories and I even replaced the logic board. All with no positive effect - the rebooting fault persisted. Further, video testing and memory testing apps always proved the hardware was good. Finally, I put my original logic board back in and this time I physically removed the WiFi card and InfraRed Card. Previously, I has disabled the WiFi via the Operating System without result. With the WiFi and infrared cards removed, my system is now stable. I suspect the fault is with the WiFi card as I recall having a similar problem with the wifi card in my old 17” 2006 model macbook pro. I had to remove its wifi card to solve it. Currently using the ethernet LAN cable.