forked from eqasim-org/eqasim-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimulation_bavaria_fleetpy_sc_1_100.sbatch
More file actions
124 lines (112 loc) · 4.38 KB
/
Copy pathsimulation_bavaria_fleetpy_sc_1_100.sbatch
File metadata and controls
124 lines (112 loc) · 4.38 KB
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
#!/bin/bash
#
# Run EQASim + FleetPy in parallel within one Slurm job.
#
#SBATCH -J sc_1_100
#SBATCH --output=sim_sc1_100_minga_%j.log
#SBATCH --error=sim_sc1_100_minga_%j.log
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=48
#SBATCH --mem=600GB
#SBATCH --time=48:00:00
#SBATCH --account=pn39mu
#SBATCH --partition=fat
#SBATCH --mail-type=BEGIN,END,FAIL
#SBATCH --mail-user=elena.natterer@tum.de
#SBATCH --get-user-env
#SBATCH --export=none
set -euo pipefail
# SuperMUC-NG: initialize module environment.
module load slurm_setup
# module load openjdk/21.0.3_9
# module load miniconda/3
#export HOME=/dss/dsshome1/06/ge49wav3
export FONTCONFIG_PATH=$HOME/test_java_font_4u/fonts
export FONTCONFIG_FILE=$HOME/test_java_font_4u/fonts/fonts.conf
export FC_FONT_PATH=$HOME/test_java_font_4u/fonts
# FleetPy python (prefer direct env python to avoid conda.sh issues).
FLEETPY_ENV="/dss/dsshome1/06/ge49wav3/.conda/envs/fleetpy_new"
FLEETPY_PYTHON="${FLEETPY_ENV}/bin/python"
if [ ! -x "${FLEETPY_PYTHON}" ]; then
echo "ERROR: FleetPy python not found at ${FLEETPY_PYTHON}" >&2
exit 1
fi
EQASIM_DIR="${SLURM_SUBMIT_DIR}"
# Use the shared filesystem path on the cluster for FleetPy.
FLEETPY_DIR="/hppfs/work/pn39mu/ge49wav3/mount_point_work_dir/MINGA_project/FleetPy"
PORT=6650
MATSim_CPUS=44
FLEETPY_CPUS=4
JAVA_LOG="${EQASIM_DIR}/output_config_sc1_drt.log"
FLEETPY_LOG="${EQASIM_DIR}/output_config_sc1_drt.log"
CONFIG_PATH="${EQASIM_DIR}/populations/muenchen_2024_10pct/synthetic_population_output/munich_config_with_drt_sbatch.xml"
OUTPUT_DIR="${EQASIM_DIR}/simulation_output/config_drt_sc1"
NETWORK_PATH="//hppfs/work/pn39mu/ge49wav3/mount_point_work_dir/MINGA_project/eqasim-java-bavaria/populations/muenchen_2024_10pct/synthetic_population_output/munich_network.xml.gz"
FLEETPY_CONFIG="${FLEETPY_DIR}/studies/scenarios/constant_config_minga_sc1_10pct.yaml"
# Run both processes inside a single Slurm step to avoid step scheduling issues.
srun --cpus-per-task=48 /bin/bash -lc "
cd \"${EQASIM_DIR}\" &&
echo \"[$(date -Is)] Starting MATSim\" > \"${JAVA_LOG}\" &&
java \
-Xms100g -Xmx500g \
-Xlog:gc*,os=info,memops=info \
-Djava.awt.headless=true \
-cp bavaria/target/bavaria-2.0.0.jar \
org.eqasim.bavaria.RunSimulationWithFleetPy \
--config-path \"${CONFIG_PATH}\" \
--config:global.numberOfThreads ${MATSim_CPUS} \
--config:controller.outputDirectory \"${OUTPUT_DIR}\" \
--use-vdf True \
--remote-port ${PORT} \
>> \"${JAVA_LOG}\" 2>&1 &
# Keep MATSim running in background; we wait for all jobs below.
# Wait until the socket is reachable before starting FleetPy.
# Default: enforce an 8-minute minimum wait, then wait up to 15 minutes total.
MIN_WAIT_SECONDS=480
WAIT_INTERVAL_SECONDS=5
MAX_WAIT_SECONDS=900
if [ \"\${MIN_WAIT_SECONDS}\" -gt 0 ]; then
echo \"[$(date -Is)] Waiting \${MIN_WAIT_SECONDS}s before checking MATSim socket...\" >&2
sleep \"\${MIN_WAIT_SECONDS}\"
fi
elapsed=0
while [ \"\${elapsed}\" -lt \"\${MAX_WAIT_SECONDS}\" ]; do
if (echo > /dev/tcp/127.0.0.1/${PORT}) >/dev/null 2>&1; then
break
fi
if [ \"\$((elapsed % 60))\" -eq 0 ]; then
echo \"[$(date -Is)] Waiting for MATSim socket on port ${PORT} (\${elapsed}s elapsed)...\" >&2
fi
sleep \"\${WAIT_INTERVAL_SECONDS}\"
elapsed=\$((elapsed + WAIT_INTERVAL_SECONDS))
done
if ! (echo > /dev/tcp/127.0.0.1/${PORT}) >/dev/null 2>&1; then
echo \"WARNING: MATSim socket not reachable on port ${PORT} after \${MAX_WAIT_SECONDS}s. Starting FleetPy anyway...\" >&2
fi
if [ ! -d \"${FLEETPY_DIR}\" ]; then
echo \"ERROR: FleetPy directory not found: ${FLEETPY_DIR}\" >&2
exit 1
fi
if [ ! -f \"${FLEETPY_CONFIG}\" ]; then
echo \"ERROR: FleetPy config not found: ${FLEETPY_CONFIG}\" >&2
exit 1
fi
if [ ! -x \"${FLEETPY_PYTHON}\" ]; then
echo \"ERROR: FleetPy python not executable: ${FLEETPY_PYTHON}\" >&2
exit 1
fi
cd \"${FLEETPY_DIR}\" &&
echo \"[$(date -Is)] Launching FleetPy\" >&2 &&
echo \"[$(date -Is)] Starting FleetPy\" > \"${FLEETPY_LOG}\" &&
export OMP_NUM_THREADS=${FLEETPY_CPUS} &&
export OPENBLAS_NUM_THREADS=${FLEETPY_CPUS} &&
export MKL_NUM_THREADS=${FLEETPY_CPUS} &&
\"${FLEETPY_PYTHON}\" src/coupling/MATSimEqasim/MATSimSocket.py \
\"${FLEETPY_CONFIG}\" \
\"${NETWORK_PATH}\" \
${PORT} \
>> \"${FLEETPY_LOG}\" 2>&1 &
# Wait for all background jobs in this shell.
wait
"