'How do I solve a generic multiple-constraint problem (in Java or Kotlin)?

I'm optimizing the placement of relative recordings of events on a timeline, but calculating their pairwise relative position is computationally expensive, and getting the "ideal" layout is difficult. But it feels like something where there would be libraries for this, and I'm not searching on the right algorithm name!

  1. For events A, B, C, D... (up to ~15)
  2. I'm reasonably sure that B happened 5.002 seconds after A.
  3. I'm reasonably sure that C happened 7.001 seconds after A.
  4. ...keep going for some amount of all possible edges, (n(n-1))/2
  5. I sure hope that C happens ~2 seconds after B!

But if I do the calc to get B-to-C, and it comes out to 2.1sec, I don't want everything to explode. I was hoping that it works out some sort of "best fit" that takes all of the relationships (and cousin relationships, and second-cousion relationships) into account.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source