Additionally, due to the quirks of memory, adding some pain to a pleasurable experience at the right time will paradoxically cause people to remember it as being more pleasurable. This is completely at odds with a simple moral calculus.
It would be interesting to set a science fiction story in a world where an accurate moral calculus had been developed.