def ensemble_time_series(net, nodes_list, Nbr_States=2, MAX_TimeStep=20):

    '''
        Arguments:
        1. net
        2. Nbr_States
        3. MAX_TimeStep

        Return:
        1. timeSeriesData
        '''

    Nbr_Nodes = len(net.nodes())
    Nbr_All_Initial_States = np.power(Nbr_States, Nbr_Nodes)

    timeSeriesData = {}
    for n in net.nodes():
        timeSeriesData[n] = {}
        for initState in range(0, Nbr_All_Initial_States):
            timeSeriesData[n][initState] = []

    for initDecState in range(0, Nbr_All_Initial_States):
        currBiState = decimal_to_binary(nodes_list, initDecState, Nbr_States)
        for step in range(0, MAX_TimeStep):
            prevBiState = currBiState.copy()
            for n in nodes_list:
                timeSeriesData[n][initDecState].append(prevBiState[n])
            currBiState = ur.sigmoid_updating(net, prevBiState)

    return timeSeriesData
Esempio n. 2
0
def biological_sequence(net, nodes_list, bio_initStates, fileName, Nbr_States=2):
    bioSeq = []
    currBiStates = bio_initStates
    finished = False
    while(not finished):
        oneDiff = 0
        prevBiStates = currBiStates.copy()
        bioSeq.append(prevBiStates)
        currBiStates = ur.sigmoid_updating(net, prevBiStates)
        for u in nodes_list:
            if abs(prevBiStates[u] - currBiStates[u]) > 0:
                oneDiff = 1
                break
        finished = (oneDiff < 1)

    OUTPUT_FILE  = open(fileName, 'w')
    OUTPUT_FILE.write('time step')
    for u in nodes_list:
        OUTPUT_FILE.write('\t%s'%(u))
    OUTPUT_FILE.write('\n')

    for i in range(len(bioSeq)):
        OUTPUT_FILE.write('%d'%i)
        for u in nodes_list:
            OUTPUT_FILE.write('\t%d'%(bioSeq[i][u]))
        OUTPUT_FILE.write('\n')
def net_state_transition(net, nodes_list, Nbr_States=2):

    '''
    Arguments:
               1. net
               2. Nbr_States
    Return:
               1. decStateTransMap
    '''

    Nbr_Nodes = len(net.nodes())
    Nbr_All_Initial_States = np.power(Nbr_States, Nbr_Nodes)

    decStateTransMap = nx.DiGraph()
    for prevDecState in range(0, Nbr_All_Initial_States):
        prevBiState = decimal_to_binary(nodes_list, prevDecState, Nbr_States)
        currBiState = ur.sigmoid_updating(net, prevBiState)
        currDecState = binary_to_decimal(nodes_list, currBiState, Nbr_States)
        decStateTransMap.add_edge(prevDecState, currDecState)
    return decStateTransMap