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.

59 lines
2.7 KiB

  1. mdp
  2. const int lanes = 5; // Counting the sidewalks as lanes
  3. const int streetLength = 20;
  4. const int maxVelocity = 3;
  5. const int minVelocity = 1;
  6. const int carLaneInit = 2;
  7. const double probFalling = 2/9;
  8. global move : [0..1] init 0; // 0: car 1: pedestrian
  9. formula ped_at_edge = ped_street_pos = 1 | ped_street_pos = streetLength;
  10. formula car_at_end = car_street_pos = streetLength;
  11. // check ped within [car_pos-velocity..car_pos], same lane
  12. formula crash_straight = (car_lane_pos=ped_lane_pos & ped_street_pos>=car_street_pos-velocity & ped_street_pos<=car_street_pos);
  13. // check ped street pos within [car_street_pos-velocity..car_street_pos], ped lane pos within [car_lane_pos-1..car_lane_pos]
  14. formula crash_left = (switched_left & ped_lane_pos>=car_lane_pos-1 & ped_lane_pos<=car_lane_pos & ped_street_pos>=car_street_pos-velocity & ped_street_pos<=car_street_pos);
  15. // check ped street pos within [car_street_pos-velocity..car_street_pos], ped lane pos within [car_lane_pos+1..car_lane_pos]
  16. formula crash_right = (switched_right & ped_lane_pos>=car_lane_pos+1 & ped_lane_pos<=car_lane_pos & ped_street_pos>=car_street_pos-velocity & ped_street_pos<=car_street_pos);
  17. label "crashed" = crash_straight | crash_left | crash_right;
  18. label "maxedOut" = velocity=maxVelocity;
  19. label "pedCrossed" = ped_lane_pos=lanes;
  20. module car
  21. switched_right : bool init false;
  22. switched_left : bool init false;
  23. car_street_pos : [0..streetLength] init 0;
  24. car_lane_pos : [2..lanes-1] init carLaneInit;
  25. velocity : [minVelocity..maxVelocity] init minVelocity;
  26. // TODO
  27. endmodule
  28. module pedestrian
  29. ped_street_pos : [0..streetLength] init floor(streetLength/4);
  30. ped_lane_pos : [1..lanes] init 1;
  31. fell_down : [0..2] init 0; // 1-2: getting up
  32. [move] move=1 & fell_down=0 -> ((1-probFalling)/4): (ped_lane_pos'=min(lanes,ped_lane_pos+1)) & (move'=0) +
  33. ((1-probFalling)/4): (ped_lane_pos'=max(1,ped_lane_pos-1)) & (move'=0) +
  34. ((1-probFalling)/4): (ped_street_pos'=min(lanes,ped_street_pos+1)) & (move'=0) +
  35. ((1-probFalling)/4): (ped_street_pos'=max(1,ped_street_pos-1)) & (move'=0) +
  36. (probFalling/4): (ped_lane_pos'=min(lanes,ped_lane_pos+1)) & (fell_down'=2) & (move'=0) +
  37. (probFalling/4): (ped_lane_pos'=max(1,ped_lane_pos-1)) & (fell_down'=2) & (move'=0) +
  38. (probFalling/4): (ped_street_pos'=min(lanes,ped_street_pos+1)) & (fell_down'=2) & (move'=0) +
  39. (probFalling/4): (ped_street_pos'=max(1,ped_street_pos-1)) & (fell_down'=2) & (move'=0);
  40. [getUp] move=1 & fell_down>0 -> 1: (fell_down'=fell_down-1) & (move'=0);
  41. endmodule