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.

49 lines
937 B

  1. function lotkavolterra() {
  2. int goats := 100;
  3. int tigers := 4;
  4. int dwellTime := 0;
  5. int curTime := 0;
  6. int b := 0;
  7. while(tigers > 0 & goats > 0) {
  8. dwellTime := 0;
  9. b := 1;
  10. if(goats > 0 & tigers > 0) {
  11. // geometric distribution with p = 0.5
  12. while (b >= 1) {
  13. {b := 1;} [0.5] {b := 0;}
  14. dwellTime := dwellTime + 1;
  15. }
  16. curTime := curTime + dwellTime;
  17. {tigers := tigers + 1;} [0.2] {{goats := goats - 1;} [0.1] {tigers := tigers - 1;}}
  18. } else { if(goats > 0) {
  19. // geometric distribution with p = 0.5
  20. while (b >= 1) {
  21. {b := 1;} [0.5] {b := 0;}
  22. dwellTime := dwellTime + 1;
  23. }
  24. curTime := curTime + dwellTime;
  25. goats := goats + 1;
  26. } else { if(tigers > 0) {
  27. // geometric distribution with p = 0.5
  28. while (b >= 1) {
  29. {b := 1;} [0.5] {b := 0;}
  30. dwellTime := dwellTime + 1;
  31. }
  32. curTime := curTime + dwellTime;
  33. tigers := tigers - 1;
  34. } } }
  35. }
  36. }