# Path: stochpy/implementations/StochPyTools.py
# class Species():
# class StochPySSA_Shared(): 
#     def __init__(self):
#     def Parse(self,model_file,model_dir,IsTauleaping=False,IsNRM=False,IsDelayed = False,IsSMM = False,IsQuiet=False):
#     def SpeciesSelection(self):
#     def RateSelection(self):
#     def SetEvents(self):
#     def Propensities(self,IsTauleaping=False):
#     def BuildPropensityCodes(self, propensities = None): # 21-11-2013 
#     def HandleEvents(self,IsTauleapingStep=False):    
#     def AssignmentRules(self):
#     def rateFunc(self,rate_eval_code,r_vec):
#     def Initial_Conditions(self,IsTauleaping = False):              
#     def GenerateOutput(self,IsTauleaping = False,completion_delayed = False):


import sys,copy,time,os,operator
from .StochPyTools import __species__,StochPySSA_Shared,np
            self.randoms_log = np.log(randoms)*-1
            self.randoms = np.random.random(1000)
            self.count = 0           
        elif self.count == 1000:
            randoms = np.random.random(1000) 
            self.randoms_log = np.log(randoms)*-1
            self.randoms = np.random.random(1000)    
            self.count = 0      
        
        self.sim_tau = self.randoms_log[self.count]/float(self.sim_a_0)       # reaction time generation
        self.sim_r2 = self.randoms[self.count]                                # Draw random number 2 [0-1]
        self.count +=1
        
        if (self.sim_t + self.sim_tau) < self.settings.endtime:
            self.sim_t += self.sim_tau                                        # Time update
            self.reaction_index = 0
            sum_of_as = self.sim_a_mu[self.reaction_index]
            criteria = self.sim_r2*self.sim_a_0
            while sum_of_as < criteria:                                       # Use r2 to determine which reaction will occur
                self.reaction_index += 1	                                  # Index
                sum_of_as += self.sim_a_mu[self.reaction_index]                 

            try:
                self.X_matrix += self.N_matrix_transpose[self.reaction_index]
                self.timestep += 1
            except MemoryError as ex:
                print(ex)
                sys.exit()               
        else:            
            self.sim_t = self.settings.endtime            

# Path: stochpy/implementations/StochPyTools.py
# class Species():
# class StochPySSA_Shared(): 
#     def __init__(self):
#     def Parse(self,model_file,model_dir,IsTauleaping=False,IsNRM=False,IsDelayed = False,IsSMM = False,IsQuiet=False):
#     def SpeciesSelection(self):
#     def RateSelection(self):
#     def SetEvents(self):
#     def Propensities(self,IsTauleaping=False):
#     def BuildPropensityCodes(self, propensities = None): # 21-11-2013 
#     def HandleEvents(self,IsTauleapingStep=False):    
#     def AssignmentRules(self):
#     def rateFunc(self,rate_eval_code,r_vec):
#     def Initial_Conditions(self,IsTauleaping = False):              
#     def GenerateOutput(self,IsTauleaping = False,completion_delayed = False):


# Path: stochpy/implementations/DirectMethod.py
import sys,copy,time,os,operator
from .StochPyTools import __species__,StochPySSA_Shared,np

            self.randoms_log = np.log(randoms)*-1
            self.randoms = np.random.random(1000)
            self.count = 0           
        elif self.count == 1000:
            randoms = np.random.random(1000) 
            self.randoms_log = np.log(randoms)*-1
            self.randoms = np.random.random(1000)    
            self.count = 0      
        
        self.sim_tau = self.randoms_log[self.count]/float(self.sim_a_0)       # reaction time generation
        self.sim_r2 = self.randoms[self.count]                                # Draw random number 2 [0-1]
        self.count +=1
        
        if (self.sim_t + self.sim_tau) < self.settings.endtime:
            self.sim_t += self.sim_tau                                        # Time update
            self.reaction_index = 0
            sum_of_as = self.sim_a_mu[self.reaction_index]
            criteria = self.sim_r2*self.sim_a_0
            while sum_of_as < criteria:                                       # Use r2 to determine which reaction will occur
                self.reaction_index += 1	                                  # Index
                sum_of_as += self.sim_a_mu[self.reaction_index]                 

            try:
                self.X_matrix += self.N_matrix_transpose[self.reaction_index]
                self.timestep += 1
            except MemoryError as ex:
                print(ex)
                sys.exit()               
        else:            
            self.sim_t = self.settings.endtime            

            self.reaction_index = np.nan