## 2 Methodology  
In this paper, the bead geometry measurements for different layers have been obtained using Grasshopper software. Grasshopper uses generative algorithms and parametric modeling that differentiates it from other CAD software, which uses polygon mesh-based representations to model an object. More specifically, Rhino's Grasshopper was used to create the physical part specifications (bead size, layer height, pattern, etc.). Then generative algorithm was implemented and converted to robot programs using the HAL framework. This approach was chosen because the programming methodology interface is suitable for mathematical representations without passing through the G-Code step [39]. This is done using the following steps:  
* Parametric surface creation: In this step, mathematical tools are used to create a 2D model surface. Alternatively, a CAD part could be imported directly and changed to a parametric CAD part using Grasshoppers tools.  
Pattern creation: In this step, patterns (zigzag, spiral tool path, etc.) are designed and added to the 2D surface. The zigzag pattern is advised for its simplicity of implementation, robustness, and surface roughness [40].
* Layer-to-layer deposition strategy: After depositing the first layer, a suitable travel strategy is required to reach the next layer, and successively. The travel strategy depends on some deposition parameters, such as the laser power, wire feed rate, and robot travel speed. Therefore, the travel strategy should be carefully chosen as it can influence the cooling of the previous layer as well as the bonding between layers. For more details see e.g., [41; 42].
* Bead geometry measurements: Finally, a laser scanner was used to obtain the measurements data of the bead geometry during the LWAM process. The laser scanner was mounted on the welding robot's arm to directly measure the bead geometry for each layer deposition. A measurement for a single bead geometry and layer deposition is shown in Figure 3.  
After having several bead's geometry measurements and dimensions, a prediction function \(F(x)\), based on a regression algorithm, is used to predict the bead geometry for the current layer and the successive layers. The prediction function \(F(x)\) can then be fed to Grasshopper with two more inputs, the product design specification and the bead dimensions. Next, the designed parametric object is loaded to the HAL framework and converted to a robot program, along with the motion settings and the robot calibration. Finally, a simulated 3D printing program of the final product is ready to be transferred to the real robot to begin manufacturing 3D parts, as shown in Figure 2.  
The prediction algorithm, used in this work, includes linear regression and linearization steps for non-linear trend (power decay function). The power decaying function is used to represent the self-regulation of the layer geometry. The prediction model takes as input the training examples (\(x_{i}\), \(i=1\) to \(m\), \(m=\) final layer geometry dimension) and the output is the model prediction that relates the bead geometry changes over layer depositions.  
Finally, a neural network technique was used to correlate the bead geometry measurements with the first-order deposition parameters: laser power, wire feed rate, and travel speed. In this way, the prediction algorithm method (discussed in Section 3.1) was used first with the fixed deposition parameters, and then a neural network (discussed in Section 3.2) was used with varied deposition parameters to study their influence on bead geometry.