# Towards Machine Learning for Error Compensation in Additive Manufacturing
## 3 Data-Driven Modelling in Additive Manufacturing
### Markov Decision Process  
The lack in the ability to monitor real-time quality control in AM can be seen as a limitation since quality assurance is provided by a more traditional offline data-driven techniques and optimization approaches such as design of experiments, which poses great challenges for widespread applications. In order to fully utilize the potential of sensing data for AM, effective analytical tools and methods that are able to handle complex image data to reflect the microstructure and mechanical properties of AM builds are seen as a key factor.  
By extracting useful information on the process dynamic and defect conditions, an optimal control approach for AM parts is proposed in [89] using Laser Powder Bed Fusion technique. Quality assurance in AM is laid out by first measuring in-situ measuring, then estimating real-time defect states in layer wise AM images, and finally optimising layer-by-layer control actions. A formulation on the in-situ AM control problem adapting Markov Decision Process (MDP) is simulated with the objective of finding an optimal control plan.  
Markov Decision Process (MDP) is a decision-making model working in a discrete and stochastic manner in sequential environments. The core principle of the model is that a decision maker, or agent, inhabits an environment, which changes the state randomly in response to action choices made by it [90].  
The defect level is characterized in the corresponding layer images with nonhomogeneous patterns or irregularities. Then, layer-by-layer control actions are taken by extracting The Hoteling \(T^{2}\) information [91,92] from the multifractal spectrum. A stochastic dynamic model is represented as Markov process to determine the optimized control policy where experimental results signifies that the proposed method has a huge potential for an on-the-fly build quality and real-time defect mitigation assessment in AM. Figure 5 encapsulates the basis of a Markov Decision Process model discussed.  
In additive manufacturing, microstructures created from the process can be quite complex than conventional counterparts like CNC deductive manufacturing. With the introduction of impermanent and spatial heat sources [93,94], microstructural heterogeneity in the processed part is imminent. In a study conducted in 2017, a kinetic Monte Carlo model is proposed to predict three-dimensional grain structure in AM [95], Figure 6 illustrates the flowchart of the Monte Carlo model being used.  
Figure 4: Schematic of ANN-based geometric compensation model.  
Figure 5: Markov decision process flow.  
The model proposed uses molten zone shape, surrounding temperature gradient, and scan pattern to represent the evolution in the microstructural level. The microstructural variation is rather prominent in metal-based additive manufacturing process is due to the non-uniform local solidification behaviour occurring throughout the process [96,97]. A cost ratio, \(c_{f}/c_{a}\), using the value of failure cost over corrective action cost is being implemented to evaluate the performance of the proposed method. The results show that the model was able to reproduce distinct and varied classes of AM microstructures with a relatively low computation requirement.