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 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 [optimistic,realistic,pessimistic]"
  20. _echo ""
  21. _echoB "Example:"
  22. _echo "\tpert 1,3,4"
  23. _echo "\tpert 10,15,20 5,7,10"
  24. _echo "\tpert \"1,2,3\" \"15,17,20\""
  25. _echo ""
  26. }
  27. scale=2
  28. function _calc
  29. {
  30. _echo "scale=$scale; $@" | bc -l | sed 's/^\./0./'
  31. }
  32. width=88
  33. function _divider
  34. {
  35. divider=------------------------------
  36. divider=" +"$divider$divider$divider"+"
  37. printf "%$width.${width}s+\n" "$divider"
  38. }
  39. readonly format=" | %-12s |%11s |%10s |%12s |%9s |%9s |%9s |\n"
  40. function _header
  41. {
  42. _echo ""
  43. _echoB "Tasks"
  44. _echo ""
  45. _divider
  46. printf "$format" "#" "optimistic" "realistic" "pessimistic" "duration" "risk" "variance"
  47. _divider
  48. }
  49. function pert_table
  50. {
  51. _header
  52. counter=0
  53. total_estimate=0
  54. total_standard_deviation=0
  55. total_variance=0
  56. for var in "$@"; do
  57. # counter iterator
  58. counter=$[$counter +1]
  59. # split values
  60. IFS=',' read -ra ADDR <<< "$var"
  61. # optimistic value
  62. o="0"
  63. if [ -n "${ADDR[0]-}" ]; then
  64. o=${ADDR[0]}
  65. fi
  66. # realistic value
  67. r="0"
  68. if [ -n "${ADDR[1]-}" ]; then
  69. r=${ADDR[1]}
  70. fi
  71. # pessimistic value
  72. p="0"
  73. if [ -n "${ADDR[2]-}" ]; then
  74. p=${ADDR[2]}
  75. fi
  76. # check values
  77. if [ -z "$o" ] || [ -z "$r" ] || [ -z "$p" ]; then
  78. printf "$format" "$counter. bad input" $o $r $p
  79. else
  80. # pert estimate
  81. pert_estimate=$(_calc "($o+4*$r+$p)/6")
  82. total_estimate=$(_calc "$total_estimate + $pert_estimate")
  83. # standard deviation
  84. standard_deviation=$(_calc "($p-$o)/6")
  85. total_standard_deviation=$(_calc "$total_standard_deviation + $standard_deviation")
  86. # variance
  87. variance=$(_calc "$standard_deviation * $standard_deviation")
  88. total_variance=$(_calc "$total_variance + $variance")
  89. # row
  90. printf "$format" "$counter. task" $o $r $p $pert_estimate $standard_deviation $variance
  91. fi
  92. done
  93. _divider
  94. if [[ $total_estimate > 0 ]]; then
  95. # footer summary
  96. printf "$format" "summary" "-" "-" "-" $total_estimate $total_standard_deviation $total_variance
  97. _divider
  98. _echo ""
  99. _echoB "Three point estimates"
  100. _echo ""
  101. width=42
  102. tpeformat=" | %-13s |%11s |%10s |\n"
  103. _divider
  104. printf "$tpeformat" "confidence"
  105. _divider
  106. printf "$tpeformat" "1 Sigma - 68%" $(_calc "$total_estimate - $total_standard_deviation") $(_calc "$total_estimate + $total_standard_deviation")
  107. printf "$tpeformat" "2 Sigma - 95%" $(_calc "$total_estimate - 2 * $total_standard_deviation") $(_calc "$total_estimate + 2 * $total_standard_deviation")
  108. printf "$tpeformat" "3 Sigma - 99%" $(_calc "$total_estimate - 3 * $total_standard_deviation") $(_calc "$total_estimate + 3 * $total_standard_deviation")
  109. _divider
  110. fi
  111. _echo ""
  112. }
  113. # main
  114. if [ $# -eq 0 ]; then
  115. _help
  116. exit 1
  117. fi
  118. case "$1" in
  119. *help|*h)
  120. _help
  121. exit 1
  122. ;;
  123. *)
  124. pert_table $@
  125. exit 0
  126. ;;
  127. esac