Algorithm 3 Spoilage Prediction Using GNN and Actor–Critic Learning with Context-Aware Weights and Coordination |
-
1:
Input: Cold-chain graph , node features , disruption scenarios D, spoilage labels y
-
2:
Initialize: Actor , critic , GNN encoder , replay buffer
-
3:
Initialize: Shared intention buffer ; static reward coefficients
-
4:
for each training episode do
-
5:
Simulate disrupted scenario from D
-
6:
Build graph G with node features X
-
7:
Compute graph embedding
-
8:
Set initial state
-
9:
for each timestep t do
|
-
10:
Select action
|
▹ e.g., spoilage threshold or inspection trigger |
|
▹ Declare spoilage alert intention |
-
12:
if conflicting inspections or redundant predictions detected in then
-
13:
Apply penalty or adjust decision based on criticality
-
14:
end if
-
15:
Predict spoilage:
-
16:
Observe ground truth and compute classification loss
-
17:
Compute false negative (FN) rate as critical misprediction signal
-
18:
Extract context vector:
-
19:
-
20:
-
21:
Observe next state from updated GNN encoding
-
22:
Store in
-
23:
Sample mini-batch from
-
24:
-
25:
-
26:
Optionally fine-tune with prediction loss
-
27:
Clear
-
28:
end for
-
29:
end for
-
30:
Output: Trained spoilage policy and GNN encoder
|