Skip to content
Snippets Groups Projects
Commit 93324eb0 authored by markn92's avatar markn92
Browse files

remove mental overhead by removing special functions

parent 8d5ac7e5
No related branches found
No related tags found
No related merge requests found
......@@ -134,14 +134,6 @@ class ChargingFunction:
return cf_inverse
def __lt__(self, other) -> bool:
"""Comparison for dominance check."""
return self.c < other.c
def __gt__(self, other):
"""Comparison for dominance check."""
return self.c > other.c
class Label(NamedTuple):
"""
......@@ -238,7 +230,7 @@ class SoCFunction:
t_charge = None
if cs > self.cf_cs:
if cs.c > self.cf_cs.c:
# Faster charging station -> charge as soon as possible
t_charge = self.breakpoints[0].t - self.t_trip
elif self.breakpoints[-1].soc < capacity:
......@@ -249,20 +241,13 @@ class SoCFunction:
return t_charge
def __lt__(self, other: 'SoCFunction') -> bool:
"""Comparison for dominance check."""
for t_i, soc_i in self.breakpoints:
if other(t_i) < soc_i:
return False
for t_i, soc_i in other.breakpoints:
if soc_i < self(t_i):
return False
def dominates(self, other: 'SoCFunction') -> bool:
"""
Check if self dominates other function by evaluating all breakpoints.
return True
f dominates f' if f(t) >= f'(t) for all t
def __gt__(self, other: 'SoCFunction') -> bool:
"""Comparison for dominance check."""
"""
for t_i, soc_i in self.breakpoints:
if other(t_i) > soc_i:
return False
......
......@@ -30,10 +30,10 @@ class LabelPriorityQueue(PriorityQueue):
except KeyError:
return
soc = self.f_soc_factory(label)
soc: SoCFunction = self.f_soc_factory(label)
# Remove item if it gets dominanted by any label in l_set
if any(self.f_soc_factory(label) > soc for label in self.l_set):
# 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):
self.remove_item(label)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment