コード例 #1
0
ファイル: regression.py プロジェクト: keiohigh2nd/hcc_1937
def update_all_parameter(diff):
    #print 'each difference -  %s' % diff
    luc_node = int(30*diff)
    hcc_node = int(5)
    time = 10

    #parameter
    luc_gro = int(6*diff)
    hcc_gro = int(2)

    lucG = nx.barabasi_albert_graph(luc_node, luc_gro)
    hccG = nx.barabasi_albert_graph(hcc_node, hcc_gro)

    frequency = np.array([0.9, 0.1])
    G_combine =nx.Graph()
    G_combine = graph.merge_graph(G_combine, hccG, lucG, frequency)

    frequency_1 = np.array([0.5, 0.5])
    G_combine_1 =nx.Graph()
    G_combine_1 = graph.merge_graph(G_combine_1, hccG, lucG, frequency_1)


    #Time series cell volume
    LucN = []
    hccN = []

    #Number of initial cell 
    LucN0 = 100
    hccN0 = 100
    LucN_init = 100
    hccN_init = 100

    for t in range(time):
      LucN.append(calc.convert_volume(LucN0))
      lucG = graph.update_graph(lucG, luc_gro)
      LucN0 = LucN_init*calc.calc_entropy(lucG, t+1)

    for t in range(time):
      hccN.append(calc.convert_volume(hccN0))
      hccG = graph.update_graph(hccG, hcc_gro)
      hccN0 = hccN_init*calc.calc_entropy(hccG, t+1)

    #Mix Number of cell
    MixN0 = 100
    MixN_init = 100
    initial_populations = MixN0*frequency
    G_comb_gro = ((frequency*np.array([luc_gro, hcc_gro])).sum())/2
    MixN = []
    x = []
    for t in range(time):
      x.append(t)
      MixN.append(calc.convert_volume(MixN0))
      G_combine = graph.update_graph(G_combine, G_comb_gro)
      MixN0 = MixN_init*calc.calc_entropy(G_combine, t+1)
 
    sim_ratio =  np.array(LucN)/np.array(MixN)
    return sim_ratio


    """
コード例 #2
0
ファイル: regression.py プロジェクト: kekeke29341/hcc_1937
def update_all_parameter(diff):
    #print 'each difference -  %s' % diff
    luc_node = int(30 * diff)
    hcc_node = int(5)
    time = 10

    #parameter
    luc_gro = int(6 * diff)
    hcc_gro = int(2)

    lucG = nx.barabasi_albert_graph(luc_node, luc_gro)
    hccG = nx.barabasi_albert_graph(hcc_node, hcc_gro)

    frequency = np.array([0.9, 0.1])
    G_combine = nx.Graph()
    G_combine = graph.merge_graph(G_combine, hccG, lucG, frequency)

    frequency_1 = np.array([0.5, 0.5])
    G_combine_1 = nx.Graph()
    G_combine_1 = graph.merge_graph(G_combine_1, hccG, lucG, frequency_1)

    #Time series cell volume
    LucN = []
    hccN = []

    #Number of initial cell
    LucN0 = 100
    hccN0 = 100
    LucN_init = 100
    hccN_init = 100

    for t in range(time):
        LucN.append(calc.convert_volume(LucN0))
        lucG = graph.update_graph(lucG, luc_gro)
        LucN0 = LucN_init * calc.calc_entropy(lucG, t + 1)

    for t in range(time):
        hccN.append(calc.convert_volume(hccN0))
        hccG = graph.update_graph(hccG, hcc_gro)
        hccN0 = hccN_init * calc.calc_entropy(hccG, t + 1)

    #Mix Number of cell
    MixN0 = 100
    MixN_init = 100
    initial_populations = MixN0 * frequency
    G_comb_gro = ((frequency * np.array([luc_gro, hcc_gro])).sum()) / 2
    MixN = []
    x = []
    for t in range(time):
        x.append(t)
        MixN.append(calc.convert_volume(MixN0))
        G_combine = graph.update_graph(G_combine, G_comb_gro)
        MixN0 = MixN_init * calc.calc_entropy(G_combine, t + 1)

    sim_ratio = np.array(LucN) / np.array(MixN)
    return sim_ratio
    """
コード例 #3
0
def exp_test():
    #parameter
    luc_node = 100
    time = 10
    luc_gro = 10

    #Generate Graph
    lucG = nx.barabasi_albert_graph(luc_node, luc_gro)

    #Time series cell volume
    LucN = []

    #Number of initial cell
    LucN0 = 100
    LucN_init = 100

    mm2 = 43

    for t in range(time):
        LucN.append(calc.convert_volume(LucN0))
        lucG = graph.update_graph(lucG, luc_gro)
        LucN0 = LucN_init * math.exp(1 / 10 * (t + 1))

    r_LucN, r_hccN, r_MixN = graph.num_read_cells(mm2)

    time_point = len(r_LucN[0])  #8
    sim_tmp = len(LucN) / time_point  #1.25

    LucN_p = []
    for t in range(time_point):
        LucN_p.append(LucN[int(round(t * sim_tmp))])

    corr_Luc = []
    for i in range(len(r_LucN)):  #times of experiments
        tmp_Luc = np.corrcoef(r_LucN[i], LucN_p)
        corr_Luc.append(tmp_Luc[0, 1])

    print np.average(np.array(corr_Luc))
    return 0
