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

Fixing multiplication operator warning for extended nonlocal games. #824

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions toqito/nonlocal_games/extended_nonlocal_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def unentangled_value(self) -> float:

rho = cvxpy.Variable((dim_x, dim_y), hermitian=True)

objective = cvxpy.Maximize(cvxpy.real(cvxpy.trace(p_win.conj().T * rho)))
objective = cvxpy.Maximize(cvxpy.real(cvxpy.trace(p_win.conj().T @ rho)))

constraints = [cvxpy.trace(rho) == 1, rho >> 0]
problem = cvxpy.Problem(objective, constraints)
Expand Down Expand Up @@ -194,7 +194,7 @@ def nonsignaling_value(self) -> float:
for x_in in range(alice_in):
for y_in in range(bob_in):
p_win += self.prob_mat[x_in, y_in] * cvxpy.trace(
self.pred_mat[:, :, a_out, b_out, x_in, y_in].conj().T * k_var[a_out, b_out, x_in, y_in]
self.pred_mat[:, :, a_out, b_out, x_in, y_in].conj().T @ k_var[a_out, b_out, x_in, y_in]
)

objective = cvxpy.Maximize(cvxpy.real(p_win))
Expand Down Expand Up @@ -328,7 +328,7 @@ def __optimize_alice(self, bob_povms) -> tuple[dict, float]:
)
.conj()
.T
* rho[x_ques, a_ans]
@ rho[x_ques, a_ans]
)
if isinstance(
bob_povms[y_ques, b_ans],
Expand All @@ -343,7 +343,7 @@ def __optimize_alice(self, bob_povms) -> tuple[dict, float]:
)
.conj()
.T
* rho[x_ques, a_ans]
@ rho[x_ques, a_ans]
)
objective = cvxpy.Maximize(cvxpy.real(win))
constraints = []
Expand Down Expand Up @@ -396,7 +396,7 @@ def __optimize_bob(self, rho) -> tuple[dict, float]:
bob_povms[y_ques, b_ans],
)
)
* rho[x_ques, a_ans].value
@ rho[x_ques, a_ans].value
)
objective = cvxpy.Maximize(cvxpy.real(win))

Expand Down Expand Up @@ -455,7 +455,7 @@ def commuting_measurement_value_upper_bound(self, k: int | str = 1) -> float:
for y_in in range(bob_in):
p_win += self.prob_mat[x_in, y_in] * cvxpy.trace(
self.pred_mat[:, :, a_out, b_out, x_in, y_in].conj().T
* mat[x_in, y_in][
@ mat[x_in, y_in][
a_out * referee_dim : (a_out + 1) * referee_dim,
b_out * referee_dim : (b_out + 1) * referee_dim,
]
Expand Down
8 changes: 3 additions & 5 deletions toqito/nonlocal_games/nonlocal_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ def __optimize_alice(self, dim, bob_povms) -> tuple[dict, float]:
# .. math::
# \sum_{(x,y) \in \Sigma} \pi(x, y) V(a,b|x,y) \ip{B_b^y}{A_a^x}
win = 0
is_real = True
for x_ques in range(num_inputs_alice):
for y_ques in range(num_inputs_bob):
for a_ans in range(num_outputs_alice):
Expand All @@ -372,17 +371,16 @@ def __optimize_alice(self, dim, bob_povms) -> tuple[dict, float]:
win += (
self.prob_mat[x_ques, y_ques]
* self.pred_mat[a_ans, b_ans, x_ques, y_ques]
* cvxpy.trace(bob_povms[y_ques, b_ans].conj().T * alice_povms[x_ques, a_ans])
* cvxpy.trace(bob_povms[y_ques, b_ans].conj().T @ alice_povms[x_ques, a_ans])
)
if isinstance(
bob_povms[y_ques, b_ans],
cvxpy.expressions.variable.Variable,
):
is_real = False
win += (
self.prob_mat[x_ques, y_ques]
* self.pred_mat[a_ans, b_ans, x_ques, y_ques]
* cvxpy.trace(bob_povms[y_ques, b_ans].value.conj().T * alice_povms[x_ques, a_ans])
* cvxpy.trace(bob_povms[y_ques, b_ans].value.conj().T @ alice_povms[x_ques, a_ans])
)

objective = cvxpy.Maximize(cvxpy.real(win))
Expand Down Expand Up @@ -430,7 +428,7 @@ def __optimize_bob(self, dim, alice_povms) -> tuple[dict, float]:
win += (
self.prob_mat[x_ques, y_ques]
* self.pred_mat[a_ans, b_ans, x_ques, y_ques]
* cvxpy.trace(bob_povms[y_ques, b_ans].H * alice_povms[x_ques, a_ans].value)
* cvxpy.trace(bob_povms[y_ques, b_ans].H @ alice_povms[x_ques, a_ans].value)
)

objective = cvxpy.Maximize(cvxpy.real(win))
Expand Down