def positions(X, V_s, stoc_vector,domain_enum):
''' Get the positions of the previous positions. '''
# X is the state space vector. N \times N_s
# stoc_vector is a vector $N_s$ with 1 when a variable is stochastic and zero otherwise.
# Initialising the positions
##pdb.set_trace()
N = X.shape[1] # Number of states.
N_s = np.sum(stoc_vector)
N_r_s = len(V_s) # N_r_s is the number of propensities which are purely stochastic ( N_r_s = len(V_s))
position = np.zeros((N,N_r_s),dtype=np.int64)
valid = np.zeros((N,N_r_s),dtype=np.bool)
#shift_M = np.zeros((N_r_s,N,N_s),dtype=np.int)
# Loops through the stochiometry and find the coresponding indexes.
##pdb.set_trace()
for i in range(N_r_s):
pre_states = X - np.array(V_s[i])[:,np.newaxis]
interior = domain_enum.contains(pre_states)
#print("shape In" + str(interior.shape))
#print("shape valid" + str(valid[:,i].shape))
valid[:,i] = interior
#exterior = np.invert(interior)
if np.sum(valid[:,i]) >0:
position[interior,i] = domain_enum.indices(pre_states[:,interior])
return valid, position
评论列表
文章目录