Automatic fitting procedure for the fundamental diagram

ABSTRACT The fundamental diagram of a road, including free-flow capacity and queue discharge rate, is very important for traffic engineering purposes. In the real word, most traffic measurements come from stationary loop detectors. This paper proposes a method to fit Wu's fundamental diagram to loop detector data. Wu's fundamental diagram is characterised by five parameters, being free-flow speed, wave speed, free-flow capacity, queue discharge rate and jam density. The proposed method entails fixing the wave speed and the free-flow speed. The method consists of two steps. We first use a triangular fundamental diagram to separate the congested branch from the free-flow branch. Then, the remaining three parameters of Wu's fundamental diagram are fitted on each branch using a least-square fit. This method is shown to be robust for cases tested in real life, and hence very noisy, data.


Introduction
In traffic flow theory the fundamental diagram is an essential concept. The fundamental diagram relates two of the three variables average speed (v), flow (q) and density (k) to each other. If two of these variables are known, the third can be derived using the relation q = kv. Therefore, if only one variable is known, and the fundamental diagram is known, the traffic state (i.e. combination of speed, density and flow) can be determined. If flow is given, one needs additional information on the branch (free flow or congestion, since two traffic states lead to the same flow).
Since Greenshields (1934) showed the relation between speed and density, many theories have been developed to work with the fundamental diagram, including the often used LWR model (Lighthill and Whitham 1955;Richards 1956).
Although many papers have been written on the shape of the fundamental diagram (see Section 2.1), it is remarkable how much spread is present if one plots observed flows versus observed densities. This spread can have different causes, for instance: (1) The traffic is not stationary during the aggregation interval.
(2) The traffic itself is heterogeneous.
(3) There are detector failures, or other measurement errors.
(4) Intrinsic measurement errors occur, for instance loops do not detect vehicles standing still (speed 0 km/h). (5) Within the aggregation interval an integer number of vehicles is measured. (6) The speed is calculated as time mean speed instead of space mean speed.
Although solutions have been found for several of these problems, often traffic engineers still use loop detector data from freeways, with the above-mentioned problems. If they want to apply theoretical concepts, such as shock wave theory or the method of characteristics, they need to have a fundamental diagram. The parameters of the fundamental diagram should be calibrated for the observed road, as each road has its own characteristics, leading to a unique fundamental diagram.
Traffic control measures, such as ramp metering  or main lane metering (Carlson et al. 2010) are exploiting the capacity drop, i.e. the difference between free-flow capacity and the queue discharge rate. In order to find the correct settings for these measures, it is required to find a reliable value for both values. For consistency of the results and calculation speed (if various locations are involved), an automatic fitting procedure is useful. However, due to errors in the data automatic fitting procedures often lead to extreme values for capacity or jam density, as will be shown later in this paper. This paper presents a method which can be applied in an automated way, preventing extreme values on noisy data -a property we will call robustness in the remainder of the paper. The key of the method proposed here (explained in more detail in Section 4) is that first a triangular fundamental diagram is fitted to find the critical density, used to separate the free-flow and the congested branches. Then, a more realistic fundamental diagram is fitted on the congested data and the free-flow data separately. Variables which are known are fixed, thereby improving the robustness of the fit.
This paper first gives an overview of the literature on the fundamental diagram and the fitting procedures. Then, the experimental setup is introduced, showing the different choices in the research approach. This setup also includes the simulation setup and a description of the empirical data used to test the methodology. Then, the methodology is introduced and the simulation results are discussed, followed by a section presenting the fitting results on empirical data. Finally, we discuss the results and present the conclusions.

Literature review
This section first describes the general shapes of the flow-density relationship, followed by a detailed discussion of the shape proposed by Wu. Then, the existing literature of fitting a functional form to this relationship is discussed.

