I am not even entirely sure that the question makes sense except in certain simple cases, but let me explain what I am trying to do, but with the question first.
The question is essentially: Given n bodies with known position, mass, velocity vectors, how do I in a meaningful way calculate what they are each orbiting right now? It does not matter than the orbits will commonly change over time for chaotic systems. I just need the current best orbit definition.
To better explain my issue...
Assume two gravitating bodies isolated in space. They will each orbit their common bary center and you can define the position of that barycenter as well as the parameters for each bodys orbit around it.
Now consider a case with three equal massed bodies orbiting their common center of mass in an equilateral triangle. Again you can calculate their barycenter and orbital parameters (however unstable to any pertubation).
Now consider a case like Sun, Earth, Moon where the three bodies have a common center of mass, which they orbit, but where Earth and Moon more rapidly orbit their common barycenter. How do you calculate, given only position, mass and velocity vectors, that this system is best described as sun and the earthMoon barycenter orbiting their common barycenter while Earth and Moon orbit their barycenter?
I currently attempt to do this by looking at all pairs sunEarth, sunMoon, earthMoon and calculate their barycenter and orbital properties in isolation and then consider "the real" orbit around the real barycenter the one with the shortest period. That gives me the correct answer in the two body case and in the Sun, Earth moon case, where two bodies are very isolated, but it would fail with the tree equal sides bodies.
I also considered defining the gravitational potential equation for the entire system and looking at the gradient to see that in the Sun, Earth, Moon case, Earth and Moon are circling in a little local indentation while still being caught in the larger indentation caused by the sun, but I am not certain that will really help and it seems somewhat complicated to properly model when a body may be in such an indentation but with a velocity direction and magnitude which will let it escape regardless.
If the answer is that for the general case there is no answer, then I guess that is an answer as well and I can stop wasting energy on it. Any other thoughts about the validity of the question, when it certainly doesn't make sense and anything else will also be greatly appreciated.