2 % Fork Job splitting node
for parallel processing models
4 % Fork
is a specialized node that splits incoming jobs into multiple sibling
5 % tasks that can be processed in parallel by downstream
nodes. Each job
6 % arriving at a Fork node
is replicated into multiple parallel tasks that
7 % must later be
synchronized using a corresponding Join node.
9 % @brief Job splitting node that creates parallel sibling tasks from incoming jobs
11 % Key characteristics:
12 % - Splits each job into multiple parallel tasks
13 % - Works in conjunction with Join
nodes for synchronization
14 % - Supports different fork strategies and task distributions
15 % - Essential
for modeling parallel processing systems
16 % - No service delay - instantaneous job splitting
18 % Fork
nodes are commonly used
for:
19 % - Parallel processing models
20 % - Fork-join queueing networks
21 % - Multi-threaded system modeling
22 % - Task decomposition scenarios
23 % - Distributed computing models
27 % fork = Fork(model,
'TaskSplitter');
28 % % Jobs entering
this fork will be split into parallel tasks
29 % % Must be paired with a Join node
for proper synchronization
32 % Copyright (c) 2012-2026, Imperial College London
33 % All rights reserved.
41 % state-carrying slots used only on FJ tag-augmented model copies
42 % (ModelAdapter.fjtag), where
the Fork
is treated as a stateful
43 % node holding
the parent job for one vanishing state; they mirror
44 %
the StatefulNode API without changing
the class ancestry
51 function prior = getStatePrior(self)
52 % PRIOR = GETSTATEPRIOR()
53 prior = self.statePrior;
56 function self = setStatePrior(self, prior)
57 % SELF = SETSTATEPRIOR(PRIOR)
58 self.statePrior = prior(:);
61 function self = setState(self, state)
62 % SELF = SETSTATE(STATE)
66 function state = getState(self)
71 function state = getStateSpace(self)
72 % STATE = GETSTATESPACE()
76 function self = setStateSpace(self, space)
77 % SELF = SETSTATESPACE(SPACE)
81 function self = resetStateSpace(self)
82 % SELF = RESETSTATESPACE()
89 function self = Fork(model, name)
90 % FORK Create a Fork node instance
92 % @brief Creates a Fork node
for splitting jobs into parallel tasks
93 % @param model Network model to add
the fork to
94 % @param name String identifier
for the fork node
95 % @
return self Fork instance configured
for the given model
97 % The constructor initializes
the Fork node with appropriate buffers,
98 % service tunnels, and forker output components. Fork
nodes have no
99 % service delay and immediately split incoming jobs into parallel tasks.
102 if model.isMatlabNative()
104 classes = model.getClasses();
106 self.input = Buffer(classes);
107 self.schedStrategy = SchedStrategy.FORK;
108 self.server = ServiceTunnel();
109 self.output = Forker(classes);
110 self.setModel(model);
113 elseif model.isJavaNative()
114 self.setModel(model);
115 self.obj = jline.lang.nodes.Fork(model.obj, name);
116 self.index = model.obj.getNodeIndex(self.obj);
120 function setTasksPerLink(self, nTasks)
121 % SETTASKSPERLINK Configure number of tasks per output link
123 % Sets
the number of tasks sent out on each outgoing link. By
default,
124 % a Fork node sends exactly one task per outgoing link. This method
125 % allows configuring
the Fork to send multiple identical tasks on each
126 % link. The total number of tasks created will be:
127 % (number of outgoing links) × tasksPerLink.
129 % Solver compatibility
for tasksPerLink > 1:
130 % - SolverJMT: Fully supported - simulation handles multiple tasks correctly
131 % - SolverLDES: Fully supported - simulation handles multiple tasks correctly
132 % - SolverMVA (H-T method): Not supported - throws error
133 % - SolverMVA (MMT method): Supported - analytical approximation
135 % @param nTasks Number of tasks per link (default: 1)
138 line_warning(mfilename,
'The setTasksPerLink feature is experimental and results may be inaccurate for analytical solvers.');
140 self.output.tasksPerLink = nTasks;
143 function summary(self)
144 % SUMMARY Display fork node configuration summary
146 % @brief Prints a summary of
the fork node
's routing configuration
148 line_printf('\nNode: <strong>%s</strong>
',self.getName);
149 for r=1:length(self.output.outputStrategy)
150 classes = self.model.getClasses();
151 line_printf('Routing %s: %s
',classes{r}.name,self.output.outputStrategy{r}{2});