- Created summary.csv to store simulation results for various scenarios, protocols, and metrics. - Developed run.sh script to automate the simulation process, including dependency checks, simulation execution, and result analysis. - Ensured proper directory structure for results and reports. - Added error handling for Python and matplotlib dependencies.
64 lines
1.6 KiB
Bash
Executable File
64 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script de lancement complet de la simulation LEACH/LEACH-C
|
|
|
|
# Get the script's directory
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
echo "============================================================"
|
|
echo " SIMULATION LEACH vs LEACH-C - RÉSEAUX DYNAMIQUES"
|
|
echo "============================================================"
|
|
echo ""
|
|
|
|
# Vérifier que Python est installé
|
|
if ! command -v python3 &> /dev/null; then
|
|
echo "ERREUR: Python3 n'est pas installé. Veuillez installer Python 3.x"
|
|
exit 1
|
|
fi
|
|
|
|
# Vérifier les dépendances
|
|
echo "Vérification des dépendances..."
|
|
python3 -c "import matplotlib" 2>/dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "Attention: matplotlib non trouvé. Installation..."
|
|
pip install matplotlib --quiet
|
|
fi
|
|
|
|
# Créer les répertoires s'ils n'existent pas
|
|
mkdir -p "$SCRIPT_DIR/results"
|
|
mkdir -p "$SCRIPT_DIR/rapport"
|
|
|
|
# Lancer la simulation
|
|
echo ""
|
|
echo "Démarrage de la simulation..."
|
|
echo ""
|
|
cd "$SCRIPT_DIR/code"
|
|
python3 main.py
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo ""
|
|
echo "Simulation terminée avec succès"
|
|
echo ""
|
|
echo "Génération des graphiques..."
|
|
python3 analysis.py
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo ""
|
|
echo "Graphiques générés"
|
|
echo ""
|
|
echo "Résultats disponibles dans: $SCRIPT_DIR/results/"
|
|
ls -lh "$SCRIPT_DIR/results/"
|
|
else
|
|
echo "ERREUR: lors de la génération des graphiques"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "ERREUR: lors de la simulation"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "============================================================"
|
|
echo " PROCESSUS TERMINÉ"
|
|
echo "============================================================"
|