Newer
Older
from evrouting.charge.T import Label, SoCFunction
from evrouting.charge.factories import SoCFunctionFactory
"""
Implementation of a variant of priority queue to store the
***unsettled*** labels of a vertex and efficiently extract
the minimum label in the algorithm.
The priority of a label is the minimum feasible time of it's
according SoC Function. Tie breaker is the SoC at this time.
It maintains the invariant:
The queue is empty or the SoC Function of the minimum label
is not dominated by any SoC Function of a ***settled*** label.
"""
"""
:param f_soc: SoC Function Factory to create SoC Functions of
inserted labels for testing the invariant.
:param l_set: Set of settled labels.
"""
if self.peak_min() == label:
self.dominance_check()
def delete_min(self) -> Any:
min_label = super().delete_min()
self.dominance_check()
return min_label
def dominance_check(self):
"""
Compare the SoC Function of the minimum label with all
SoC Functions of the already settled labels. If any settled label
dominates the minimum label, the minimum label is removed, since
it cannot lead to a better solution.
"""
try:
label: Label = self.peak_min()
except KeyError:
return
soc: SoCFunction = self.f_soc_factory(label)
# Remove item if it gets dominated by any label in l_set
if any(self.f_soc_factory(label).dominates(soc) for label in self.l_set):