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(gb, *a):
    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 -common.expectation(G, 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
Exemple #4
0
def qaoa(p, g_list, b_list):
    global G, C, M, k
    state = np.zeros(2**len(G.nodes))
    state = common.dicke(state, G, k)
    for i in range(p):
        state = common.phase_separator(state, C, g_list[i])
        state = common.ring_mixer(state, M, b_list[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.ring_mixer(state, M, beta0)
    for i in range(p):
        state = common.phase_separator(state, C, gamma)
        state = common.ring_mixer(state, M, beta1)
    return state
Exemple #6
0
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 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)
Exemple #9
0
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)