## 3 Implementing the FLUIDSIM Prototype  
The simulation prototype, based on the model described in the previous section, is based on a main loop whose scheme is presented below. **1. ** import network  
**2. ** congestion reduction  
**MAIN LOOP**  
**3. FOR \(t=1\)** _to_ \(iterations\)**DO**  
**4. ** FOR _each_ \(n\in N\)**DO**  
**5. ** process node(n)  
**6. ** ENDFOR**  
**7. ** FOR _each_ \(e\in E\)**DO**  
**8. ** process arc(n)  
**9. ** ENDFOR**  
**10. ** export output(t)  
**11. ENDFOR**  
At each iteration, two main routines are invoked, one providing the elaboration of each node and the other the processing of each arc. Since wave propagation speed is assumed to be finite, it is possible to compute the traffic evolution by processing elements separately. FLUIDSIM can be used as a macrosimulation tool in order to evaluate the general impact of some traffic regulation rules on the whole network. Therefore, data structures and other implementation details were chosen to guarantee the chance to consider a traffic network in its full generality, with a focus on the efficiency of processing large size instances, like those arising from real urban networks. Node processingAs reported in Section 2.2, each time the node processing routine is invoked, a LP problem must be solved at the optimum in order to produce the assignment for flows and density at the extreme points of the incident links interval. The linear programming formulation is quite concise, being in most cases the number of its variables and constraints equal to the number of roads incident to junctions. In general, the worst case is \(O(|E|)\) for both the number of variables and the number of constraints. In a first version of the prototype the node processing routine invoked an external mathematical solver [27], but due to the high number of times this routine must be run, the code was improved by embedding a simplex routine inside the code. The relevance of the computational time saving provided by this additional feature was tested, and the results are presented in Section 4. Arc processingThe arc processing routine computes, for each arc, a new density value for each segment in which an arc is divided by the numerical segmentation scheme, that is \(\lfloor\frac{l_{i}}{\Delta s}\rfloor\). This is done by invoking each time the routines implementing the numerical approximation scheme. Depending on the size of \(\Delta s\), on the number of arcs in the network, and on the choice of the scheme itself, this computation can represent the computational bottleneck of the system. Software architectureIn Figure 1, we provide a scheme of the prototype architecture. The core of the simulation environment is represented by the FLUIDSIM block, taking as an input the network structure, that can be exported from a Geographical Information System project as a file containing the list of nodes and links, together with a set of data concerning the initial state of density on arcs. The main output of the simulation at each time step is the profile of density values on arcs, that can be represented on a GIS system by means of the implementation of proper importation routines. In particular, varying accurately the density profile, if \(\Delta s\) is small enough, it could be interesting to visualize each arc segment differently on the map, instead of considering just the mean value for each arc. To this aim, dynamic segmentation can be used to consider all the discrete intervals in which each arc is divided when representing the map on a GIS. Figure 1: Architecture of the FLUIDSIM prototype. Implementation detailsThe prototype was implemented in ANSI C++ language, and the code compiled with gcc on linux environment. Tests were performed on a single cpu Pentium 4 1.7 GHz PC with 2 Gb RAM. Scalability propertiesThe structure of the simulation algorithm suggests the possible use of grid computing and parallelization.