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

Private GIT Repository
Add a VERSION file, for the distrib.
[loba.git] / Experimentations / make_params
1 #!/bin/bash
2
3 set -e
4
5 TEMPLATE=${1:-"ag_parameters"}
6 PREFIX=${2:-"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 source "$TEMPLATE" || die "cannot read file: $TEMPLATE"
20 declare -a common_opts=( "${MORE_ARGS[@]}" )
21
22 for flavour in "I" "R"; do
23     for distrib in "1" "N"; do
24         for ratio in "1000:1" "100:1" "10:1" "1:1" "1:10" "1:100" "1:1000"; do
25             declare -a opts=( "${common_opts[@]}" )
26             case "$flavour" in
27                 "I") opts+=( -Z ) ;;
28                 "R") : ;;
29                 *) die "unknown flavour: $flavour" ;;
30             esac
31             case "$distrib" in
32                 "1") : ;;
33                 "N") opts+=( -r42 -R ) ;;
34                 *) die "unknown distribution: $distrib" ;;
35             esac
36             case "$ratio" in
37                 "1000:1") opts+=( -c1e6,0 -C1.25e2,0 ) ;;
38                 "100:1")  opts+=( -c1e6,0 -C1.25e3,0 ) ;;
39                 "10:1")   opts+=( -c1e6,0 -C1.25e4,0 ) ;;
40                 "1:1")    opts+=( -c1e6,0 -C1.25e5,0 ) ;;
41                 "1:10")   opts+=( -c1e6,0 -C1.25e6,0 ) ;;
42                 "1:100")  opts+=( -c1e6,0 -C1.25e7,0 ) ;;
43                 "1:1000") opts+=( -c1e6,0 -C1.25e8,0 ) ;;
44                 *) die "unknown ratio: $ratio" ;;
45             esac
46             suffix="${flavour}${distrib}_${ratio}"
47             output="${PREFIX}_${suffix}"
48             more_args="${opts[@]}"
49             results="./results_${suffix}"
50             log "writing file: ${output}"
51             {
52                 sed -n '/MORE_ARGS/q;p' "$TEMPLATE"
53                 printf 'MORE_ARGS=( %s )\n' "${more_args}"
54                 sed -n '1,/MORE_ARGS/d;/RESULTS/q;p' "$TEMPLATE"
55                 printf 'RESULTS="%s"\n' "${results}"
56                 sed '1,/RESULTS/d' "$TEMPLATE"
57             } > "${output}"
58         done
59     done
60 done