Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
sprivite committed Jun 26, 2024
1 parent 27b1b7f commit 2065d22
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pybalance/lp/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _get_limits(self, f, match_size=None):

return min_feature, max_feature, max_delta

def match(self, threshold = None, hint: Optional[List[int]] = None) -> MatchingData:
def match(self, threshold=None, hint: Optional[List[int]] = None) -> MatchingData:
"""
Match populations passed during __init__(). Returns MatchingData
instance containing the matched pool and target populations.
Expand Down Expand Up @@ -362,8 +362,10 @@ def match(self, threshold = None, hint: Optional[List[int]] = None) -> MatchingD
# --- Taxicab distance ---------#
model.AddAbsEquality(abs_deltas[j], deltas[j])
if threshold is not None:
model.Add(abs_deltas[j] <= target_size * pool_size * int(self.scalefac * threshold))

model.Add(
abs_deltas[j]
<= target_size * pool_size * int(self.scalefac * threshold)
)

# --- Cardinality ---------#
model.Add(sum(x) == pool_size)
Expand Down Expand Up @@ -688,7 +690,9 @@ def match(self, threshold=0.1, hint: Optional[List[int]] = None) -> MatchingData
== deltas[j]
)
model.AddAbsEquality(abs_deltas[j], deltas[j])
model.Add(abs_deltas[j] <= self.n_target * n * int(self.scalefac * threshold))
model.Add(
abs_deltas[j] <= self.n_target * n * int(self.scalefac * threshold)
)

# --- Cardinality ---------#
model.Add(sum(x) == n)
Expand Down

0 comments on commit 2065d22

Please sign in to comment.