I can't actually find out how power on trains works, so I'm going to assume it's coming from either the rail system electrification, generators, batteries or some combination of them.
In any case the power from whatever source(s) is going to need to be converted and adjusted to get the 230V AC that things expect from a power socket. Unfortunately this is a non-trivial thing to do in a train where (I assume) the incoming power is probably not that stable.
I'm guessing that what's happening is that the power available from the socket may be dipping below the minimum power required by your power brick. Or, because you think it's cyclical, perhaps the AC cycles are not quite synced and it drifts over time eventually causing your power brick to stop recognizing it briefly. It's also possible that something is periodically drawing power from the system forcing it to dip under a usable power level.
Sadly this means that there's unlikely to be a some special socket where you can avoid this.
It is possible that using an expensive surge protection / power filtering extension cable might smooth out things enough to keep it running. But without debugging exactly what's happening with the socket there's no way to tell.
If your problem is just the screen dimming then I suggest you go with the option of changing the settings. It depends on your device and OS but you may have the option to delay the dimming for a few minutes (which wouldn't really be too much of an issue at other times). Or many PCs have options to save multiple graphics settings and switch between them easily (often with a hot key).
Failing that there are third part tools that can do it, if you travel at regular times you could even fully automate it based on the time of day. I'm getting a bit off topic for Travel here but, if you're technical or happy with a bit of a learning curve, I'd check out AutoHotKey.