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.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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=85
  24. printf "%$width.${width}s\n" "$divider"
  25. }
  26. header="\n %-12s |%11s |%10s |%12s |%9s |%9s |%9s\n"
  27. format=" %-12s |%11s |%10s |%12s |%9s |%9s |%9s\n"
  28. counter=0
  29. total_estimate=0
  30. total_standard_deviation=0
  31. total_variance=0
  32. for var in "$@"; do
  33. # counter iterator
  34. counter=$[$counter +1]
  35. # split values
  36. IFS=',' read -ra ADDR <<< "$var"
  37. # optimistic value
  38. o=${ADDR[0]}
  39. # realistic value
  40. r=${ADDR[1]}
  41. # pessimistic value
  42. p=${ADDR[2]}
  43. # header
  44. if [[ $counter = 1 ]]; then
  45. printf "$header" "#" "optimistic" "realistic" "pessimistic" "duration" "risk" "variance"
  46. _divider
  47. fi
  48. # check values
  49. if [ -z "$o" ] || [ -z "$r" ] || [ -z "$p" ]; then
  50. printf "$format" "$counter. bad input" $o $r $p
  51. else
  52. # pert estimate
  53. pert_estimate=$(_calc "($o+4*$r+$p)/6")
  54. total_estimate=$(_calc "$total_estimate + $pert_estimate")
  55. # standard deviation
  56. standard_deviation=$(_calc "($p-$o)/6")
  57. total_standard_deviation=$(_calc "$total_standard_deviation + $standard_deviation")
  58. # variance
  59. variance=$(_calc "$standard_deviation * $standard_deviation")
  60. total_variance=$(_calc "$total_variance + $variance")
  61. # row
  62. printf "$format" "$counter. task" $o $r $p $pert_estimate $standard_deviation $variance
  63. fi
  64. done
  65. if [[ $total_estimate > 0 ]]; then
  66. # footer
  67. _divider
  68. printf "$format" "summary" "-" "-" "-" $total_estimate $total_standard_deviation $total_variance
  69. #echo -e "\nThree point estimate:"
  70. fi
  71. echo -e "\n"