First Implementation Pseudo-code:
1. Read the command line parameters, which include the model file name, the
configuration file name, the print interval, the end time, and the random
seed.
2. Read the configuration file to determine the number of threads and
which reactions are assigned to each thread.
3. Read the model file to
determine the number of species, their initial populations, the number of
reactions, their chemical equations, and their rate constants.
4. Start the threads.
EACH THREAD -
1. Build a dependency graph to determine how my thread’s
reactions effect the propensity values of reactions assigned to other
processors.
2. While not all threads are done
A. For each reaction in reactions assigned to thread
i. Calculate the reaction propensity
ii. Generate an exponential random number
iii. Generate a putative time for the reaction
B. Determine which reaction has the smallest putative time.
C. Set currentTime += smallestPutativeTime
D. Update the species populations to reflect the execution of the reaction
with the smallest putative time.
E. Log which reaction was executed and the time it was executed.
F. Look at the dependency graph to determine if the reaction that was just executed has
affected any other thread’s propensity value. If so:
i. Add a message to each affected thread’s message queue indicating the reaction that was executed and
the time at which the reaction was executed.
ii. Store a record of the message sent.
G. Get the message with the earliest time from my message
queue:
i. If no messages exist continue.
ii. If myCurrentTime < messageCurrentTime continue.
iii. If myCurrentTime > messageCurrentTime then
a. Use the reaction log to rollback (unexecute) reactions until
myCurrentTime < messageCurrentTime.
b. As we rollback, use the log of
messages sent to send anti-messages to other thread’s message queues.
If the corresponding message still exists in the message queue, delete both the
anti-message and the message.
c. If the message is not an anti-message,
execute the reaction specified by the message and update the current time.
H. If (currentTime > endTime) set my thread is done.
3. Merge the histories of the various threads to form the output file.
BACK HOME