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

Vectorize methods #1

Open
endolith opened this issue Sep 11, 2019 · 2 comments
Open

Vectorize methods #1

endolith opened this issue Sep 11, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@endolith
Copy link
Owner

I think all of these functions could accept 3D arrays of shape (n_voters, n_cands, n_elections) or (n_elections, n_voters, n_cands), whichever makes more sense, and return a list of winners for each election.

np.array((impartial_culture(5, 4), impartial_culture(5, 4)))
Out[16]:
array([[[1, 2, 0, 3],
		[2, 1, 3, 0],
		[3, 0, 1, 2],
		[3, 1, 2, 0],
		[2, 3, 0, 1]],

	   [[0, 2, 3, 1],
		[2, 3, 1, 0],
		[1, 3, 2, 0],
		[2, 1, 0, 3],
		[0, 2, 3, 1]]], dtype=uint8)

_.shape
Out[17]: (2, 5, 4)
@endolith endolith added the enhancement New feature or request label Sep 11, 2019
@endolith
Copy link
Owner Author

Huge elections would run out of memory, but still would be faster than processing them in a loop.

	a = np.empty((100000, 10000, 10), dtype=np.uint8)

		MemoryError

@endolith
Copy link
Owner Author

endolith commented Feb 9, 2021

Need to

  • generate the utilities in chunks,
  • feed those chunks to the method functions,
    • some of which can be vectorized and some of which can't,
  • re-use the same utilities for different methods, but
  • don't re-use for the same method,
  • parallelize everything.

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

No branches or pull requests

1 participant