PERT est une méthodologie de gestion de projet. Il s'agit d'un fork du programme bash qui permet d'afficher les tâches et les prévisions individuels et cumulés : https://github.com/arzzen/pert
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pert.sh 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/bin/bash
  2. set -o nounset
  3. set -o errexit
  4. function _echo
  5. {
  6. echo -e "$1"
  7. }
  8. function _echoB
  9. {
  10. _echo "\033[1m$1\033[0m"
  11. }
  12. function _help
  13. {
  14. _echo ""
  15. _echoB "A command line PERT calculator for quick estimates."
  16. _echo "Comma separated task list in the form \"1,2,12 4,5,9 2,3,6\", where whitespace separates tasks."
  17. _echo ""
  18. _echoB "Usage:"
  19. _echo "\tpert.sh [optimistic,realistic,pessimistic]"
  20. _echo ""
  21. _echoB "Example:"
  22. _echo "\tpert.sh 1,3,4"
  23. _echo "\tpert.sh 10,15,20 5,7,10"
  24. _echo "\tpert.sh \"1,2,3\" \"15,17,20\""
  25. _echo ""
  26. exit 1
  27. }
  28. scale=2
  29. function _calc
  30. {
  31. _echo "scale=$scale; $@" | bc -l | sed 's/^\./0./'
  32. }
  33. width=88
  34. function _divider
  35. {
  36. divider=------------------------------
  37. divider=" +"$divider$divider$divider"+"
  38. printf "%$width.${width}s+\n" "$divider"
  39. }
  40. readonly format=" | %-12s |%11s |%10s |%12s |%9s |%9s |%9s |\n"
  41. function _header
  42. {
  43. _echo ""
  44. _echoB "Tasks"
  45. _echo ""
  46. _divider
  47. printf "$format" "#" "optimistic" "realistic" "pessimistic" "duration" "risk" "variance"
  48. _divider
  49. }
  50. # help text
  51. if [ $# -eq 0 ] || [ -z "$1" ] || [[ "$1" =~ [-]*(help|h) ]]; then
  52. _help
  53. fi
  54. # main
  55. _header
  56. counter=0
  57. total_estimate=0
  58. total_standard_deviation=0
  59. total_variance=0
  60. for var in "$@"; do
  61. # counter iterator
  62. counter=$[$counter +1]
  63. # split values
  64. IFS=',' read -ra ADDR <<< "$var"
  65. # optimistic value
  66. o="0"
  67. if [ -n "${ADDR[0]-}" ]; then
  68. o=${ADDR[0]}
  69. fi
  70. # realistic value
  71. r="0"
  72. if [ -n "${ADDR[1]-}" ]; then
  73. r=${ADDR[1]}
  74. fi
  75. # pessimistic value
  76. p="0"
  77. if [ -n "${ADDR[2]-}" ]; then
  78. p=${ADDR[2]}
  79. fi
  80. # check values
  81. if [ -z "$o" ] || [ -z "$r" ] || [ -z "$p" ]; then
  82. printf "$format" "$counter. bad input" $o $r $p
  83. else
  84. # pert estimate
  85. pert_estimate=$(_calc "($o+4*$r+$p)/6")
  86. total_estimate=$(_calc "$total_estimate + $pert_estimate")
  87. # standard deviation
  88. standard_deviation=$(_calc "($p-$o)/6")
  89. total_standard_deviation=$(_calc "$total_standard_deviation + $standard_deviation")
  90. # variance
  91. variance=$(_calc "$standard_deviation * $standard_deviation")
  92. total_variance=$(_calc "$total_variance + $variance")
  93. # row
  94. printf "$format" "$counter. task" $o $r $p $pert_estimate $standard_deviation $variance
  95. fi
  96. done
  97. _divider
  98. if [[ $total_estimate > 0 ]]; then
  99. # footer summary
  100. printf "$format" "summary" "-" "-" "-" $total_estimate $total_standard_deviation $total_variance
  101. _divider
  102. _echo ""
  103. _echoB "Three point estimates"
  104. _echo ""
  105. width=42
  106. tpeformat=" | %-13s |%11s |%10s |\n"
  107. _divider
  108. printf "$tpeformat" "confidence"
  109. _divider
  110. printf "$tpeformat" "1 Sigma - 68%" $(_calc "$total_estimate - $total_standard_deviation") $(_calc "$total_estimate + $total_standard_deviation")
  111. printf "$tpeformat" "2 Sigma - 95%" $(_calc "$total_estimate - 2 * $total_standard_deviation") $(_calc "$total_estimate + 2 * $total_standard_deviation")
  112. printf "$tpeformat" "3 Sigma - 99%" $(_calc "$total_estimate - 3 * $total_standard_deviation") $(_calc "$total_estimate + 3 * $total_standard_deviation")
  113. _divider
  114. fi
  115. _echo ""