## Appendix A  
Experimental Code Structure and Explanation.  
The codebase is structured as follows:  
main.py # Main entry point for experiments  
config/  
config.yaml # Configuration parameters  
models/  
neural_networks.py # Neural network model definitions  
federated_models.py # Federated learning model implementations  
algorithms/  
adaptive_transfer.py # Adaptive transfer learning implementation  
hierarchical_rl.py # Hierarchical reinforcement learning  
privacy_budget.py # Privacy budget allocation  
robust_aggregation.py # Robust aggregation methods  
utils/  
data_loader.py # Dataset loading and preprocessing  
metrics.py # Evaluation metrics  
visualization.py # Results visualization  
simulation/  
network_topology.py # SAGIN network topology simulator  
device_manager.py # Device status and capability simulator  
communication.py # Communication channel simulator  
Detailed Code Structure Introduction  
main.py  
main.py serves as the primary entry point for experiments, responsible for initializing the entire system and controlling the execution flow. This file implements the following functionalities: parsing configuration files and initializing the experimental environment, creating and configuring the space-air-ground integrated network simulation environment, initializing terminal devices, edge nodes, and the central server, and coordinating the federated learning training process, including local training, model aggregation, and evaluation.  
config/  
The config/folder contains experimental configuration parameters, primarily including config.yaml, which stores experiment parameters such as network topology parameters, federated learning parameters, differential privacy parameters, device parameter configurations, and dataset configurations.  
models/  
The models/folder contains neural network model definitions and federated learning model implementations. Specifically, neural_networks.py implements the neural networkmodels used in experiments, while federated_models.py implements various federated learning algorithms, including FedAvg, FedAsync, FedAsyncISL, and others.  
algorithms/  
The algorithms/folder contains implementations of the core algorithms proposed in this paper. Among them, adaptive_transfer.py implements the adaptive transfer learning mechanism, including dynamic weighting factor calculation, task matching degree calculation, and transfer learning model updates. hierarchical_rl.py implements the device selection strategy based on hierarchical reinforcement learning, including global layer decision-making, local layer decision-making, and meta-learning-based strategy optimization. privacy_budget.py implements the privacy budget allocation strategy, including Laplace and Gaussian noise mechanisms, dynamic privacy budget allocation, and reinforcement learning-based privacy budget optimization.  
utils/  
The utils/folder contains utility functions, including data_loader.py which implements dataset loading and preprocessing, metrics.py which implements evaluation metric calculations such as accuracy, precision, recall, and F1-score, and visualization.py which implements result visualization.  
simulation/  
The simulation/folder contains the implementation of the space-air-groundintegrated network simulation, where network_topology.py serves as the network topology simulator, device_manager.py is the device status and capability simulator, and communication.py is the communication channel simulator.