A Framework for Simulating Cyclists in SUMO

. Cyclists pose an interesting challenge in the microscopic modeling and simulation of urban traffic. Like motorists, cyclists can move on roadways, tend to have one main axis of movement (longitudinal), and cannot change their velocity instantaneously. However, like pe-destrians, cyclists are less bound by lane discipline and are often less rule-oriented than mo-torists. They flexibly adjust their lateral position within a lane, fluidly move between different types of infrastructure (bicycle lane, sidewalk, roadway), and tactically select their pathways across intersections. Their interactions with other road users are more intuitive and less defined by the lane markings. How should the behavior of such adaptable road users be modeled? In SUMO, modifications to the simulation environment enable the application of car-based models to cyclists. A driving lane is divided into multiple sub-lanes along the longitudinal axis. Lane change and car-following models can be calibrated and applied to simulate realistic bicycle and mixed traffic using this approach. However, the flexible nature of cyclists, particularly at intersections or when switching between different types of infrastructure, is difficult to simulate. A modeling framework for linking the paradigms used to simulate motor vehicle traffic (one-dimensional lane-based models) and pedestrian traffic (two-dimensional social force type models) is presented. Guidelines are used to lead each cyclist through the network while they move freely on a two-dimensional plane, their movement and interactions governed by an adapted social force model. The conceptual framework and an openly available Python package CyclistModel are introduced, and advantages and possible use cases are discussed.


Introduction
The earliest microscopic simulation tools, which emerged in the 1960's, were comprised of cars that progressed through road networks by traveling single-file along lanes, initially by hopping from one cell to the next [1]. Despite the tremendous advances in the field of traffic simulation since then, most simulation software still operate around the concept of the driving lane [2], [3]. In lane-based tools, motion is simulated using vehicle dynamics models, preference models (e.g. desired speed and acceleration), models of traffic rules and regulations and traffic signal control models. Interactions with other road users are reduced to one-dimensional, single-file following behavior, lane selection, (cooperative) lane changing, and yielding at points of conflict.
This relatively simple paradigm is very powerful for designing and evaluating road infrastructure, planning traffic signal control, developing Cooperative Intelligent Transport Systems (C-ITS), and investigating automated vehicle traffic, to name a few fields of application. Unfortunately, lane-based simulation tools are inherently bad at simulating other types of road users with different, more fluid ways of moving and interacting, such as pedestrians and cyclists.
As simulation became a more accepted tool for traffic analysis in the 1990s, approaches for simulating pedestrians emerged [1]. In contrast to motorists, pedestrian traffic is not always characterized by a common direction of travel. Pedestrians (typically) do not move single-file but rather exhibit free motion on a two-dimensional plane, changing their velocity almost instantaneously. In consideration of these major differences, a new type of model based on internal or social forces was proposed. The original social force model for pedestrian dynamics was introduced by Helbing and Molnar [4] and conceptualized the motion of a pedestrian as the result of multiple internal motivations. These internal motivations or forces include a driving force towards the (interim) destination, repulsive forces from other pedestrians, obstacles, and boundaries, as well as attractive forces to friends and points of interest. In each simulation step, an acceleration vector is calculated based on these attractive and repulsive forces that move the pedestrian through a continuous two-dimensional space. Over the 30 years since the original formulation of this model, there have been many further developments, extensions, and divergent models [5], [6]. Researchers have formulated social force models specifically for bicycle traffic [7], [8], the most notable of which is the model developed by Schönauer et al. [9]. In the Schönauer et al. model, operational behavior is modeled using an adapted social force model in which the degrees of freedom are limited based on the single-track model for car dynamics. Road users' pathways are determined using an infrastructure force field model.
Cyclists' behavior falls on a spectrum between the movement and interaction patterns of motor vehicle traffic and those of pedestrians. They can adjust their behavior along this spectrum to adapt to the current situation. At one end, cyclists ride quickly in one direction with little lateral movement while sharing a roadway with motor vehicle traffic. On the other end, cyclists move slowly and are ready to deviate from their pathways in spaces shared with many pedestrians. The SUMO user documentation indicates that there are no bicycle-specific models available and cyclists are to be simulated as 'fast pedestrians' or 'slow vehicles' [10].
Most of the extensions and further developments to microscopic traffic simulation software since the 2010s, including SUMO, have focused on the bicycle as a 'slow vehicle' option to enable the more realistic inclusion of cyclists. These extensions are also relevant for other types of road users, such as users of micromobility modes (e.g. e-kick-scooters), who are less bound by lane discipline. In SUMO, the main extension is the sub-lane model, which allows for the longitudinal division of driving lanes into multiple sub-lanes, the width of which can be defined by the user. The width of each road user relative to the width of the sub-lanes determines the number of sub-lanes occupied. In Figure 1  Although the sub-lane approach permits modeling bicycle and mixed traffic flows with much more realism than the conventional single lane approach (see example in Figure 1, left), it is still difficult to capture the inherent flexibility of cyclists and users of micromobility modes in simulations.
Why is it important to simulate the movement and interactions of cyclists realistically? First, in reaction to the persisting and worsening effects of overdependence on private motor vehicles, cities and regions are strongly promoting and building for more sustainable modes of transport, including cycling and micromobility. The number of cyclists, e-kick-scooter users, and e-moped users is increasing as a result. For example, in German metropolitan regions, the modal share of cycling increased from 9 % in 2002 to 17 % in 2017 [11]. Considering this trend and the goal of the German government to double the number of kilometers traveled by bicycle by 2030 compared to 2017 [12], the volume of bicycle traffic is expected to rise drastically in urban areas. In this future, it will no longer be defendable to develop any C-ITS, automated driving, or future technological system for urban (motor vehicle) traffic without including bicycles in the research and development process. Not only will it be (more) necessary to consider bicycles in the development of future technologies for motor vehicle traffic, but it is likely (and hoped for) that the focus of technological development will shift largely to active and micromobility. In this future scenario, research questions concerning the dimensioning and design of road infrastructure for enormously high volumes of mixed bicycle traffic, the necessity and programming of traffic signal control as well as road user safety could be investigated using microscopic traffic simulation. This will only be possible if microscopic traffic simulation tools and the underlying behavior models accurately simulate bicycle and mixed traffic flows.

