LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Source.m
1classdef Source < Station
2 % Source External job arrival node for open queueing networks
3 %
4 % Source represents an external arrival node that generates jobs for open
5 % classes according to specified arrival processes. It serves as the entry
6 % point for jobs entering the network from the external environment, with
7 % configurable arrival rates and distributions for each job class.
8 %
9 % @brief External arrival node generating jobs for open queueing networks
10 %
11 % Key characteristics:
12 % - External job generation for open classes
13 % - Class-dependent arrival processes
14 % - Infinite capacity job source
15 % - Configurable inter-arrival time distributions
16 % - Integration with network routing
17 %
18 % Source node features:
19 % - Multiple job class support
20 % - Flexible arrival process specification
21 % - Poisson, MAP, and general arrival processes
22 % - Arrival rate configuration per class
23 % - Disabled arrival capability for specific classes
24 %
25 % Source is used for:
26 % - Web server client arrivals
27 % - Manufacturing job arrivals
28 % - Call center customer generation
29 % - Network packet injection
30 % - Open system workload modeling
31 %
32 % Example:
33 % @code
34 % model = Network('WebServer');
35 % source = Source(model, 'ClientArrivals');
36 % webClass = OpenClass(model, 'WebRequests', 1);
37 % source.setArrival(webClass, Exp(2.0)); % Poisson arrivals, rate 2
38 % @endcode
39 %
40 % Copyright (c) 2012-2026, Imperial College London
41 % All rights reserved.
42
43 properties
44 schedStrategy;
45 arrivalProcess;
46 end
47
48 methods
49 %Constructor
50 function self = Source(model, name)
51 % SOURCE Create an external arrival source node
52 %
53 % @brief Creates a Source node for external job generation
54 % @param model Network model to add the source node to
55 % @param name String identifier for the source node
56 % @return self Source instance ready for arrival process configuration
57 self@Station(name);
58 if model.isMatlabNative()
59 self.numberOfServers = 1;
60 if(model ~= 0)
61 classes = model.getClasses();
62 self.classCap = Inf*ones(1,length(classes));
63 self.output = Dispatcher(classes);
64 self.server = ServiceTunnel();
65 self.input = RandomSource(classes);
66 self.schedStrategy = SchedStrategy.EXT;
67 self.setModel(model);
68 model.addNode(self);
69 end
70 elseif model.isJavaNative()
71 self.setModel(model);
72 self.obj=jline.lang.nodes.Source(model.obj, name);
73 end
74 end
75
76 function setArrival(self, class, distribution)
77 % SETARRIVAL(CLASS, DISTRIBUTION)
78 % distribution can be a Distribution object or a Workflow object
79
80 % If Workflow, convert to PH distribution
81 if isa(distribution, 'Workflow')
82 distribution = distribution.toPH();
83 end
84
85 if isempty(self.obj)
86 % Check if arrival was already configured
87 if length(self.input.sourceClasses) >= class.index && ~isempty(self.input.sourceClasses{1, class.index})
88 % Invalidate struct so procid gets recomputed
89 self.model.setInitialized(false);
90 self.model.hasStruct = false;
91 end
92 self.input.sourceClasses{1, class.index}{2} = ServiceStrategy.LI;
93 self.input.sourceClasses{1, class.index}{3} = distribution;
94 self.arrivalProcess{1,class.index} = distribution;
95 if distribution.isDisabled()
96 self.classCap(class.index) = 0;
97 else
98 self.classCap(class.index) = Inf;
99 end
100 else
101 self.obj.setArrival(class.obj, distribution.obj);
102 % Also update MATLAB-side storage to keep in sync with Java object
103 % This ensures getArrivalProcess returns the correct distribution
104 % Check if arrival was already configured
105 if length(self.input.sourceClasses) >= class.index && ~isempty(self.input.sourceClasses{1, class.index})
106 % Invalidate struct so procid gets recomputed
107 self.model.setInitialized(false);
108 self.model.hasStruct = false;
109 end
110 self.input.sourceClasses{1, class.index}{2} = ServiceStrategy.LI;
111 self.input.sourceClasses{1, class.index}{3} = distribution;
112 self.arrivalProcess{1,class.index} = distribution;
113 if distribution.isDisabled()
114 self.classCap(class.index) = 0;
115 else
116 self.classCap(class.index) = Inf;
117 end
118 end
119 end
120
121 function distrib = getArrivalProcess(self, oclass)
122 distrib = self.arrivalProcess{oclass};
123 end
124
125 end
126
127end