コード例 #4
0
def exp_test():
    #parameter
    luc_node = 100
    time = 10
    luc_gro = 10

    #Generate Graph
    lucG = nx.barabasi_albert_graph(luc_node, luc_gro)

    #Time series cell volume
    LucN = []

    #Number of initial cell 
    LucN0 = 100
    LucN_init = 100

    mm2 = 43

    for t in range(time):
      LucN.append(calc.convert_volume(LucN0))
      lucG = graph.update_graph(lucG, luc_gro)
      LucN0 = LucN_init*math.exp(1/10*(t+1))

    r_LucN, r_hccN, r_MixN = graph.num_read_cells(mm2)

    time_point = len(r_LucN[0])#8
    sim_tmp = len(LucN)/time_point #1.25

    LucN_p = []
    for t in range(time_point):
        LucN_p.append(LucN[int(round(t*sim_tmp))])

    corr_Luc = []
    for i in range(len(r_LucN)): #times of experiments
      tmp_Luc = np.corrcoef(r_LucN[i], LucN_p)
      corr_Luc.append(tmp_Luc[0,1])

    print np.average(np.array(corr_Luc))
    return 0
コード例 #5
0
    G_combine_1 = graph.merge_graph(G_combine_1, hccG, lucG, frequency_1)

    #Time series cell volume
    LucN = []
    hccN = []

    #Number of initial cell 
    LucN0 = 10**4
    hccN0 = 10**4
    LucN_init = 10**4
    hccN_init = 10**4


    for t in range(time):
      LucN.append(calc.convert_volume(LucN0))
      lucG = graph.update_graph(lucG, luc_gro)
      LucN0 = LucN_init*calc.calc_entropy(lucG, t+1)
      
    for t in range(time):
      hccN.append(calc.convert_volume(hccN0))
      hccG = graph.update_graph(hccG, hcc_gro)
      hccN0 = hccN_init*calc.calc_entropy(hccG, t+1)

    #Mix Number of cell
    MixN0 = 10**4
    MixN_init = 10**4
    initial_populations = MixN0*frequency
    G_comb_gro = ((frequency*np.array([luc_gro, hcc_gro])).sum())/2
    MixN = []
    x = []
    for t in range(time):
コード例 #6
0
ファイル: serverMBQC.py プロジェクト: rheaparekh/protocols
    for E in Edges:
        qubits[E[0] - 1].cphase(qubits[E[1] - 1])

    #Comment to not draw the graph
    if (args.draw):
        G1 = draw_graph_pos(Edges, ninput, nQubits)

    print("Server makes adaptive measurements and corrections")
    result = measure_mbqc(seq_out, nQubits, qubits)
    qout = result[0]
    #print("idx_output ",result[1])

    #comment to not draw/update the graph
    if (args.draw):
        idx_output = result[1]
        update_graph(G1[0], G1[1], G1[2], idx_output)

    noutput = len(qout)

    print("Server Sending: Number of output qubits = {}".format(noutput))
    Bob.sendClassical("Alice", noutput)

    for q in qout:
        Bob.sendQubit(q, "Alice")
        recvd_data = Bob.recvClassical()
        data = pickle.loads(recvd_data)
        if data != "OK":
            print("Server received : {} ".format(data))

    if (args.draw):
        plt.show()
コード例 #7
0
        # Each measurement has has a qubit index (between 0 and nQubits)
        qubit_n = int.from_bytes(Server.recvClassical(), "little")
        # Each measurement has an angle to measure in degrees
        angle = int.from_bytes(Server.recvClassical(), "little")
        qout_idx.remove(qubit_n - 1)
        #print("{}".format(qout_idx))
        print("Server Measuring qubit {} using angle {}".format(
            qubit_n, angle))
        #qubits[qubit_n-1].rot_Z(angle)
        qubits[qubit_n - 1].rot_Z(-int(angle) % 256)
        qubits[qubit_n - 1].rot_Y(
            256 - 64)  # to make the measurement along in the |+> |-> basis
        m = qubits[qubit_n - 1].measure()

        time.sleep(0.1)
        print("Server Sending (classical): result of measurement {}".format(m))
        Server.sendClassical(client_name, m)

    for i in range(nQubits - nMeasurement):
        print("Server Sending (quantum): qubit {}".format(qout_idx[i] + 1))
        Server.sendQubit(qubits[qout_idx[i]], client_name)
        recv_data = Server.recvClassical()  #recv ok from the client
        data = pickle.loads(recv_data)
        print("message = {} ".format(data))

    if (args.draw):
        update_graph(G1[0], G1[1], G1[2], qout_idx)
        plt.show()

    sys.exit(0)