Conceptual framework
A straightforward approach for establishing compatibility between the one-dimensional lanebased and the two-dimensional force-based simulation paradigms and thus enabling the more realistic simulation of non-lane-based traffic is presented in this paper. The term guideline is used to describe the intended pathways of a cyclist or other non-lane-based road user and was coined with this specific meaning in the doctoral thesis Development of tactical and operational behaviour models for bicyclists based on automated video data analysis by Heather Twaddle (now Heather Kaths). A guideline is a polyline that a road user intends to follow to reach their interim destination, congruent in form to the center of a driving (sub-)lane.
Conceptually, guidelines are the result of conscious decisions made by a cyclist or other non-lane-based road user at the tactical behavior level. At this level, road users decide how to act in order to best cope with the current situation [13]. This includes making movement and interaction plans on a time horizon of seconds to minutes under the consideration of the speed and position of nearby road users, the form and state of the road infrastructure, and the phase of traffic signals, as well as many other factors. Based on this conceptual definition, an entire route through a network is comprised of numerous successive guidelines, again congruent to the centerlines of lanes in lane-based simulation tools. Indeed, if the non-lane-based road user simulated using the proposed approach does not encounter any impedance from other road users or obstacles, they will proceed along the guideline as they would the centerline of a (sub-)lane.
So far, the congruity with the (sub-)lane-based simulation paradigm is clear. The presented model diverges from the lane-based approach in that the road user is not bound to the guideline and does not travel along the line in one-dimension. Rather the guideline is used to determine the interim destination in the next simulation step to use as input for a social forcelike behavior model. The point on the guideline closest to the front of the road user ( ) is located. Then, a point along the guideline in the direction of travel ( + 1) = ( ) + 0 is selected, where 0 is a scalar value that is at least as large as the distance that will be travelled in the next simulation step. The magnitude of 0 determines how closely the road user follows the guideline. An example of using the guideline to determine the interim destination in the next simulation step is shown in Figure 2. The model used to generate the movement and interactions of cyclists and other non-lanebased road users belongs to the family of social force models. Twaddle [14] formulated a model for cyclists' movement and interactions based on the NOMAD model for pedestrian dynamics [15], [16]. The basic formulation of the NOMAD model is: where: The desired velocity 0 is towards the desired destination of pedestrian . The velocity ( ) and the position ( ) are two-dimensional vectors at instant . The set of pedestrians in a defined vicinity of pedestrian is given by . Four pedestrian-specific parameters, the desired speed 0 , the necessary time for acceleration , the interaction factor and radius of interaction , are defined. The model was calibrated using trajectory data extracted from video data at four intersections in Munich. Guidelines were generated by clustering the observed trajectories and using the centroid trajectory of each cluster as the guideline for all the cyclists in the cluster. This is a shaky presumption, but it made it possible to calibrate the model parameters using Maximum Likelihood Estimation (MLE). More detailed information about the model specification, calibration and validation can be found in Twaddle [14].
Because the simulated cyclists and other non-lane-based road users are no longer constrained to a lane in the simulation, it is necessary to define boundaries that cannot be crossed as well as other obstacles that must be avoided. For example, if an on-road bicycle lane is shouldered by a steep curb, green strip, or roadside parking, the right side boundary of the bicycle lane must be simulated as an obstacle to prevent crossing.
Practically, the centerlines of (sub-)lanes can be extracted from a SUMO simulation using TraCI and used to act as guidelines in this approach. Alternatively, guidelines can be defined by the user based on observed motion patterns. The definition of unique guidelines is likely particularly relevant at intersections where the behavior of cyclists tends to stray most from the planned infrastructure use. A desire line analysis [17]- [19], which examines the forms of unique pathways used by cyclists to cross an intersection (or carry out any other type of maneuver) can be useful for creating guidelines.