Shapes of the fundamental diagram
Many shapes have been proposed for the fundamental diagram, ranging from very simple functions to functions with mathematically useful properties, functions including the microscopic traffic characteristics or relations based on empirical findings. Greenshields (1934) was the first to observe traffic flows and to hypothesize a linear relationship between speed and density. Applying the relation the linear relation between speed v and density k corresponds to a parabolic relation between speed v and flow q. The fundamental diagram defines a number of characteristics of the traffic flow. First of all, it determines the capacity, or the maximum flow that can be maintained for a short period of time.
The corresponding density is the so-called critical density. This capacity distinguishes two states or regimes: for densities lower than the critical density, traffic is in an uncongested state, while for higher densities, traffic is in a congested state. The Greenshields fundamental diagram is called a univariate model, since both the uncongested regime and the congested regime are described using the same formula. Another well-known univariate model is Drake's model (Drake, Schöfer, and May 1967), where the speed is an exponentially decreasing function of the density. Two-variate models use distinct formulas to describe the congested and the uncongested regime. The simplest two-variate model is a triangular fundamental diagram, that describes both regimes with a linear relationship. The slope of the uncongested regime is equal to the free-flow speed, while the slope of the congested regime equals the shock wave speed (describing the speed with which the congestion front is moving upstream). The latter shows a direct relation between the fundamental diagram and shockwave theory (Lighthill and Whitham 1955). Daganzo (1997) introduced the truncated triangular fundamental diagram. Here, the capacity is not only reached at the critical density, but for a certain range of densities the flow is constant, and maximal. Edie (1965) was among the first researchers to show that a discontinuous relation might be more appropriate to describe traffic dynamics. He distinguished the regime of the free traffic, with the socalled free-flow capacity as maximum flow, and the congested traffic, having the so-called queue discharge rate as maximum flow. As the curve is discontinuous, free-flow capacity is higher than the queue discharge rate. This is called the capacity drop (Hall and Agyemang-Duah 1991;Banks 2002). Koshi, Iwasaki, and Ohkura (1981) introduced an inverse lambda shaped fundamental diagram, which included this capacity drop. In this diagram, traffic has a free-flow speed up to a capacity point. However, the congested branch does not start at capacity, but connects below the capacity point to the free-flow branch. An addition to the inverse lambda shaped fundamental diagram is made by Wu (2002). He assumes that the speed in the free-flow branch is not constant, but decreasing with increasing density. The shape of the free-flow branch is determined by the overtaking opportunities, which depend on the number of lanes. Figure 1 visualises the density-flow and density-speed diagram mentioned above. Kerner (2004) proposed a different traffic flow theory, the so-called three phase traffic flow theory. Instead of distinguishing an uncongested regime and a congested regime, Kerner describes three phases of traffic. In addition to the uncongested regime, the congested regime has been split into two distinct phases: synchronised flow and wide moving jam. In a wide moving jam, traffic stands still and the wave moves upstream (similar to stop-and-go waves); in synchronised flow, the traffic is moving. Contrary to other researchers, Kerner claims that in this state several equilibrium distances exist for the same speed, leading to an area rather than a line in the flow-density plane. So far, the described fundamental diagrams are all deterministic. Recent research (Wang et al. 2013) has tried to explicitly include stochastic aspects in the fundamental diagram.
Each of the fundamental diagrams mentioned above has its advantages and disadvantages. The existence of a capacity drop requires the fundamental diagram to have at least two regimes: a freeflow regime and a congested regime. Besides, we would like to have the option of a speed decrease in the free-flow branch, implying a nonlinear free-flow branch. Taking these two requirements as a starting point, we have chosen to fit Wu's fundamental diagram to our data. Although we test our estimation method for Wu's fundamental diagram, the problems that arise are similar for many shapes of the fundamental diagram, especially if the free-flow branch and the congested branch are fitted

Wu's fundamental diagram
The fundamental diagram by Wu (2002) is based on overtaking possibilities. Those differ for roads with a variable number of lanes. Wu (2002) defines a fundamental diagram by prescribing the speed as function of density. He argues that the speed changes gradually from the free-flow speed v free to the critical speed v crit . The way it decreases depends on the number of lanes, N. In an equation, this gives ( 2 ) Multiplying both sides with the density gives the relation between the flow (speed times flow is density, see Equation (1)) and the density. For the congested branch, Wu proposes a straight line in the flow-density relationship, starting at a lower flow than the free flow, hence incorporating a capacity drop. It can be easily verified that these equations can be rewritten, and different parameters can be chosen to represent the same shape. For this paper, we rewrote the equations such that the parameters of the fundamental diagram were as meaningful as possible. Note that rewriting the equations or changing variables does not change the relationship, nor the parameter values. Table 1 shows the variables and their default values being used for this paper.

