/// <summary> /// Process all agents in a leaf node. /// </summary> /// <param name="leaf">Leaf node to processes.</param> private void ProcessLeafAll(LeafNode leaf) { // For every agent on the node... while (leaf.Out.Count > 0) { // Get next agent Agent a = leaf.Dequeue(); // Perform transaction between station and agent InteractTerm(leaf.Terminal, a); // Get node that agent will travel to next GraphNode exit = leaf.GetExit(a); // Move agent to node if available, otherwise put back onto leaf if (exit != null) { exit.Enqueue(a); } else { leaf.Enqueue(a); } } }
/// <summary> /// Processes the first available agent in a leaf node. /// </summary> /// <param name="l">Index of the leaf node to process.</param> /// <param name="state">State of the parallel loop.</param> /// <param name="doneTick">Whether or not the process cycle has been completed.</param> /// <returns>The doneTick variable.</returns> private long ProcessLeafSingle(int l, ParallelLoopState state, long toProcess) { // Get leaf LeafNode leaf = Leaves[l]; // If there is an agent to process if (leaf.Out.Count > 0) { // Get agent from node Agent a = leaf.Dequeue(); // Perform transaction between station and agent InteractTerm(leaf.Terminal, a); // Get node that agent will travel to next GraphNode exit = leaf.GetExit(a); // Move agent to node if available, otherwise put back onto leaf if (exit != null) { exit.Enqueue(a); } else { leaf.Enqueue(a); } // If there are more agents, then the tick isn't done if (leaf.Out.Count > 0) { toProcess++; } } return(toProcess); }