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

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