-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrunart1
executable file
·153 lines (146 loc) · 4.23 KB
/
runart1
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
INT_RE='^[0-9]+$'
FLOAT_RE='^[0-9]+([.][0-9]+)?$'
BETA=1
SKIP=0
VIGILANCE=0.5
TRAINNOISE=0
TESTNOISE=0
OUTPUT="art"
FLUCTUATION=5
PASS=100
TRAIN=""
TEST=""
usage(){
echo -e "USAGE:\trunart1 [-T -o -b -v -s -e -n -p] -t input_file"
echo -e "OPTIONS:"
echo -e "\t-t file containing the patterns to train"
echo -e "\t-T file containing the patterns to test"
echo -e "\t-o prefix of the output files (default is \"art\")"
echo -e "\t-b beta network parameter: influences the number of created clusters (default is 1)"
echo -e "\t-v vigilance network parameter: similarity threshold (default is 0.5)"
echo -e "\t-s skip the first column in the input file"
echo -e "\t-f fluctuation network parameter: stop if fluctuation lower this parameter"
echo -e "\t-n noise network parameter: percentage of noise to add to the training patterns"
echo -e "\t-N noise network parameter: percentage of noise to add to the testing patterns"
echo -e "\t-p passes network parameter: maximum number of passes through the input examples"
}
while test $# -gt 0; do
case "$1" in
-h|--help)
usage
exit 0
;;
-b*|--beta*)
shift
if ! [[ $1 =~ $INT_RE ]]; then
echo "ERROR: BETA must be an integer" >&2
exit 1
fi
BETA=$1
shift
;;
-s|--skip)
SKIP=1
shift
;;
-v*|--vigilance*)
shift
if ! [[ $1 =~ $FLOAT_RE ]]; then
echo "ERROR: VIGILANCE must be a float" >&2
exit 1
fi
if (( $(bc <<< "$1 > 1") == 1 )) || (( $(bc <<< "$1 < 0") == 1 ))
then
echo "ERROR: VIGILANCE must in range [0, 1]" >&2
exit 1
fi
VIGILANCE=$1
shift
;;
-o*|--output*)
shift
OUTPUT=$1
shift
;;
-f*|--fluctuation*)
shift
if ! [[ $1 =~ $FLOAT_RE ]]; then
echo "ERROR: FLUCTUATION must be a float" >&2
exit 1
fi
if (( $(bc <<< "$1 > 100") == 1 )) || (( $(bc <<< "$1 < 0") == 1 ))
then
echo "ERROR: FLUCTUATION must in range [0, 100]" >&2
exit 1
fi
FLUCTUATION=$1
shift
;;
-n*|--noise-train*)
shift
if ! [[ $1 =~ $INT_RE ]]; then
echo "ERROR: TRAINNOISE must be an integer" >&2
exit 1
fi
if (( $(bc <<< "$1 > 100") == 1 )) || (( $(bc <<< "$1 < 0") == 1 ))
then
echo "ERROR: TRAINNOISE must in range [0, 100]" >&2
exit 1
fi
TRAINNOISE=$1
shift
;;
-N*|--noise-test*)
shift
if ! [[ $1 =~ $INT_RE ]]; then
echo "ERROR: TESTNOISE must be an integer" >&2
exit 1
fi
if (( $(bc <<< "$1 > 100") == 1 )) || (( $(bc <<< "$1 < 0") == 1 ))
then
echo "ERROR: TESTNOISE must in range [0, 100]" >&2
exit 1
fi
TESTNOISE=$1
shift
;;
-p*|--pass*)
shift
if ! [[ $1 =~ $INT_RE ]]; then
echo "ERROR: PASS must be an integer" >&2
exit 1
fi
PASS=$1
shift
;;
-t*|--train*)
shift
if [ ! -f $1 ]; then
echo "ERROR: $1 dosen't exist!"
exit 1
fi
TRAIN=$1
shift
;;
-T*|--test*)
shift
if [ ! -f $1 ]; then
echo "ERROR: $1 dosen't exist!"
exit 1
fi
TEST=$1
shift
;;
*)
break
;;
esac
done
if [ "$TRAIN" == "" ]; then
echo "ERROR: you must specify a training file using option -t"
usage
exit 1;
fi
./art1 "$TRAIN" "$TEST" "$OUTPUT" "$SKIP" "$TRAINNOISE" " $TESTNOISE" "$BETA" "$VIGILANCE" "$FLUCTUATION" "$PASS"
exit 0