2 % @brief Validates inputs
for Flow-Equivalent Server (FES) aggregation
4 % @author LINE Development Team
8 % @brief Validates inputs
for Flow-Equivalent Server (FES) aggregation
11 % Checks that the network structure and station subset are valid
for FES aggregation:
12 % - Model
is a closed product-form queueing network
13 % - Station subset
is non-empty and not the entire network
14 % - Subset contains only Queue or Delay stations
15 % - All station indices are valid
19 % [isValid, errorMsg] = fes_validate(sn, subsetIndices)
24 % <tr><th>Name<th>Description
25 % <tr><td>sn<td>Network structure (from model.getStruct())
26 % <tr><td>subsetIndices<td>Array of station indices to aggregate (1-based)
31 % <tr><th>Name<th>Description
32 % <tr><td>isValid<td>True
if inputs are valid
for FES aggregation
33 % <tr><td>errorMsg<td>Error message
if validation fails, empty otherwise
36function [isValid, errorMsg] = fes_validate(sn, subsetIndices)
43 errorMsg =
'First argument must be a network structure (sn).';
47% Check required fields exist in sn
48requiredFields = {
'nstations',
'nclasses',
'njobs',
'nodetype',
'stationToNode'};
49for i = 1:length(requiredFields)
50 if ~isfield(sn, requiredFields{i})
51 errorMsg = sprintf(
'Network structure missing required field: %s', requiredFields{i});
56% Check subsetIndices
is a numeric array
57if ~isnumeric(subsetIndices)
58 errorMsg =
'Station subset must be a numeric array of station indices.';
62% Check subset
is non-empty
63if isempty(subsetIndices)
64 errorMsg = 'Station subset cannot be empty.';
68% Check model has only closed
classes (FES applies to closed networks)
69if sn_is_open_model(sn)
70 errorMsg =
'FES aggregation only applies to closed queueing networks. Model contains open classes.';
76% Check subset
is not the entire network
77if length(subsetIndices) >= M
78 errorMsg =
'Cannot aggregate all stations. The subset must be a proper subset of the network.';
82% Validate each station index in the subset
83for i = 1:length(subsetIndices)
84 stationIdx = subsetIndices(i);
86 % Check station index
is valid
87 if stationIdx < 1 || stationIdx > M || stationIdx ~= floor(stationIdx)
88 errorMsg = sprintf(
'Station index %d is invalid. Must be an integer between 1 and %d.', stationIdx, M);
92 % Check station
is a Queue or Delay (not Fork, Join, Source, Sink, Cache, etc.)
93 nodeIdx = sn.stationToNode(stationIdx);
94 nodeType = sn.nodetype(nodeIdx);
96 if nodeType ~= NodeType.Queue && nodeType ~= NodeType.Delay
97 errorMsg = sprintf('Station %d has type %s. FES aggregation only supports Queue and Delay stations.', ...
98 stationIdx, NodeType.toText(nodeType));
103% Check for duplicate stations in subset
104if length(unique(subsetIndices)) ~= length(subsetIndices)
105 errorMsg = 'Station subset contains duplicate stations.';
109% All validations passed