arzzen 9 gadus atpakaļ
revīzija
252a7147c6
1 mainītis faili ar 80 papildinājumiem un 0 dzēšanām
  1. 80
    0
      pert

+ 80
- 0
pert Parādīt failu

@@ -0,0 +1,80 @@
1
+#!/bin/bash
2
+
3
+# help text
4
+if [ -z "$1" ] || [[ "$1" =~ [-]*(help|h) ]]; then
5
+    echo -e "\nA command line PERT calculator for quick estimates."
6
+    echo -e "Comma separated task list in the form \"1,2,12 4,5,9 2,3,6\", where whitespace separates tasks.\n"
7
+    echo -e "Usage:\n\tpert [optimistic,realistic,pessimistic]\n"
8
+    exit 1
9
+fi
10
+
11
+header="\n %-12s |%11s |%10s |%12s |%9s |%7s |%9s\n"
12
+format=" %-12s |%11s |%10s |%12s |%9s |%7s |%9s\n"
13
+
14
+divider=------------------------------
15
+divider=" "$divider$divider$divider
16
+width=83
17
+
18
+scale=2
19
+counter=0
20
+total_estimate=0
21
+total_standard_deviation=0
22
+total_variance=0
23
+for var in "$@"; do
24
+    
25
+    # counter iterator
26
+    counter=$[$counter +1]
27
+ 
28
+    # split values
29
+    IFS=',' read -ra ADDR <<< "$var"
30
+    
31
+    # optimistic value
32
+    o=${ADDR[0]}
33
+    
34
+    # realistic value
35
+    r=${ADDR[1]}
36
+    
37
+    # pessimistic value
38
+    p=${ADDR[2]}
39
+    
40
+    # header
41
+    if [[ $counter = 1 ]]; then
42
+        printf "$header" "task" "optimistic" "realistic" "pessimistic" "duration" "risk" "variance"
43
+        printf "%$width.${width}s\n" "$divider"
44
+    fi
45
+    
46
+    # check values
47
+    if [ -z "$o" ] || [ -z "$r" ] || [ -z "$p" ]; then
48
+        #echo -e "\tbad input [$o,$r,$p]"
49
+        printf "$format" "$counter. bad input" $o $r $p
50
+    else
51
+    
52
+        # pert estimate
53
+        pert_estimate=$(echo "scale=$scale; ($o+4*$r+$p)/6" | bc -l | sed 's/^\./0./')
54
+        total_estimate=$(echo "scale=$scale; $total_estimate + $pert_estimate" | bc -l | sed 's/^\./0./') 
55
+        
56
+        # standard deviation
57
+        standard_deviation=$(echo "scale=$scale; ($p-$o)/6" | bc -l | sed 's/^\./0./')
58
+        total_standard_deviation=$(echo "scale=$scale; $total_standard_deviation + $standard_deviation" | bc | sed 's/^\./0./')
59
+
60
+        # variance
61
+        variance=$(echo "scale=$scale; $standard_deviation*$standard_deviation" | bc -l | sed 's/^\./0./')
62
+        total_variance=$(echo "scale=$scale; $total_variance + $variance" | bc | sed 's/^\./0./')
63
+    
64
+        # row        
65
+        printf "$format" "$counter. task" $o $r $p $pert_estimate $standard_deviation $variance
66
+    fi
67
+
68
+done
69
+
70
+if [[ $total_estimate > 0 ]]; then
71
+
72
+    # footer        
73
+    printf "%$width.${width}s\n" "$divider"
74
+    printf "$format" "summary" "-" "-" "-" $total_estimate $total_standard_deviation $total_variance
75
+    
76
+    echo -e "\nThree point estimate:"
77
+    
78
+fi
79
+
80
+echo -e "\n"

Notiek ielāde…
Atcelt
Saglabāt