Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first attempt on Hash-based box search #53

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

paulzcooper
Copy link
Collaborator

@paulzcooper paulzcooper commented Jul 11, 2024

What does this PR do?

Add hash-based box search and tests.

Issue reference

Explanation

This PR brings first attempt to implement hash-based box search for neighbors search optimization.

How to get?

git clone --recursive -b feature/blabla [email protected]:aartiukh/sph.git

@paulzcooper paulzcooper self-assigned this Jul 11, 2024
Comment on lines +62 to +64
# discretized_coords = []
# for coord in point:
# discretized_coords.append(int((coord + sys.float_info.epsilon) // self.search_radius))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop unused code

Initialize the box-based neighbors search algorithm.
:param search_radius: minimal distance for particles to become neighbors
:param epsilon: precision for distance calculation, set to 10e-8 by default
:param domain_size: upper bound for the working domain
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all arguments have been documented. please add all args

self.epsilon = epsilon
self.domain_size = domain_size
self._verbose = verbose
self.box_size = cell_size if cell_size is not None else self.search_radius
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we have cell_size input param? I believe it should always be calculated

Comment on lines +27 to +33
self._boxes_in_row = round(self.domain_size / self.search_radius)
self._total_boxes = self._boxes_in_row ** 2
self.hashed_box_id2points = {}
self.box_id2hash = {}
self.hash2box_id = {}
self._int_neighbor_boxes_ids = None
self._box_neighbors = self._find_neighbor_boxes()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments to these vars, the names are not self-explanatory.

Comment on lines +57 to +60
col = int((point[0] + sys.float_info.epsilon) // self.search_radius)
row = int((point[1] + sys.float_info.epsilon) // self.search_radius)
discretized_point_coords = [col, row]
box_id = int(row * self._boxes_in_row + col)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there code instead of docs?

LOG.debug(message)

@staticmethod
def _get_hash(col: int, row: int) -> int:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments to all methods, including private

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants