Dynamically writing coupled memories using a reinforcement learning agent, meeting physical bounds