Skip to content

Commit 866de51

Browse files
mnshkwCopilot
andauthored
RFC: avoid redundant np.eye and precompute identity matrix in howson_lcp.py M construction (#828)
* refactor: avoid redundant eye in howson_lcp M construction * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 8ba6e49 commit 866de51

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

quantecon/game_theory/howson_lcp.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ def polym_lcp_solver(
8686
LOW_AVOIDER = 2.0
8787
# makes all of the costs greater than 0
8888
positive_cost_maker = polymg.range_of_payoffs()[1] + LOW_AVOIDER
89+
90+
eye_N = np.eye(polymg.N)
91+
8992
# Construct the LCP like Howson:
9093
M = np.vstack([
9194
np.hstack([
@@ -96,13 +99,13 @@ def polym_lcp_solver(
9699
for p2 in range(polymg.N)
97100
] + [
98101
-np.outer(np.ones(
99-
polymg.nums_actions[player]), np.eye(polymg.N)[player])
102+
polymg.nums_actions[player]), eye_N[player])
100103
])
101104
for player in range(polymg.N)
102105
] + [
103106
np.hstack([
104107
np.hstack([
105-
np.outer(np.eye(polymg.N)[player], np.ones(
108+
np.outer(eye_N[player], np.ones(
106109
polymg.nums_actions[player]))
107110
for player in range(polymg.N)
108111
]

0 commit comments

Comments
 (0)