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

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