def qaoa(gb, *a): G, C, M, k, p = a[0], a[1], a[2], a[3], a[4] state = random_k_state(len(G.nodes), k) state = common.mixer(state, M, random.uniform(0, pi)) for i in range(p): state = common.phase_separator(state, C, gb[i]) state = common.mixer(state, M, gb[p + i]) return -common.expectation(G, state)
def qaoa(G, C, M, k, p, m, gamma, beta0, beta1): state = np.zeros(2**len(G.nodes)) state = common.prep(state, G, k, m) state = common.mixer(state, M, beta0) for i in range(p): state = common.phase_separator(state, C, gamma) state = common.mixer(state, M, beta1) return state
def qaoa_restricted(a, opt): G, C, M, k, p, prev = a[0], a[1], a[2], a[3], a[4], a[5] state = np.zeros(2**len(G.nodes)) state = common.dicke(state, len(G.nodes), k) for i in range(p): if i != p - 1: state = common.phase_separator(state, C, prev[0][i]) state = common.mixer(state, M, prev[1][i]) else: state = common.phase_separator(state, C, opt[0]) state = common.mixer(state, M, opt[1]) return state
def qaoa(G, C, M, k, p, gamma, beta): state = np.zeros(2**len(G.nodes)) state = common.dicke(state, G, k) for i in range(p): state = common.phase_separator(state, C, gamma) state = common.mixer(state, M, beta) return state
def qaoa(gb, *a): G, C, M, k, p = a[0], a[1], a[2], a[3], a[4] state = common.dicke(len(G.nodes)) for i in range(p): state = common.phase_separator(state, C, gb[i]) state = common.mixer(state, M, gb[p+i]) return -common.expectation(G, state)
def qaoa(a, gb): G, C, M, k, p = a[0], a[1], a[2], a[3], a[4] state = common.dicke(len(G.nodes), k) for i in range(p): state = common.phase_separator(state, C, gb[i]) state = common.mixer(state, M, gb[p + i]) return state
def qaoa(p, g_list, b_list): global G, C, M, k state = np.zeros(2**len(G.nodes)) state = common.dicke(state, len(G.nodes), k) for i in range(p): state = common.phase_separator(state, C, g_list[i]) state = common.mixer(state, M, b_list[i]) return common.expectation(G, state)
def qaoa(gamma, beta, G, C, M, k, gi, flag): state = common.dicke(len(G.nodes), k) state = common.phase_separator(state, C, gamma) state = common.mixer(state, M, beta) if flag == 0: return common.prob(G, state, gi) else: return common.expectation(G, state)
def qaoa_initial(gb, G, C, M, k, p, m): size = int(comb(len(G.nodes), k)) state = np.zeros(size) state[m] = 1 for i in range(p): state = common.phase_separator(state, C, gb[i]) state = common.mixer(state, M, gb[p + i]) return -common.expectation(G, k, state)
def f(t, n, k): t = t * pi state = prep(n, k) #state = dicke(n, k) state = common.mixer(state, common.create_ring_M(n), t) state = [np.real(np.conj(s) * s) for s in state] probs = [] for i in range(0, 2**n): if common.num_ones(i) == k: probs.append(state[i]) return probs
def qaoa(gb, G, C, M, k, p): state = common.dicke(len(G.nodes), k) for i in range(p): state = common.phase_separator(state, C, gb[i]) state = common.mixer(state, M, gb[p + i]) return -common.expectation(G, k, state)
def qaoa(gamma, beta, G, C, M, k): state = common.dicke(len(G.nodes), k) state = common.phase_separator(state, C, gamma) state = common.mixer(state, M, beta) return common.expectation(G, k, state)