LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Fork.m
1classdef Fork < Node
2 % Fork Job splitting node for parallel processing models
3 %
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.
8 %
9 % @brief Job splitting node that creates parallel sibling tasks from incoming jobs
10 %
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
17 %
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
24 %
25 % Example:
26 % @code
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
30 % @endcode
31 %
32 % Copyright (c) 2012-2026, Imperial College London
33 % All rights reserved.
34
35 properties
36 schedStrategy;
37 cap;
38 end
39
40 methods
41 %Constructor
42 function self = Fork(model, name)
43 % FORK Create a Fork node instance
44 %
45 % @brief Creates a Fork node for splitting jobs into parallel tasks
46 % @param model Network model to add the fork to
47 % @param name String identifier for the fork node
48 % @return self Fork instance configured for the given model
49 %
50 % The constructor initializes the Fork node with appropriate buffers,
51 % service tunnels, and forker output components. Fork nodes have no
52 % service delay and immediately split incoming jobs into parallel tasks.
53
54 self@Node(name);
55 if model.isMatlabNative()
56 if(model ~= 0)
57 classes = model.getClasses();
58 self.cap = Inf;
59 self.input = Buffer(classes);
60 self.schedStrategy = SchedStrategy.FORK;
61 self.server = ServiceTunnel();
62 self.output = Forker(classes);
63 self.setModel(model);
64 model.addNode(self);
65 end
66 elseif model.isJavaNative()
67 self.setModel(model);
68 self.obj = jline.lang.nodes.Fork(model.obj, name);
69 self.index = model.obj.getNodeIndex(self.obj);
70 end
71 end
72
73 function setTasksPerLink(self, nTasks)
74 % SETTASKSPERLINK Configure number of tasks per output link
75 %
76 % Sets the number of tasks sent out on each outgoing link. By default,
77 % a Fork node sends exactly one task per outgoing link. This method
78 % allows configuring the Fork to send multiple identical tasks on each
79 % link. The total number of tasks created will be:
80 % (number of outgoing links) × tasksPerLink.
81 %
82 % Solver compatibility for tasksPerLink > 1:
83 % - SolverJMT: Fully supported - simulation handles multiple tasks correctly
84 % - SolverMVA (H-T method): Not supported - throws error
85 % - SolverMVA (MMT method): Limited - results may be inaccurate
86 %
87 % @param nTasks Number of tasks per link (default: 1)
88
89 self.output.tasksPerLink = nTasks;
90 end
91
92 function summary(self)
93 % SUMMARY Display fork node configuration summary
94 %
95 % @brief Prints a summary of the fork node's routing configuration
96
97 line_printf('\nNode: <strong>%s</strong>',self.getName);
98 for r=1:length(self.output.outputStrategy)
99 classes = self.model.getClasses();
100 line_printf('Routing %s: %s',classes{r}.name,self.output.outputStrategy{r}{2});
101 end
102 end
103 end
104
105end
Definition mmt.m:92