I don't know the actual formula, but it depends on the science output of both of civs total science output of whichever civ generates less total science during the research term (presuming Brave New World). The higher, the better, so if you have an option but can only afford one, it's better for you to sign the RA with which ever AI civ has better science output.
As for not signing them to deny the opportunity for the opponent, they are generally more beneficial for people rather than the AI - not necessarily a better science boost but because people can put that science to better use, usually. Figuring out the circumstances where it would be better to deny the opponent seems difficult to know for certain, so unless you think you want to declare war before the RA completes, it's usually a good idea to sign it.
Multiplayer has its own complications, and since I don't have experience, I have no comment. If "partners" means coop (i.e. Teams 1 & 2 vs. Teams 3 & 4), then like multiplayer, I don't know. Presumably, it'd be best for teammates to sign as many as they can with each other if it's allowed (unless the gold could be better spent elsewhere, of course.)