Skip to content

Commit

Permalink
apply black format
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedongPeng committed Dec 10, 2024
1 parent e0cc3ff commit 201aed4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pyomo/contrib/gdpopt/ldsda.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,10 @@ def neighbor_search(self, config):
self.best_direction = None # reset best direction
fmin = float('inf') # Initialize the best objective value
best_dist = 0 # Initialize the best distance
abs_tol = config.integer_tolerance # Use integer_tolerance for objective comparison

abs_tol = (
config.integer_tolerance
) # Use integer_tolerance for objective comparison

# Loop through all possible directions (neighbors)
for direction in self.directions:
# Generate a neighbor point by applying the direction to the current point
Expand All @@ -415,7 +417,9 @@ def neighbor_search(self, config):
# --- Tiebreaker Logic ---
if abs(fmin - primal_bound) < abs_tol:
# Calculate the Euclidean distance from the current point
dist = sum((x - y) ** 2 for x, y in zip(neighbor, self.current_point))
dist = sum(
(x - y) ** 2 for x, y in zip(neighbor, self.current_point)
)

# Update the best neighbor if this one is farther away
if dist > best_dist:
Expand All @@ -427,7 +431,9 @@ def neighbor_search(self, config):
fmin = primal_bound # Update the best objective value
best_neighbor = neighbor # Update the best neighbor
self.best_direction = direction # Update the best direction
best_dist = sum((x - y) ** 2 for x, y in zip(neighbor, self.current_point))
best_dist = sum(
(x - y) ** 2 for x, y in zip(neighbor, self.current_point)
)
# --- End of Tiebreaker Logic ---

# Move to the best neighbor if an improvement was found
Expand Down

0 comments on commit 201aed4

Please sign in to comment.