Skip to content

massive complexity improvement for fictitious play #202

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

Open
louisabraham opened this issue Feb 28, 2023 · 2 comments
Open

massive complexity improvement for fictitious play #202

louisabraham opened this issue Feb 28, 2023 · 2 comments

Comments

@louisabraham
Copy link

Currently, fictitious play stores count vectors and recomputes each time the payoff of each move by matrix multiplication before selecting the best move.

  • move = payoff.argmax() costs $\mathcal{O}(n)$
  • count[move] += 1 costs $\mathcal{O}(1)$
  • payoff = matrix @ count costs $\mathcal{O}(n * m)$

Instead, one could just update the payoff vector with payoff += matrix[:, move] in $\mathcal{O}(n)$.

Even better, the matrix can be stored transposed to be able to write matrix[move] which is more cache efficient.

@drvinceknight
Copy link
Owner

This sounds like a great improvement. Would you like to work on a PR for this?

@louisabraham
Copy link
Author

sure, it's like 10 sloc
will do after lunch

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 a pull request may close this issue.

2 participants