Model of simple traffic simulation [closed]

I want to write a simple traffic simulation with one road intersection. First I thought of a cellular automata in the model but it should not be limited by an underlying discrete grid system so the streets could be more independent to location or levels. Currently I can think of three approaches and I would like to get your thoughts on it.

  1. Street as Entity
    An agent is part of this entity when it’s driving on it.

  2. Intersection (or Endpoint) as Entity
    An agent drives from endpoint A to B.

  3. Intersection and Street as Entity
    Merged Point 1 and 2 in one system.

This reminds me somehow about the benefit of a Moore vs Mealy machine (States vs. Transition). What do you think would be the best representation to go with. As mentioned, the entire system should be not just limited by discrete values because I would like to animate the transition of the agent from street A to B. Any ideas appreciated.

3

Just some thoughts.

(Mandatory disclaimer: use of the information for purposes other than strictly personal use or entertainment, or use for purposes that may harm safety or cause loss of assets or life, is strictly forbidden.)


Since I’m not certain about what you mean by “entity”, I will just list the properties (model and behavior) a person (who can code) would naturally expect from these road structures and vehicles.

Streets, a bundle of lanes

  • Streets can be one-line, multi-lane, single-direction or bi-direction.
  • For simplicity, let’s discount lane-changing behaviors and all sources of obstructions:
    • Entering of vehicle from a lot into a lane.
    • Exiting of a vehicle from a lane into a lot.
    • Lane-changing in general.
      • Multiple vehicles are allowed to enter one street in one direction, being initially assigned a lane number from 1 to N.
      • Upon exiting from the other end of the street, these vehicles can be found to have magically switched lane assignments.
      • For simplicity, the simulation will not look into how that happened.
    • Lane-passing.
    • Parking on the curb, and the occasional slight traffic obstruction it causes.
    • Jaywalking pedestrians

Lane, a one-dimensional position on a curve.

  • Mathematically speaking, the (traversal) position of a vehicle on a lane is a real number between 0 and x, where x is the physical arc-length of the lane (one stretch of a street).
  • While a vehicle is on a lane, it will have an instantaneous velocity, and also an acceleration/deceleration (rate of change of velocity).
    • For simplicity, let’s discount rotational mechanics, torque, turning radius, or rollover (accident).
    • The simulation will treat all lane traversals as strictly linear motion as far as the physics is concerned.

Intersection, a complicated Venn diagram of exclusive zones

  • Even with the most simplistic simulation, we must agree that we can’t let north-south and east-west traffic flowing at the same time. If it is so, it would not be an at-grade intersection; it would be an overpass or underpass.
  • Below we make the typical assumption of a four-way intersection, i.e. having four ingress (incoming) and four egress (leaving) directions.
  • 4 x 4 makes 16 possible vehicle trajectories. (This includes U-turns.)
  • By using pen-and-paper, one can work out the exclusion rules that allow different combinations of these trajectories to be used at different traffic signals.
  • A vehicle entering the intersection will have a velocity
  • Each trajectory takes a certain amount of time to traverse given a velocity. Work backwards and one can get a fake “length” value.
    • It is common knowledge that a vehicle must slow down upon entering an intersection and return to normal speed upon exiting, but for sake of simplicity it will be omitted from simulation.

How do I run a simulation, with many agents, with time, and with many different lengths and velocities?

Two ideas come to my mind.

  • Finite, fixed time-steps. Say, by the second.

    • At the current timestamp, calculate where each vehicle will be (position, velocity and acceleration/deceleration), and what the vehicle’s steering and gas pedal behaviors will be (based on each agent’s received stimuli)
  • Event-based time simulation.

    • For each agent, one would forecast the next future timestamp at which one has to re-examine the agent’s whereabouts and responses. Store this future timestamp (“event”) in a priority queue.
    • After forecasting future events from all agents, the agent with the nearest timestamp will be processed. The vehicles surrounding the agent will also have their status updated. If all calculations work out to be correct (no conflicts), the global simulation timestamp is updated, and the next future timestamp will be picked from the queue and processed.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật