## 6 In-Process Control  
The natural extension of research work on process monitoring is developing systems capable of predicting impending events and taking corrective actions to prevent the onset of defects. The application of ML in real-time control for AM is just coming into existence and beginning to display signs of future potential. Some of the challenges where such systems are not highly utilized are a high number of process parameters and their relationship with the part quality. The use of ML for monitoring has matured in the past few years as it mainly depends on training the model offline. More effort is needed to cope with the fast nature of the process. Furthermore, solid solutions for data management and storage are needed to develop ML-based control [140]. Factors affecting the development of such systems include the need for sensor fusion techniques to achieve improved process understanding and control [141]  
Several studies have been performed using classical control approaches to compensate for defects in metal additive manufacturing. Well-defined examples can be found in the works of [PERSON] et al. [53; 142; 143], [PERSON] et al. [144], and [PERSON] et al. [46]. Examples of more recent research work in this area using mainly energy density as a process parameter include [PERSON] et al. [145], [PERSON] et al. [146], [PERSON] et al. [147], and [PERSON] et al. [148]. In addition, comprehensive review papers by [PERSON] and [PERSON] [149] and [PERSON] et al. [150] were also published. Generally, these efforts were based on mechanistic (or analytical) process models based on first principles. This typically leads to a fixed number of process parameters with physical or empirical interpretation. In addition, physics-based models are often computationally expensive. In contrast, data-driven models require little physical knowledge and a more extensive dataset. The number of parameters in these \"black-box\" models depends on the available data. The so-called \"grey-box\" or hybrid semiparametric modeling is realized by balancing the advantages and disadvantages of knowledge and data-driven models. There are two approaches used to realize hybrid model structures: serial or parallel [151]. In the serial approach, the data-driven model is used as an input to the mechanistic model. In the parallel approach, the output of the data-driven model is superimposed onto that of the mechanistic model. The residuals between process observations and mechanistic model predictions are then used to improve the model's prediction accuracy. Examples of hybrid modeling can be found in the chemical industry [152]. In this section, we focus on machine learning approaches to control the additive manufacturing process. These approaches are typically mainly based on data-driven models. Machine learning models can be applied to the AM process's analysis, diagnosis, and control because they can define critical causal relationships between process variables and construct classification procedures to detect unwanted process states. Classification of the process states can be used to construct optimal control trajectories in real-time process control. The application of ML in the development of in-process control systems has improved control performance in terms of accuracy, particularly for systems that are difficult to describe mathematically [153]. ML techniques have been used to develop online closed-loop controllers for various AM processes. For example, [PERSON] et al. [154] used the Markov decision process and layer-per-layer imaging data to formulate an AM optimal control system. Optimal control theory is a branch of mathematical optimization that deals with finding a control for a dynamical system over a period of time such that an objective function is optimized. In this case, the optimal control was to optimize the process parameters in a layer-by-layer manner. They considered the stochastic dynamics of the defects for each layer and used the Markov decision process to control the L-PBF process sequentially.