Fitting a fundamental diagram to data
To fit a fundamental diagram, data have to be collected, from a certain interval in time and an interval in space. The resulting data of individual vehicles have to be aggregated into intervals. To this end, Edie's generalised definitions can be used (Edie 1965). Generally, they describe how to aggregate observations in an area in space-time into a flow, density and speed. This can be computed as follows.
The total distance D travelled by all vehicles and the total time spent in the area T is calculated; the area of observation has a size of A (in units of space-time). The flow and density then are calculated by q = D/A and k = T/A. The speed is defined as v = q/k. It is possible that the measuring intervals have zero length in one dimension, being an instantaneous measurement (an aerial photograph), or a local measurement (e.g. via loops at a certain location). Especially the local measurements are often used, where traffic data are collected by loops. Edie's definitions then suggest that the flow is the number of passing vehicles divided by the aggregation period, and the average speed is the harmonic mean of the speed of the passing vehicles. This can be seen from the following. Suppose we have I vehicles (labelled i) passing the measurement location with a speed v i . Let us consider an area in space-time, with length λ and time interval τ . The area hence is A = λτ . The total distance covered is D = i λ = Iλ; the total time spent is In this equation, the bar indicates the mean. Note that the speed is the harmonic mean of the speeds of the individual vehicles, i.e. the inverse of the mean of the inverse of the speeds. This speed differs from the (arithmetic) mean of the speeds (also called time mean speeds) observed in an aggregation period. Unfortunately, the speed data provided is often in the form of arithmetic mean speeds. Using this method will cause a bias in the speeds (time mean speeds are too high), and a bias in the density (the computed densities are too low), especially for higher densities -see Knoop, Hoogendoorn, and Van Zuylen (2007) for an explanation and a comparison of real data. This paper explicitly investigates how a fundamental diagram could be fitted if these time mean speed data are used. More researchers discuss which data to use for such an estimation. Typically, fundamental diagrams are estimated from aggregated data at a specific location (Cassidy 1998;Kockelman 1998). Depending on the type of detectors used to derive these data, occupancy or densities are observed. In addition, speeds can be averaged over time or harmonically averaged. One of the drawbacks is the existence of transient phases, which are difficult to distinguish from equilibrium phases. Only the latter should be used to derive the fundamental diagram, as this describes traffic in an equilibrium state. When using the fundamental diagram to predict how traffic states propagate (both in time and in space), the estimation should be based on spatial measurements (in accordance to Edie's definition of equilibrium). As detectors only collect data at a single cross-section, probe vehicles can be used (Neumann, Bohnke, and Touko Tcheumadjeu 2013). Chiabaut, Buisson, and Leclercq (2009) use the passing rate to estimate a fundamental diagram, as this is independent of the traffic flow state. Using NGsim data, they prove that a linear fundamental diagram can be used to describe the traffic and that both the congested wave speed and the jam density can be accurately predicted.
Although the shape of the fundamental diagram is well discussed, not much literature can be found on how to estimate a fundamental diagram. If shapes are fitted, this is usually done in manual way, in which case errors can be avoided. The only automated procedure that the authors are aware of is described in the paper by Dervisoglu et al. (2009). They first fit the free-flow speed for all data points for which a speed of more than 55 mph is reported. Then, the capacity is found as the highest flow, and the matching critical density as the capacity divided by the free-flow speed. Finally, the congested branch is found by a linear regression of the points of which the speed lies under 55 mph. The main drawback of the method proposed is that it does not account for time mean speeds. Besides, the queue discharge rate is determined as function of a time series, which cannot be measured at all locations; note that the differences in queue discharge rates as function of space as mentioned in Dervisoglu et al. (2009) can be caused by the spatiodynamic effects (temporal overloading of traffic before congestion sets back), as pointed out by Kim and Coifman (2013).
Although literature clearly has shown drawbacks of detector data, this is the type of data typically available. Therefore, we have developed a method to estimate the fundamental diagram based on detector data.

Experimental setup
This section introduces the different parameters to be fit and which combinations of these parameters we compare. The methodology is assessed by simulation. The setup for the simulation is elaborated upon, and some details are given on the empirical data we use for evaluation.

Influencing elements in fitting a fundamental diagram
In the process of fitting the fundamental diagram several aspects play a role. We can fix parameters, that is, not all parameter values need to be estimated. Also, different speed averages might lead to different results. Moreover, the stochasticity of real traffic might be different from a traffic simulation. This section comments on these variables. while in the next section it is indicated which combinations are tested.

