epidemioptim/utils.py
def calculate_A_and_c(step, k, contact_modifiers, perturbation_matrices, transition_matrices, N=16):
    """
    When called, change the value of each contact matrices.
    Called when there is a change in NPI

    k: kval for the given time, compliance index
    
    Return
    ------
    A: per capita activity counts of individuals in age group n
    c: mixing matrix between individuals of two groups, modified given k
    con:
    """
    sf = create_list(1, N, N)
    wf = create_list(1, N, N)
    of = create_list(1, N, N)
    phase = contact_modifiers[0]
    if (phase[step][0] == 1):
        sf = perturbation_matrices[0]
    elif (phase[step][0] == 2):
        sf = perturbation_matrices[1]
    elif (phase[step][0] == 3):
        sf = perturbation_matrices[2]
    elif (phase[step][0] == 4):
        sf = perturbation_matrices[3]
    elif (phase[step][0] == 5):
        sf = perturbation_matrices[4]
    elif (phase[step][0] == 6):
        sf = perturbation_matrices[5]

    if (phase[step][2] == 1):
        wf = perturbation_matrices[6]
    elif (phase[step][2] == 2):
        wf = perturbation_matrices[7]
    elif (phase[step][2] == 3):
        wf = perturbation_matrices[8]

    if (phase[step][1] == 1):
        of = perturbation_matrices[9]
    elif (phase[step][1] == 2):
        of = perturbation_matrices[10]
    elif (phase[step][1] == 3):
        of = perturbation_matrices[11]

    USc = np.array(transition_matrices[0]) + np.multiply(np.array(wf), np.array(transition_matrices[1])) + np.multiply(np.array(of), np.array(transition_matrices[2])) + np.multiply(np.array(sf), np.array(transition_matrices[3]))
    B = USc.sum(axis=0)
    _con = np.dot(USc, k)
    _A = _con.sum(axis=0)
    _c = np.divide(_con, np.tile(_A, (16,1)))
    _A = np.tile(_A, (4,1))
    A, c = _A.tolist(), _c.tolist()
    return [A, c]

    When called, change the value of each contact matrices.
    Called when there is a change in NPI

    k: kval for the given time, compliance index
    
    Return
    ------
    A: per capita activity counts of individuals in age group n
    c: mixing matrix between individuals of two groups, modified given k
    con:
    
When called, change the value of each contact matrices.
Called when there is a change in NPI

kval for the given time, compliance index

Return

per capita activity counts of individuals in age group n
c: mixing matrix between individuals of two groups, modified given k
con.
When called change the value of each contact matrices . Called when there is a change in NPI kval for the given time compliance index Return per capita activity counts of individuals in age group n c : mixing matrix between individuals of two groups modified given k con .
def calculate_A_and_c(step, k, contact_modifiers, perturbation_matrices, transition_matrices, N=16):
    sf = create_list(1, N, N)
    wf = create_list(1, N, N)
    of = create_list(1, N, N)
    phase = contact_modifiers[0]
    if (phase[step][0] == 1):
        sf = perturbation_matrices[0]
    elif (phase[step][0] == 2):
        sf = perturbation_matrices[1]
    elif (phase[step][0] == 3):
        sf = perturbation_matrices[2]
    elif (phase[step][0] == 4):
        sf = perturbation_matrices[3]
    elif (phase[step][0] == 5):
        sf = perturbation_matrices[4]
    elif (phase[step][0] == 6):
        sf = perturbation_matrices[5]
    if (phase[step][2] == 1):
        wf = perturbation_matrices[6]
    elif (phase[step][2] == 2):
        wf = perturbation_matrices[7]
    elif (phase[step][2] == 3):
        wf = perturbation_matrices[8]
    if (phase[step][1] == 1):
        of = perturbation_matrices[9]
    elif (phase[step][1] == 2):
        of = perturbation_matrices[10]
    elif (phase[step][1] == 3):
        of = perturbation_matrices[11]
    USc = np.array(transition_matrices[0]) + np.multiply(np.array(wf), np.array(transition_matrices[1])) + np.multiply(np.array(of), np.array(transition_matrices[2])) + np.multiply(np.array(sf), np.array(transition_matrices[3]))
    B = USc.sum(axis=0)
    _con = np.dot(USc, k)
    _A = _con.sum(axis=0)
    _c = np.divide(_con, np.tile(_A, (16,1)))
    _A = np.tile(_A, (4,1))
    A, c = _A.tolist(), _c.tolist()
    return [A, c]
def calculate_A_and_c ( step , k , contact_modifiers , perturbation_matrices , transition_matrices , N = 16 ) : sf = create_list ( 1 , N , N ) wf = create_list ( 1 , N , N ) of = create_list ( 1 , N , N ) phase = contact_modifiers [ 0 ] if ( phase [ step ] [ 0 ] == 1 ) : sf = perturbation_matrices [ 0 ] elif ( phase [ step ] [ 0 ] == 2 ) : sf = perturbation_matrices [ 1 ] elif ( phase [ step ] [ 0 ] == 3 ) : sf = perturbation_matrices [ 2 ] elif ( phase [ step ] [ 0 ] == 4 ) : sf = perturbation_matrices [ 3 ] elif ( phase [ step ] [ 0 ] == 5 ) : sf = perturbation_matrices [ 4 ] elif ( phase [ step ] [ 0 ] == 6 ) : sf = perturbation_matrices [ 5 ] if ( phase [ step ] [ 2 ] == 1 ) : wf = perturbation_matrices [ 6 ] elif ( phase [ step ] [ 2 ] == 2 ) : wf = perturbation_matrices [ 7 ] elif ( phase [ step ] [ 2 ] == 3 ) : wf = perturbation_matrices [ 8 ] if ( phase [ step ] [ 1 ] == 1 ) : of = perturbation_matrices [ 9 ] elif ( phase [ step ] [ 1 ] == 2 ) : of = perturbation_matrices [ 10 ] elif ( phase [ step ] [ 1 ] == 3 ) : of = perturbation_matrices [ 11 ] USc = np . array ( transition_matrices [ 0 ] ) + np . multiply ( np . array ( wf ) , np . array ( transition_matrices [ 1 ] ) ) + np . multiply ( np . array ( of ) , np . array ( transition_matrices [ 2 ] ) ) + np . multiply ( np . array ( sf ) , np . array ( transition_matrices [ 3 ] ) ) B = USc . sum ( axis = 0 ) _con = np . dot ( USc , k ) _A = _con . sum ( axis = 0 ) _c = np . divide ( _con , np . tile ( _A , ( 16 , 1 ) ) ) _A = np . tile ( _A , ( 4 , 1 ) ) A , c = _A . tolist ( ) , _c . tolist ( ) return [ A , c ]
When called, change the value of each contact matrices.
When called change the value of each contact matrices .
"""
    When called, change the value of each contact matrices.
    Called when there is a change in NPI

    k: kval for the given time, compliance index
    
    Return
    ------
    A: per capita activity counts of individuals in age group n
    c: mixing matrix between individuals of two groups, modified given k
    con:
    """
step
k
contact_modifiers
perturbation_matrices
transition_matrices
N