-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestTransition.m
160 lines (147 loc) · 4.05 KB
/
testTransition.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
% TEST testTransitionIndex FUNCTION
%
% This function is designed to take a given controlled testTransitionIndex
% (1,3,5,..,etc) and the current marking (state) and return a TRUE == 1 or
% a FALSE == 0 in terms of feasiblity. This information used by the
% findFeasibleControlledEvents function to discover all feasible events to
% find feasible events in the neighbourhood.
function [feasible] = testTransition(testTransitionIndex, SYSTEM)
% NOTES
% A testTransitionIndex basically means that the place in which the token goes from
% goes down by 1 and the one that it goes to goes up by 1.
% RULE_SET_TOTYPE = RULE_SET(testTransitionIndex, 4);
% RULE_SET_FROMTYPE = RULE_SET(testTransitionIndex, 3);
% RULE_SET_TO = RULE_SET(testTransitionIndex, 2);
% RULE_SET_FROM = RULE_SET(testTransitionIndex, 1);
% BECAUSE WE'RE TESTING eC, its ALWAYS going from a queue to a workcenter
% Set feasible as default 0
feasible = uint8(0);
% CH
% FROM (-1)
switch SYSTEM.RULE_SET(testTransitionIndex, 1)
% A TYPES
case 1
% A1 TYPE
% IF THE QUEUE HAS ONE OR MORE
if SYSTEM.A1.VOLUME >= 1
feasible = uint8(1);
else
feasible = uint8(0);
return
end
case 2
% A2 TYPE
% IF THE QUEUE HAS ONE OR MORE
if SYSTEM.A2.VOLUME >= 1
feasible = uint8(1);
else
feasible = uint8(0);
return
end
% B TYPES
case 4
% B1 TYPE
% IF THE QUEUE HAS ONE OR MORE
if SYSTEM.B1.VOLUME >= 1
feasible = uint8(1);
else
feasible = uint8(0);
return
end
case 5
% B2 TYPE
% IF THE QUEUE HAS ONE OR MORE
if SYSTEM.B2.VOLUME >= 1
feasible = uint8(1);
else
feasible = uint8(0);
return
end
% C TYPES
case 7
% C1 TYPE
% IF THE QUEUE HAS ONE OR MORE
if SYSTEM.C1.VOLUME >= 1
feasible = uint8(1);
else
feasible = uint8(0);
return
end
case 8
% C2 TYPE
% IF THE QUEUE HAS ONE OR MORE
if SYSTEM.C2.VOLUME >= 1
feasible = uint8(1);
else
feasible = uint8(0);
return
end
end
% THIS CODE IS BEASTY
% TO (+1)
resourceType = 0;
resourceIndex = 1;
targetResource = SYSTEM.RULE_SET(testTransitionIndex, 2);
PERMUTATION = SYSTEM.SYS_PERMUTATION;
while targetResource ~= 0
resourceType = resourceType + 1;
resourceIndex = 1;
if PERMUTATION(resourceType) > 0
while PERMUTATION(resourceType) > 0
targetResource = targetResource - 1;
resourceIndex = resourceIndex + 1;
PERMUTATION(resourceType) = PERMUTATION(resourceType) - 1;
if targetResource == 0
break
end
end
end
end
resourceIndex = resourceIndex - 1;
switch SYSTEM.RULE_SET(testTransitionIndex, 1)
case 1
taskTypeQueue = 'A1';
case 2
taskTypeQueue = 'A2';
case 4
taskTypeQueue = 'B1';
case 5
taskTypeQueue = 'B2';
case 7
taskTypeQueue = 'C1';
case 8
taskTypeQueue = 'C2';
end
switch resourceType
case 1
% R1 RESOURCE
if SYSTEM.R1(resourceIndex).STATE == true
feasible = uint8(0);
end
case 2
% R2 RESOURCE
if SYSTEM.R2(resourceIndex).STATE == true
feasible = uint8(0);
end
case 3
% R3 RESOURCE
if SYSTEM.R3(resourceIndex).STATE == true
feasible = uint8(0);
end
case 4
% R4 RESOURCE
if SYSTEM.R4(resourceIndex).STATE == true
feasible = uint8(0);
end
case 5
% R5 RESOURCE
if SYSTEM.R5(resourceIndex).STATE == true
feasible = uint8(0);
end
end
%% DEBUGGER
% disp("_________________________");
% disp("CONTROLLED EVENT: " + testTransitionIndex);
% disp("USES TASK TYPE QUEUE: " + taskTypeQueue);
% disp("USES RESOURCE TYPE; R" + resourceType + " WITH INDEX: " + resourceIndex);
end