Fixing parameters
Fixing one or more parameters will increase the robustness of a fit, simply because one can set the parameter to a value which must be approximately right. Thereby, it is avoided that a variable is set to an extreme value because another variable is wrong.
Wu's fundamental diagram has five parameters, of which two are the capacities which are to be estimated. The remaining three are the free-flow speed, the wave speed and the jam density. The jam density is most constant, and can be determined by other methods as well (e.g. Leclercq 2005;Chiabaut, Buisson, and Leclercq 2009). Also the free-flow speed can relatively easy be estimated based on the speed limit. The jam density is more difficult to estimate on beforehand, so this will not be considered in the tests here. Fixed wave speed and/or free-flow speed will be considered.

Type of data in relation to speed averaging
Some of the problems in determining the fundamental diagram are caused by the fact that the reported mean speeds are time mean speeds. For the density calculation by k = q/v (Equation (1)), one needs the space mean speed, or as approximation the harmonically averaged speed. Figure 2(a) shows the differences of the different density calculations based on simulation data. Still, high density areas hardly occur, but the congested conditions are better represented in the diagram. This has to do with the fact that the congested states are more affected by the speed averaging procedure (Knoop, Hoogendoorn, and Van Zuylen 2007). In this paper we will look at the consequences of using detector data or Edie's definitions based on the full trajectories.
Another cause of problems in determining the fundamental diagram is the fact that the measurements are taken at one location. From the simulation, the full trajectories are known. That means that we can apply Edie's definitions (Edie 1965). In particular, we divide the road into segments of 100 metres and consider time intervals of 10s, leading to an area in space and time A = 100 * 10 = 1000 ms. The combinations of flow and density based on Edie's definitions are shown in Figure 2(b). Note that the effect of single-loop detectors compared to double loop detectors has been discussed by Coifman and Neelisetty (2014).

