|
@@ -26,7 +26,6 @@ function _help
|
26
|
26
|
_echo "\tpert.sh 10,15,20 5,7,10"
|
27
|
27
|
_echo "\tpert.sh \"1,2,3\" \"15,17,20\""
|
28
|
28
|
_echo ""
|
29
|
|
- exit 1
|
30
|
29
|
}
|
31
|
30
|
|
32
|
31
|
scale=2
|
|
@@ -54,90 +53,105 @@ function _header
|
54
|
53
|
_divider
|
55
|
54
|
}
|
56
|
55
|
|
57
|
|
-# help text
|
58
|
|
-if [ $# -eq 0 ] || [ -z "$1" ] || [[ "$1" =~ [-]*(help|h) ]]; then
|
59
|
|
- _help
|
60
|
|
-fi
|
61
|
|
-
|
62
|
|
-# main
|
63
|
|
-_header
|
64
|
|
-
|
65
|
|
-counter=0
|
66
|
|
-total_estimate=0
|
67
|
|
-total_standard_deviation=0
|
68
|
|
-total_variance=0
|
69
|
|
-for var in "$@"; do
|
|
56
|
+function pert_table
|
|
57
|
+{
|
|
58
|
+ _header
|
70
|
59
|
|
71
|
|
- # counter iterator
|
72
|
|
- counter=$[$counter +1]
|
73
|
|
-
|
74
|
|
- # split values
|
75
|
|
- IFS=',' read -ra ADDR <<< "$var"
|
|
60
|
+ counter=0
|
|
61
|
+ total_estimate=0
|
|
62
|
+ total_standard_deviation=0
|
|
63
|
+ total_variance=0
|
|
64
|
+ for var in "$@"; do
|
|
65
|
+
|
|
66
|
+ # counter iterator
|
|
67
|
+ counter=$[$counter +1]
|
76
|
68
|
|
77
|
|
- # optimistic value
|
78
|
|
- o="0"
|
79
|
|
- if [ -n "${ADDR[0]-}" ]; then
|
80
|
|
- o=${ADDR[0]}
|
81
|
|
- fi
|
|
69
|
+ # split values
|
|
70
|
+ IFS=',' read -ra ADDR <<< "$var"
|
|
71
|
+
|
|
72
|
+ # optimistic value
|
|
73
|
+ o="0"
|
|
74
|
+ if [ -n "${ADDR[0]-}" ]; then
|
|
75
|
+ o=${ADDR[0]}
|
|
76
|
+ fi
|
|
77
|
+
|
|
78
|
+ # realistic value
|
|
79
|
+ r="0"
|
|
80
|
+ if [ -n "${ADDR[1]-}" ]; then
|
|
81
|
+ r=${ADDR[1]}
|
|
82
|
+ fi
|
|
83
|
+
|
|
84
|
+ # pessimistic value
|
|
85
|
+ p="0"
|
|
86
|
+ if [ -n "${ADDR[2]-}" ]; then
|
|
87
|
+ p=${ADDR[2]}
|
|
88
|
+ fi
|
|
89
|
+
|
|
90
|
+ # check values
|
|
91
|
+ if [ -z "$o" ] || [ -z "$r" ] || [ -z "$p" ]; then
|
|
92
|
+ printf "$format" "$counter. bad input" $o $r $p
|
|
93
|
+ else
|
|
94
|
+
|
|
95
|
+ # pert estimate
|
|
96
|
+ pert_estimate=$(_calc "($o+4*$r+$p)/6")
|
|
97
|
+ total_estimate=$(_calc "$total_estimate + $pert_estimate")
|
|
98
|
+
|
|
99
|
+ # standard deviation
|
|
100
|
+ standard_deviation=$(_calc "($p-$o)/6")
|
|
101
|
+ total_standard_deviation=$(_calc "$total_standard_deviation + $standard_deviation")
|
82
|
102
|
|
83
|
|
- # realistic value
|
84
|
|
- r="0"
|
85
|
|
- if [ -n "${ADDR[1]-}" ]; then
|
86
|
|
- r=${ADDR[1]}
|
87
|
|
- fi
|
|
103
|
+ # variance
|
|
104
|
+ variance=$(_calc "$standard_deviation * $standard_deviation")
|
|
105
|
+ total_variance=$(_calc "$total_variance + $variance")
|
|
106
|
+
|
|
107
|
+ # row
|
|
108
|
+ printf "$format" "$counter. task" $o $r $p $pert_estimate $standard_deviation $variance
|
|
109
|
+ fi
|
88
|
110
|
|
89
|
|
- # pessimistic value
|
90
|
|
- p="0"
|
91
|
|
- if [ -n "${ADDR[2]-}" ]; then
|
92
|
|
- p=${ADDR[2]}
|
93
|
|
- fi
|
|
111
|
+ done
|
94
|
112
|
|
95
|
|
- # check values
|
96
|
|
- if [ -z "$o" ] || [ -z "$r" ] || [ -z "$p" ]; then
|
97
|
|
- printf "$format" "$counter. bad input" $o $r $p
|
98
|
|
- else
|
|
113
|
+ _divider
|
99
|
114
|
|
100
|
|
- # pert estimate
|
101
|
|
- pert_estimate=$(_calc "($o+4*$r+$p)/6")
|
102
|
|
- total_estimate=$(_calc "$total_estimate + $pert_estimate")
|
|
115
|
+ if [[ $total_estimate > 0 ]]; then
|
103
|
116
|
|
104
|
|
- # standard deviation
|
105
|
|
- standard_deviation=$(_calc "($p-$o)/6")
|
106
|
|
- total_standard_deviation=$(_calc "$total_standard_deviation + $standard_deviation")
|
107
|
|
-
|
108
|
|
- # variance
|
109
|
|
- variance=$(_calc "$standard_deviation * $standard_deviation")
|
110
|
|
- total_variance=$(_calc "$total_variance + $variance")
|
|
117
|
+ # footer summary
|
|
118
|
+ printf "$format" "summary" "-" "-" "-" $total_estimate $total_standard_deviation $total_variance
|
|
119
|
+ _divider
|
|
120
|
+
|
|
121
|
+ _echo ""
|
|
122
|
+ _echoB "Three point estimates"
|
|
123
|
+ _echo ""
|
|
124
|
+
|
|
125
|
+ width=42
|
|
126
|
+ tpeformat=" | %-13s |%11s |%10s |\n"
|
|
127
|
+
|
|
128
|
+ _divider
|
|
129
|
+ printf "$tpeformat" "confidence"
|
|
130
|
+ _divider
|
|
131
|
+ printf "$tpeformat" "1 Sigma - 68%" $(_calc "$total_estimate - $total_standard_deviation") $(_calc "$total_estimate + $total_standard_deviation")
|
|
132
|
+ printf "$tpeformat" "2 Sigma - 95%" $(_calc "$total_estimate - 2 * $total_standard_deviation") $(_calc "$total_estimate + 2 * $total_standard_deviation")
|
|
133
|
+ printf "$tpeformat" "3 Sigma - 99%" $(_calc "$total_estimate - 3 * $total_standard_deviation") $(_calc "$total_estimate + 3 * $total_standard_deviation")
|
|
134
|
+ _divider
|
111
|
135
|
|
112
|
|
- # row
|
113
|
|
- printf "$format" "$counter. task" $o $r $p $pert_estimate $standard_deviation $variance
|
114
|
136
|
fi
|
115
|
|
-
|
116
|
|
-done
|
117
|
|
-
|
118
|
|
-_divider
|
119
|
|
-
|
120
|
|
-if [[ $total_estimate > 0 ]]; then
|
121
|
137
|
|
122
|
|
- # footer summary
|
123
|
|
- printf "$format" "summary" "-" "-" "-" $total_estimate $total_standard_deviation $total_variance
|
124
|
|
- _divider
|
125
|
|
-
|
126
|
|
- _echo ""
|
127
|
|
- _echoB "Three point estimates"
|
128
|
138
|
_echo ""
|
129
|
|
-
|
130
|
|
- width=42
|
131
|
|
- tpeformat=" | %-13s |%11s |%10s |\n"
|
132
|
|
-
|
133
|
|
- _divider
|
134
|
|
- printf "$tpeformat" "confidence"
|
135
|
|
- _divider
|
136
|
|
- printf "$tpeformat" "1 Sigma - 68%" $(_calc "$total_estimate - $total_standard_deviation") $(_calc "$total_estimate + $total_standard_deviation")
|
137
|
|
- printf "$tpeformat" "2 Sigma - 95%" $(_calc "$total_estimate - 2 * $total_standard_deviation") $(_calc "$total_estimate + 2 * $total_standard_deviation")
|
138
|
|
- printf "$tpeformat" "3 Sigma - 99%" $(_calc "$total_estimate - 3 * $total_standard_deviation") $(_calc "$total_estimate + 3 * $total_standard_deviation")
|
139
|
|
- _divider
|
|
139
|
+}
|
|
140
|
+
|
140
|
141
|
|
|
142
|
+# main
|
|
143
|
+if [ $# -eq 0 ]; then
|
|
144
|
+ _help
|
|
145
|
+ exit 1
|
141
|
146
|
fi
|
142
|
147
|
|
143
|
|
-_echo ""
|
|
148
|
+case "$1" in
|
|
149
|
+ *help|*h)
|
|
150
|
+ _help
|
|
151
|
+ exit 1
|
|
152
|
+ ;;
|
|
153
|
+ *)
|
|
154
|
+ pert_table $@
|
|
155
|
+ exit 0
|
|
156
|
+ ;;
|
|
157
|
+esac
|