]> AND Private Git Repository - loba.git/blob - Experimentations/make_params
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
f034186db8a9e0e9424e79d0b5959fef9801ec14
[loba.git] / Experimentations / make_params
1 #!/bin/bash
2
3 set -e
4
5 TEMPLATE=${1:-"ag_parameters"}
6 PREFIX=param
7
8 log() {
9     echo "-#- $@" >&2
10 }
11
12 die() {
13     echo "ERROR: $@" >&2
14     exit 2
15 }
16
17 test -r "$TEMPLATE" || die "file not found: $TEMPLATE"
18
19 for flavour in "I" "R"; do
20     for distrib in "1" "N"; do
21         for ratio in "1000:1" "100:1" "10:1" "1:1" "1:10" "1:100" "1:1000"; do
22             declare -a opts=( )
23             case "$flavour" in
24                 "I") opts+=( -Z ) ;;
25                 "R") : ;;
26                 *) die "unknown flavour: $flavour" ;;
27             esac
28             case "$distrib" in
29                 "1") : ;;
30                 "N") opts+=( -r42 -R ) ;;
31                 *) die "unknown distribution: $distrib" ;;
32             esac
33             case "$ratio" in
34                 *100*)    continue ;; ##### HACK, FIXME #####
35                 "1000:1") opts+=( -c1e6,0 -C1.25e2,0 ) ;;
36                 "100:1")  opts+=( -c1e6,0 -C1.25e3,0 ) ;;
37                 "10:1")   opts+=( -c1e6,0 -C1.25e4,0 ) ;;
38                 "1:1")    opts+=( -c1e6,0 -C1.25e5,0 ) ;;
39                 "1:10")   opts+=( -c1e6,0 -C1.25e6,0 ) ;;
40                 "1:100")  opts+=( -c1e6,0 -C1.25e7,0 ) ;;
41                 "1:1000") opts+=( -c1e6,0 -C1.25e8,0 ) ;;
42                 *) die "unknown ratio: $ratio" ;;
43             esac
44             suffix="${flavour}${distrib}_${ratio}"
45             output="${PREFIX}_${suffix}"
46             more_args="${opts[@]}"
47             results="./results_${suffix}"
48             log "writing file: ${output}"
49             {
50                 sed -n '/MORE_ARGS/q;p' "$TEMPLATE"
51                 printf 'MORE_ARGS=( %s )\n' "${more_args}"
52                 sed -n '1,/MORE_ARGS/d;/RESULTS/q;p' "$TEMPLATE"
53                 printf 'RESULTS="%s"\n' "${results}"
54                 sed '1,/RESULTS/d' "$TEMPLATE"
55             } > "${output}"
56         done
57     done
58 done