Real-world data or simulation data
In the paper, first the method is applied to simulation data. The advantage of using data from a microscopic simulation program is that the ground truth (i.e. the underlying fundamental diagram) is known, and there are no measurement errors. Moreover, all type of data (time mean speeds, harmonically mean speeds, Edie's generalised density using trajectories) can be obtained from the simulation. Applying the proposed algorithm to simulation shows how accurate the estimation results are compared to the ground truth, and it shows the effect of aggregation and speed averaging. This will give the theoretical insights of measuring principles. The disadvantage is that the situation is not completely realistic, but it will still provide the insights.  Then, the same method is applied to real-world data, which has all properties one expects in traffic: multi-lane (and hence lane changing), multi-class, differences in speed and spacing between the vehicles. This will show the real-world applicability of the proposed method.

Analyses
The section above indicated several combinations of influencing elements in the fitting procedure. Not all combinations are tested in this paper. Table 2 shows the analyses we chose for this paper.
The selection we made is based on a combination of simulation data and real data, but the emphasis is on simulation data. The main reason is that the ground truth (theoretical fundamental diagram) is known for these simulation data. Moreover, we can get arithmetic mean speeds and harmonic mean speeds at (virtual) detectors as well as Edie's data from the trajectories. So, in short, all information is available to perform extensive tests on the proposed method.
As said, fixing parameters might increase the robustness of the fitting results, so we will consider fixing the free-flow speed and/or the wave speed. As it will turn out, especially fitting the congested part is difficult, particularly if only the arithmetic mean speed is known. Therefore, for real data only fixed wave speed is considered.

Simulation
In this section we discuss the simulation model and the setup of the simulation.

Simulation program
The methodology is tested using simulation data. The advantage of traffic simulation is that the ground truth is known (see Figure 4(a)), although lane changing effects are not taken into account. To generate simulation data we use FOSIM (Dijker and Knoppers 2006) -for a screenshot, see Figure 3. FOSIM is the only simulation model that has been validated for Dutch freeways, and it is used by the Dutch road authority for ex-ante capacity assessments of new infrastructure (de Leeuw and Dijker 2000).
FOSIM implements a Wiedeman principle (Wiedemann 1974) in the car-following model. The equilibrium spacing drivers prefer is a quadratic function of their speed: FOSIM implements by default two user classes: passenger cars and Heavy Good Vehicles. For passenger cars, three different types of drivers are distinguished: aggressive drivers, more timid drivers and drivers driving vans. For each of these driver-vehicle combinations, input parameters are determined (see the screenshot in Figure 3(a)).

Simulation setup
For the sake of simplicity and traceability, we only consider a homogeneous flow of timid drivers in passenger cars in the simulation. We have used the default (validated) parameters for this vehicle class. For our driver population, this means that the parameter values for z 1 , z 2 , and z 3 are, respectively, 3 m, 0.72 s and 0.0050 s 2 /m. This, together with the vehicle length of 4 m gives the speed spacing diagram, which can be translated into a flow-density diagram (see Figure 4(a)). Note that this theoretical calculation does not take stochasticity into account. The resulting capacity from this relationship seems to be rather high, at a value of approximately 3275 veh/h/lane, equalling a headway of 1.1s. This is the theoretical capacity in case all vehicles are following (in both lanes). These flow values are being observed in the Netherlands for passenger cars only in the left lane. For instance, on the A4 section between The Hague and Leiden (see the section on fitting results on empirical data) we find a maximum flow in the left lane of 56 vehicles in one minute, equalling 3360 veh/h. The authors find these values in one minute in one lane more often. Note however, that these values cannot be maintained over all lanes and only if many drivers are following, which is generally not the case, not even in periods of high demand. Note that although FOSIM is a validated tool for the Dutch freeways, the current setup (one lane, one vehicle class) falls outside the validity range. The results might hence not be representative for Dutch traffic. However, the results can still be used to get theoretical insights. It should furthermore be noted that with no lane changes taking place, vehicles may even drive in platoons, and thus they are not in the homogeneous state which would lead to the fundamental diagram as shown in Figure 4(a).
The case study we consider for estimating the fundamental diagram is as simple as possible. We consider a two lane freeway with an onramp, see Figure 3(b). The top of this figure shows the demands, both for the main road (origin 2), and for the onramp (origin 1). With these demands the capacity of the road is temporarily exceeded. First, a stop-and-go wave is created by increasing the flow on the main road, where the head of the congestion is just downstream of the end of the onramp. Secondly, bottleneck congestion is created by a higher inflow from the ramp and a lower inflow from the main road.
We have collected speeds, flows and density at detectors, located 250 m apart, see the yellow boxes in Figure 3(b). As these detectors observe passing moments of vehicles per lane, only data from the two main lanes are used for the estimation of the fundamental diagram. As merging occurs at the merging lane, causing disturbance of the process, we have excluded detectors 6 and 7.
In FOSIM, simulations often lead to congestion where vehicles come to a complete stop. Also, passenger cars accelerate at a high rate, thus not passing detectors at a low speed. As mentioned, when traffic is completely stationary (standing still), no vehicles pass the detector, and no traffic is observed. So the only traffic that is being observed is the relatively fast moving -because quickly acceleratingtraffic. To overcome these problems, we created bottlenecks as well by halving the free speeds, rather than creating an infrastructural (lane drop) bottleneck. This way, we prevent vehicles from standing still, and thus we prevent the introduction of model bias into our data set.

Experimental data
The method proposed in this paper is also applied on data from the A4 freeway in the Netherlands between Amsterdam and Rotterdam. The stretch we consider is 10km long (from Leiden to The Hague). On this freeway aggregated data are being collected, consisting of flows and time mean speeds derived from dual loop detectors.

Fitting methodology
The main innovation of the method proposed in this paper is that we first use a triangular fundamental diagram to separate the congested branch from the free-flow branch. Then, Wu's fundamental diagram is fitted on each branch. For the fitting process, we use data from all detectors for which the road has the same properties. A graphical overview of the method is presented in Figure 5. In this fitting process, some variables can be fixed. Figure 5 shows that the wave speed and the free-flow speed are fixed, which will turn out to give the most robust fitting results.
In the remainder of this section we will first indicate our overall optimisation goal, being minimizing a weighted error. We then (in Section 4.2) indicate the weights. Using these weights first a triangular fundamental diagram is fitted, yielding the critical density, and hence the separation between the free-flow and congested branches (Section 4.3). Then a fit is made for Wu's fundamental diagram, with the free-flow speed and wave speed fixed, and using the separation from the triangular fundamental diagram (Section 4.4).

Performance measures and optimization
The fit will give a predicted flow (q) based on the measured density k i . The error for a data point (one observation of flow and density) can be calculated as the difference between the observed flow q and the predicted flowq. As error of the fit we consider the weighted root-mean-square error of all data points, indicated by : The goal of the optimization is to minimize this error.

Weight of data points
We assign a weight p to each of the data points based on their reliability. This weight is not constant, as data points that can be trusted should contribute more to the quality of the fit than unreliable points and outliers. The following weights are assigned:  • Speeds under 10 m/s cannot be trusted. It would be very rare to have situations where the speed is constantly 10 m/s. Therefore, this will be a mixture of states, in which only the moving vehicles are measured. Due to the nature of local measurements, vehicles standing still will not be measured at all. Moreover, the approximation of the space mean speed by time mean speed will be worse when the spread of (measured) speeds is higher. Therefore, we give measurements with these low speeds a lower weight. In order to get a robust fit, we do not want to pre-specify the speed which is too low, but we would like to relate that to the speeds resulting from the fundamental diagram. If the weight would be zero, the fitting procedure benefits from choosing a very high-free speed, thereby ignoring all aggregation intervals with a lower free speed. Since this is undesirable, a weight of 0.5 is given to these points. • The measurements are taken at a freeway. Therefore, in low density conditions we expect high speeds. Consequently, low speeds at low densities are a measurement error. This could be due to the fact that speeds are time mean speeds, which distorts the speed and hence the estimation of density. This means these data points are unreliable. If the speeds are below 20 m/s in free flow, the points are neglected.
The resulting weights are shown in Figure 6.

Fitting a triangular fundamental diagram
First, we will estimate the triangular fundamental diagram. This will give a robust estimation of the critical density. This critical density will be used to separate the free-flow branch from the congested branch. The separation of the two branches is made based on density. A separation on speed is less reliable. The fitting procedure could end up fitting a high-free-flow speed, which fits data points with the high speeds very well. The other points, which one would assign to the free-flow branch, would be moved to the congested branch, which has a higher spread anyway, and therefore would fit in the line of expectation. This fundamental diagram has three degrees of freedom: the free-flow speed, the critical density and the jam density. Note that the capacity is determined by the free-flow speed times the critical density. In our approach the shock wave speed is fixed, so two degrees of freedom remain: the free-flow speed and either the critical density or the jam density, which is for fitting purposes equivalent.
The result of this fitting procedure is a triangular fundamental diagram. This triangular fundamental diagram gives the critical density which is input to the fitting procedure of the Wu fundamental diagram (next section).

Fitting Wu's fundamental diagram
For the same reasons as above, we assume a fixed shock wave speed w. Moreover, for freeway driving, we can assume a fixed free-flow speed. This will not affect the fitting process, as it hardly influences capacity, and it is relatively constant for freeways. In this paper, we set the free-flow speed u 0 to 30 m/s. The critical density is used to split the data into free-flow points and congested data points. There might be an error in the estimation of the critical density. Therefore, data points with a density between 90% and 120% of the estimated critical density from the triangular fit are not taken into account. If one considers the fundamental diagram, this is generally not an issue: the fitting of the diagram can be based on the 'slopes' of the fundamental diagram. The points near the top of the diagram may belong to both branches, thus introducing an error in the fit. However, these points are not necessary to find the slopes of the congested branch and the free-flow branch, respectively.
The remaining parameters of the fundamental diagram which need to be estimated are: (1) the free-flow capacity, (2) the queue discharge rate and (3) the jam density (see Figure 5).

Simulation results
This section presents the results of the fitting procedure. We first show the fundamental diagram using Edie's definitions. Then, the estimation results when different parameter values are fixed in order to see the sensitivity of each parameter are shown. Finally, the improvement of the fit when using harmonic mean speeds is identified.

Edie's definitions
The fundamental diagram using the points obtained by Edie's definitions can be visualised by the proportion of observations for a combination of density and flow. This is done in Figure 2(b). The line of the fundamental diagram agrees to a large extent with the theoretical lines; however, the diagram constructed from the trajectories shows a large capacity drop, while this is not present in the theoretical curve. This is because the theoretical curve is only based on car-following behaviour, and does not take into account that drivers might have a larger gap than desired when leaving the queue.

Fix various parameters
This section describes what happens to the fit of the fundamental diagram if some of the parameters are fixed, while applying the proposed methodology. Table 3 presents the results for the different parameters values, as well as the values for these parameters when derived from the graph using Edie's definitions. For Edie's definitions, we read the parameter values for the ground truth from the figure; this is possible because the figure gives very clear lines.
The graphical representation is shown in Figure 7. The table shows the numerical comparison between the various ways of fitting. The standard error, like the sum of the squared errors between the data points and the fit, does not provide a sensible measure for the error made. In fact, this is lowest  if all degrees of freedom are left for calibration. However, the values for the parameters of the fundamental diagram show that this does not lead to the best fundamental diagram. Therefore, we focus in this section on the values for the fundamental diagram and its shape. Figure 7(a) shows the curve if no parameters are fixed. The jam density is estimated at 477 veh/km/lane, which is much higher than the approximately 145 veh/km/lane which follows from theory and the analysis of trajectories using Edie's definitions. Figure 7(b) shows the fundamental diagram with the free-flow speed and the wave speed being fixed. The shape and parameters match relatively well with the shape of the fundamental diagram from Edie's definitions, although the free-flow capacity is higher. In fact, it seems that in the fundamental diagram according to Edie's definitions the speed decreases strongly just before the free-flow capacity point is reached. Therefore, a comparable fit of the shape of Wu's fundamental diagram leads to a higher capacity point. Given these intrinsic shortcomings, the fit is reasonably well. It is of course a disadvantage to fix both the free-flow speed and the wave speed. Therefore, it is also checked whether the same results can be obtained by fixing only one of these. Figure 7(d) shows that fixing only the free-flow speed does not alleviate this problem, but Figure 7(e) shows that fixing only the wave speed does.

Effect of the speed averaging
As mentioned before, speed averaging has an effect on the points in the fundamental diagram, particularly on the congested branch. Figure 7(f) shows the fit of the flow-density diagram where the density is computed using the harmonic mean speed and all parameters are estimated. In Figure 7(g), the free-flow speed and the wave speed have been fixed in the fit. Overall, the density can be better estimated when the density is based on the harmonic mean speed. However, as the amount of points along the congested branch is very limited, not much information is available on the shape of the congested branch. This is due to the very low speeds at which these points are located. The fit with all 5 parameters estimated has a very large estimated jam density of 410 veh/km/lane, hence this method is infeasible for practice. This can be improved by fixing the wave speed, and possibly the freeflow speed. Especially, the method only fixing the wave speed yields good results (see Table 3), with a closely matching free-flow capacity and queue discharge rate.

Applying the method to empirical data
Figure 8(b) shows the fitting results on empirical (real world) data. First, Figure 8(a) shows what happens if all five parameters of Wu's fundamental diagram are fitted simultaneously. This leads to a fit which visually does not seem to follow the data points. Moreover, the free-flow capacity is estimated to be (much) lower than the queue discharge rate. If we fix the wave speed and the free-flow speed (see Figure 8(b)), the fit follows the expected shape of the fundamental diagram better. However, the capacity values are slightly lower than the capacities indicated in the Dutch version of the Highway Capacity Manual (Dutch Road Authority 2011). The fitted capacities are 1890 veh/h/lane for the three lane section and 2270 veh/h/lane for the two lane section, where the Dutch Highway Capacity Manual indicates values of 2100 veh/h/lane for both situations. Also the data points seem to point at a slightly higher capacity. However, for design purposes, a slight underestimation of the capacity is better than an overestimation. The queue discharge rate is estimated at 1725 veh/h/lane.
Fixing only the wave speed, which gives a good fit with simulation results, is not working for the case with real data, since the free-flow capacity will be given an extreme value (see Figure 8(c)).
We can thus conclude that the method fixing the wave speed and the free-flow speed can also be used to fit a fundamental diagram on empirical data. Of course, the type of drivers for the realworld data is not known, but generally the population of a group of drivers is heterogeneous (Ossen, Hoogendoorn, and Gorte 2006). Therefore, the fact that the fitting procedure works for this real-world case also gives confidence that the method works well for a heterogeneous group of drivers.

Conclusions
This paper presents a method to fit a fundamental diagram to traffic data, thereby estimating the freeflow capacity and queue discharge rate. The difficulty is that points near capacity can be assigned to either of the two branches, which makes the fitting process difficult, leading to extreme (erroneous) values. We propose to first separate the free-flow branch from the congested branch by a triangular fit. Then, the free-flow speed and the wave speed are fixed, thereby limiting extreme values. The method proved to yield reasonable, though not perfect, results on simulation data. Also for more noisy realworld data, the method gives reasonably good fits for the fundamental diagram with realistic capacity values.
In this paper the fundamental diagram of Wu was fitted. In the procedure it turned out to be critical (1) to first find the shape and the critical density approximately (by the triangular fit) and (2) to fix the values of the free-flow speed and the wave speed which are then known. It is expected that the proposed method also works for fundamental diagrams of other shapes.