original_docstring: r"""
          Calculate lower bound on the quantum value of an extended nonlocal game.
  
          Test
  
          :return: The quantum value of the extended nonlocal game.
          
docstring: r"""
  Calculate lower bound on the quantum value of an extended nonlocal game.
  
  Test
docstring_tokens: r " " " Calculate lower bound on the quantum value of an extended nonlocal game . Test
code: def quantum_value_lower_bound(self, iters: int = 5, tol: float = 10e-6) -> float:
          r"""
          Calculate lower bound on the quantum value of an extended nonlocal game.
  
          Test
  
          :return: The quantum value of the extended nonlocal game.
          """
          # Get number of inputs and outputs for Bob's measurements.
          _, _, _, num_outputs_bob, _, num_inputs_bob = self.pred_mat.shape
  
          best_lower_bound = float("-inf")
          for _ in range(iters):
              # Generate a set of random POVMs for Bob. These measurements serve as a
              # rough starting point for the alternating projection algorithm.
              bob_povms = defaultdict(int)
              for y_ques in range(num_inputs_bob):
                  random_mat = random_unitary(num_outputs_bob)
                  for b_ans in range(num_outputs_bob):
                      random_mat_trans = random_mat[:, b_ans].conj().T.reshape(-1, 1)
                      bob_povms[y_ques, b_ans] = random_mat[:, b_ans] * random_mat_trans
  
              # Run the alternating projection algorithm between the two SDPs.
              it_diff = 1
              prev_win = -1
              best = float("-inf")
              while it_diff > tol:
                  # Optimize over Alice's measurement operators while fixing Bob's.
                  # If this is the first iteration, then the previously randomly
                  # generated operators in the outer loop are Bob's. Otherwise, Bob's
                  # operators come from running the next SDP.
                  rho, lower_bound = self.__optimize_alice(bob_povms)
                  bob_povms, lower_bound = self.__optimize_bob(rho)
  
                  it_diff = lower_bound - prev_win
                  prev_win = lower_bound
  
                  # As the SDPs keep alternating, check if the winning probability
                  # becomes any higher. If so, replace with new best.
                  best = max(best, lower_bound)
  
              best_lower_bound = max(best, best_lower_bound)
  
          return best_lower_bound
code_tokens: def quantum_value_lower_bound ( self , iters : int = 5 , tol : float = 10e-6 ) -> float : _ , _ , _ , num_outputs_bob , _ , num_inputs_bob = self . pred_mat . shape best_lower_bound = float ( "-inf" ) for _ in range ( iters ) : bob_povms = defaultdict ( int ) for y_ques in range ( num_inputs_bob ) : random_mat = random_unitary ( num_outputs_bob ) for b_ans in range ( num_outputs_bob ) : random_mat_trans = random_mat [ : , b_ans ] . conj ( ) . T . reshape ( - 1 , 1 ) bob_povms [ y_ques , b_ans ] = random_mat [ : , b_ans ] * random_mat_trans it_diff = 1 prev_win = - 1 best = float ( "-inf" ) while it_diff > tol : rho , lower_bound = self . __optimize_alice ( bob_povms ) bob_povms , lower_bound = self . __optimize_bob ( rho ) it_diff = lower_bound - prev_win prev_win = lower_bound best = max ( best , lower_bound ) best_lower_bound = max ( best , best_lower_bound ) return best_lower_bound
short_docstring: r"""
  Calculate lower bound on the quantum value of an extended nonlocal game.
short_docstring_tokens: r " " " Calculate lower bound on the quantum value of an extended nonlocal game .
comment: r"""
          Calculate lower bound on the quantum value of an extended nonlocal game.
  
          Test
  
          :return: The quantum value of the extended nonlocal game.
          """$SEP$# Get number of inputs and outputs for Bob's measurements.$SEP$# Generate a set of random POVMs for Bob. These measurements serve as a$SEP$# rough starting point for the alternating projection algorithm.$SEP$# Run the alternating projection algorithm between the two SDPs.$SEP$# Optimize over Alice's measurement operators while fixing Bob's.$SEP$# If this is the first iteration, then the previously randomly$SEP$# generated operators in the outer loop are Bob's. Otherwise, Bob's$SEP$# operators come from running the next SDP.$SEP$# As the SDPs keep alternating, check if the winning probability$SEP$# becomes any higher. If so, replace with new best.