Is there a not too complicated way how to implement a priority queue working with two criteria? The queue gets created with 2 Comparator
s and provides (besides add
) the operations poll1()
and poll2()
, where each removes and returns the smallest element according to the corresponding comparator.
Note that it has nothing in common with these two questions.
Motivation
My use case is Branch and Bound Optimization. Expanding the candidate with the best bound is provably optimal when you're given an unlimited time. Assuming an unlimited time is provably wrong.
Strictly following this strategy often ends up with having no solution at all when the deadline comes. A simple band-aid is to direct the search towards a solution first and then switch to the best bound strategy. This is rather unsatisfactory as the first solution found can be of an arbitrary low quality.
That's why I'd like to use the two criteria queue: In one step, expand the best bound candidate and in another, expand the "best looking" candidate according to some heuristics.
Another possible use would be for pareto-optimization.