## 3 Modelling and Implementation of the Simulation Prototype  
### The Assembly System to Be Analysed and the Simulation System Requirements  
The first step of the methodology is to define the logical structure of the system to be analyzed. We focused our work on a type of assembly system (AS) that has many of the properties (flexibility, reconfigurability, reactivity, intelligence, etc.) that should be present in advanced manufacturing systems. This type of AS, named the flexible and modular assembly line [26], is characterized by: (a) adopting a mixed production model offering flexible routes of the products throughout the system, (b) using automatic guided vehicles (AGVs) to provide it with the great flexibility required, and (c) adhering to a whole set of additional design principles. Among these principles, the need for flexible integration of quality control loops stands out, with some of them focused on preventing the generation and propagation of geometric defects. The objective of this work is to validate these strategies with the construction of a simple simulation prototype supported by a simulation meta-model that will be described in the following sections. For the sake of simplicity, in this work, we focus on the simulation of a MAS for the assembly of a single product, with an established multi-station process without considering alternative routes, and subject to a number of restrictions that are described throughout this section. The assembly line consists of a certain number (N) of assembly stations to execute the assembling operations and can include inspection stations for the in-line measurement and verification of the final assemblies in order to establish their acceptance or rejection. Each assembly station includes an assembly machine that adds a new part on the incoming subassembly. To execute this operation, the machine previously fixes the part and the subassembly using a set of locators which can be adjusted manually or automatically. Furthermore, the assembly stations may have capabilities for conducting in-process measurements on the resulting subassembly, although the measurements in this case will present greater uncertainty than those obtained from the inspection stations. Both the measured data from the on-line measurements (inspection stations) and from the in-processing measurements (assembly stations) can be used to compute, according to different optimization algorithms, the correction of the locators' positions for improving the quality index for the final assemblies. Moreover, each assembly station has two input buffers, one for subassemblies and one for parts, to regulate the flow of materials. The transport of processed assemblies between the stations is carried out by means of a set of AGVs, the number of which is sufficient to avoid any stock rupture in the buffers caused by delays or lack of transport capacity. Therefore, in this first work, the transport processes are not modelled. From the above description, the work is clearly focused on a generic MAS with a sequential linear flow of materials through a variable number of stations which allow the processing of the assemblies and their measurement. This MAS is also equipped with a control logic both for the logistics (flow of materials and production orders) and for the assurance and improvement of geometric quality. Therefore, it is a generic MAS type, which can be described with the modular and scalable structure of the meta-model shown in the BDD of Figure 2.  
Next, and according to the second step of the methodology, the requirements for the system of interest, i.e., the simulation system, are established. Taking into account the previously described characteristics of the system to analyze, the simulation prototype and its meta-model must also be modular and scalable in order to support the creation of specific simulation models for a given MAS. Additionally, the prototype must be designed taking advantage of Modelica's ability to obtain executable models from libraries formed by a set of reusable blocks/classes.