Implementation and first results
The original model formulated based on the concept of guidelines and social force was demonstrated in SUMO using the TraCI Python interface by Twaddle [14]. Simulations of the research intersections were built in SUMO and the centroids of the trajectory clusters were extracted, smoothed, and used as guidelines as described above.
CyclistModel is an open-source Python package that uses TraCI to integrate the guideline/social force model approach in SUMO. CyclistModel is based on the original Python code developed by Twaddle [14] and can be accessed here https://github.com/HeatherAnne85/Cy-clistModel. A flowchart of the basic functionality of CyclistModel is shown in Figure 3.  Figure 4 shows an example of the same simulation of a 1.5 m wide bicycle facility with two variations in the placement of the non-crossable boundary (red line). In the simulation on the left, the bicycle facility is on the roadway and a curb prevents cyclists from deviating onto the sidewalk. As a result, cyclists move onto the roadway to carry out passing maneuvers (if traffic permits). The image on the right shows the non-crossable boundary on the left shoulder of the bicycle lane and a resulting passing maneuver using the sidewalk. Qualitatively, the presented approach enables the simulation of the higher flexibility and more fluid interactions characteristic of bicycle traffic. However, it is difficult to use standard methods for assessing validity to determine if this method is more capable of realistically simulating bicycle traffic than the sub-lane approach. Macroscopic parameters that are typically used to evaluate microscopic traffic simulations, such as average delay time, total travel time, and speed distribution, do not allow for the assessment of flexible infrastructure use (such as moving against the given direction of travel, using unintended infrastructure (such as the sidewalk) and crossing using unexpected maneuvers. Depending on the level of realism necessitated by the simulation study research question, model calibration and validation using parameters that capture behaviors characteristic of cyclists and other non-lane-based road users is necessary.
Some work has been done in this area for mixed traffic in countries where lane discipline is less strong and traffic is more heterogeneous (e.g. India, see for example [3]) that is useful for defining parameters for the calibration of mixed traffic simulations. These tend to build on car traffic-based approaches and do not account for the spatial distribution of the parameters. Twaddle [14] proposed evaluating the simulation by dividing the intersection into a grid of small cells (1.5m by 1.5m was used in the original publication, Figure 5).  [14]).
Parameters such as average, minimum and maximum speed, occupancy and density in each cell can be calculated from simulated and observed trajectories and compared. Examples of heat maps produced from trajectory data from an intersection in Munich, Germany are shown in Figure 5. The validity of the simulation model can be assessed based on the summed or averaged measure of error (e.g. RMSE) across the cells. As the aim of this paper is to introduce the concept of the guideline/social force approach, no validation is presented here.
Although CyclistModel functions as intended, it is still a very rudimentary prototype that requires a great deal of development work to become a functional tool for simulation studies.
The Python package is computationally expensive and very slow, partially because all road users in the simulation are loaded to extract interaction parameters (although interaction parameters are only calculated for road user pairs in close proximity to one another). Extensive further model developments are necessary to capture the dynamics, movements and interactions of cyclists and other non-lane-based road users in a realistic way.

Discussion and conclusion
The modeling approach presented in this paper creates a link between lane-based and social force-type models that could allow for the more realistic modeling of flexible road users in lanebased microscopic traffic simulation tools such as SUMO without altering the fundamental setup of the simulation environment. The behavior of cyclists lies on a spectrum spanning between the rule-based, longitudinally-guided motion patterns of motorists and the continuous, two-dimensional behavior of pedestrians. In reflection of this transitionary nature, the Cyclist-Model approach combines attributes of both modeling paradigms. The major advantages of this approach over the lane-based are: Here, the NOMAD social force model was applied because of the straightforward formulation and the inclusion of anisotropic and velocity anisotropic behavior. However, if social force-type models are to be applied to bicycle traffic, a great deal of observational and experimental work is needed to advance specification, calibration and validation. It could also very well be that other types of models are better able to replicate the behavior of non-lane-based road users.
Further developments and improvements to the Python package CyclistModel are needed. So far, the simulated cyclists interact with one another based on internal social forces and do not take into account traffic rules or regulations or signal control. Fundamental knowledge concerning how cyclists take these factors into account in moving through the environment, behavior models based on these findings and additional code in CyclistModel are all necessary to make the simulated cyclists behave realistically at intersections.
It could be beneficial to use both the sub-lane approach and the guideline/social force approach for modeling bicycle traffic at different locations in the same simulation. For example, cyclists traveling on a separated bicycle lane that has some degree of physical separation from both pedestrian and motor vehicle traffic could be simulated realistically using the sub-lane approach. At intersections, however, it may be necessary to switch to the guideline/social force approach to reach an acceptable level of realism. This is easily doable with CyclistModel with some small changes in the code.

Data availability statement
The data used to calibrate and validate the original version of the Cyclist Model from Twaddle [14] is available upon request at the Chair of Traffic Engineering and Control at the Technical University of Munich.

Underlying and related material
CyclistModel is an open-source Python package that uses TraCI to integrate the guide-line/social force model approach in SUMO. CyclistModel is based on the original Python code developed by Twaddle [14] and can be accessed here https://github.com/HeatherAnne85/Cyclist-Model.