Repository navigation
Expand file tree
/
Copy pathrun_single.sh
More file actions
executable file
·153 lines (124 loc) · 5.06 KB
/
Copy pathrun_single.sh
File metadata and controls
executable file
·153 lines (124 loc) · 5.06 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
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
#!/bin/bash
SCRIPT_DIR="$(cd -- "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/load_experiment_config.sh" "${1:-${CONFIG_PATH:-$SCRIPT_DIR/configs/config_NSGA2MOCPOMOEATS_codeA.ini}}"
source "$SCRIPT_DIR/script_functions.sh"
###############################################################################
# Constants
###############################################################################
EXP_NAME="$STANDARD_EXP_NAME"
STANDARD_SEED_END=$((STANDARD_SEED_START + N_EXECUTIONS - 1))
################################################################################
# FUNCTIONS
################################################################################
get_files_exp1() {
NTW_NAME="$(get_network_filename $SEED $NODES $TASKS $USERS $COMMUNITIES)"
SOL_PATH="$(get_solution_path $NTW_NAME $N_REPLICAS $ALGORITHM \
${OBJECTIVES[@]})"
ALG_FILES=()
i=0
for ALG in ${ALGORITHMS[*]}; do
for SD in $(seq "$STANDARD_SEED_START" 1 "$STANDARD_SEED_END"); do
SOL_NAME="$(get_solution_filename $ALG $SD $POP_SIZE $N_GEN \
$SAMPLING_VERSION $CROSSOVER_VERSION $MUTATION_VERSION \
$MUTATION_PROB_MOVE $MUTATION_PROB_CHANGE \
$MUTATION_PROB_BINOMIAL)"
ALG_FILES[${i}]="$SOL_PREFIX/$SOL_PATH/$SOL_NAME"
i=$((i+1))
done
done
echo ${ALG_FILES[*]}
}
get_csv_exp1() {
FILES=$(get_files_exp1)
NTW_NAME="$(get_network_filename $SEED $NODES $TASKS $USERS $COMMUNITIES)"
SOL_PATH="$(get_solution_path $NTW_NAME $N_REPLICAS $ALGORITHM \
${OBJECTIVES[@]})"
local REF_PATH="$(get_ref_points_path $NTW_NAME $N_REPLICAS \
${OBJECTIVES[@]})"
local REF_NAME="$(get_ref_points_filename $REF_POINTS_ALGORITHM)"
local REF_FILE="$SOL_PREFIX/$REF_PATH/$REF_NAME"
if [ -f "$REF_FILE" ]; then
local REF_POINTS_STRING="$(cat $REF_FILE | tr -d '[:space:]')"
local REF_POINTS_OPT=--ref_points
else
local REF_POINTS_STRING=
local REF_POINTS_OPT=
fi
SUFFIX=""$ALGORITHM"_$POP_SIZE:$N_GEN"
mkdir -p "$ALY_PREFIX/$SOL_PATH/$EXP_NAME"
python3 main.py analyze \
--objectives ${OBJECTIVES[*]} $REF_POINTS_OPT $REF_POINTS_STRING \
--network "$NTW_PREFIX/$NTW_NAME" \
-i $FILES \
--alg_names ${ALGORITHMS[*]} \
--seed_values $(seq "$STANDARD_SEED_START" 1 "$STANDARD_SEED_END") \
--pop_values $POP_SIZE \
--gen_values $(seq $GEN_STEP $GEN_STEP $N_GEN) \
--output "$ALY_PREFIX/$SOL_PATH/$EXP_NAME/table_$SUFFIX.csv"
}
get_all_csv() {
# Create a copy of the list of objectives
OBJECTIVES_AUX=(${OBJECTIVES[@]})
# From 2 to $N_OBJECTIVES number of objectives
LENGTH=${#OBJ_UPPERB_LIST[@]}
for IDX in $(seq 0 1 $((LENGTH - 1))); do
# Select subset of objectives with upper bound
OBJ_UPPERB=${OBJ_UPPERB_LIST[$IDX]}
OBJECTIVES=(${OBJECTIVES_AUX[@]::$OBJ_UPPERB})
echo "OBJECTIVES = (${OBJECTIVES[@]})"
# Load generations and pop size for current number of objectives
N_GEN=${N_GENS[$IDX]}
POP_SIZE=${POP_SIZES[$IDX]}
echo " $POP_SIZE:$N_GEN"
get_csv_exp1
done
}
play_with_objectives() {
# Create a copy of the list of objectives
OBJECTIVES_AUX=(${OBJECTIVES[@]})
# From 2 to $N_OBJECTIVES number of objectives
LENGTH=${#OBJ_UPPERB_LIST[@]}
for IDX in $(seq 0 1 $((LENGTH - 1))); do
# Select subset of objectives with upper bound
OBJ_UPPERB=${OBJ_UPPERB_LIST[$IDX]}
OBJECTIVES=(${OBJECTIVES_AUX[@]::$OBJ_UPPERB})
echo "OBJECTIVES = (${OBJECTIVES[@]})"
# Load generations and pop size for current number of objectives
N_GEN=${N_GENS[$IDX]}
POP_SIZE=${POP_SIZES[$IDX]}
echo " $POP_SIZE:$N_GEN"
for ALGORITHM in ${ALGORITHMS[*]}; do
echo " ALGORITHM = $ALGORITHM"
# Load number of iterations having:
# - N_EXECUTIONS total executions
# - N_PROC max paralel processes
N_ITER=$((
N_EXECUTIONS % N_PROC == 0 ?
N_EXECUTIONS / N_PROC :
N_EXECUTIONS / N_PROC + 1
))
for ITER in $(seq 1 1 $N_ITER); do
# Calculate start iteration index and end iteration index
START=$((STANDARD_SEED_START + (ITER - 1) * N_PROC))
END=$((
STANDARD_SEED_END <= STANDARD_SEED_START + ITER * N_PROC - 1 ?
STANDARD_SEED_END :
STANDARD_SEED_START + ITER * N_PROC - 1
))
echo " $START-$END"
for SEED2 in $(seq $START 1 $END); do
echo " $SEED2"
solve &
pids[$i]=$!
i=$((i+1))
done
for pid in ${pids[*]}; do
wait $pid
done
done
done
done
}
generate # generate network
play_with_objectives
get_all_csv