Submitted:
22 April 2024
Posted:
23 April 2024
You are already at the latest version
Abstract
Keywords:
1. Introduction
- What data is needed to capture the optimal (quasi-optimal) behaviour of the couple (PSO, PM)?
- How are the datasets for the ML algorithms generated?
2. Controllers with Predictions Based on PSO. Connection with Machine Learning Algorithms
- The process model can include nonlinearities, imprecise, incomplete, and uncertain knowledge, or correspond to a distributed-parameter system, etc.
- The constraints, such as initial conditions, bound constraints, final constraints, etc.
- The cost function, which should be optimized, leads to a performance index.
- What does it mean that the ML algorithm must emulate the predictor?
- What are datasets used in training the ML, and how are they obtained?
- What kind of ML model can be used to achieve an appropriate controller?
“when the process is in the state at the moment , the APSOA will predict the best control value ”.
3. Data Generation Using Closed-Loop Simulation over the Control Horizon
- □
- The reader can understand and execute the “ContrlLoop_PSO” program using the script ControlLoop_PSO_RHC.m. Details are also given in Appendix B, concerning the generic functions “Predictor_PSO” and “ProcessStep”.
- The PSO has a stochastic character, and the convergence process is imperfect. So, the optimal control values are different (and so are the state vector’s values), even if the initial state will be strictly the same.
- The initial state values are not the same. A standard initial state (of the standard batch) could be perturbed to simulate different initial conditions (the standard ones are imprecisely achieved).
- □
- The script LOOP_M_ControlLoop_PSO.m collects the data from M executions of the closed-loop simulation. The data structures presented in Figure 5 are created and loaded. A concrete example of data collected in the first simulation is given in Appendix B.
4. The ML Controller. The Design Procedure and the General Algorithm
- The same PSO algorithm generates the M state inside a group.
- The M simulations work with the same PM.
- Each state is transferred as the initial state to the predictor.
- The prediction horizon has sampling periods.
- Design procedure
- Write the “ControlLoop_PSO” program simulating the closed-loop working of the controller based on the PSO algorithm over the control horizon. The output data are the quasi-optimal trajectory and its associated control profile ( and ).
- Repeat M times the “ControlLoop_PSO” program’s execution to produce the sequences (, ) and save them in data structures similar to those in Figure 5.
- For each sampling period k, derive datasets similar to Table 1 from data saved at step 2.
- Determine the set of functions using the data sets derived at step 3 and an ML model; a function is associated with each sampling period k.
- Implement the new controller based on the ML model, i.e. the set of functions determined in step 4.
- Write the “CONTROL_loop” program to simulate the closed-loop functioning equipped with the ML controller. The proposed method’s feasibility, performance index, solution quality, and execution time will be evaluated.
- □
- A fragment of the SOCSK matrix produced by a MATLAB script is presented in Appendix C for step k=1. Only when k=0 the value of x2(0) equals 0 for any observation.
5. Linear Regression Controller
5.1. General Algorithm
- □
- The implementation of this algorithm is included in the script GENERATE_ModelSW; some details are given in Appendix D.
5.2. Simulation Results
- The state variable has two elements.
- The coefficients’ matrix must be loaded from an existing file.
- The grey instructions make the predictions, avoiding any numerical integration.
- The green instruction updates the next state, which has two components. The amount of light irradiated in the current sampling period is added to x2(k).
- □
- The script CONTROL_loopLINREG.m included in the attached folder implements the presented algorithm.
6. Controller Based on Regression Neural Networks
6.1. General Approach
- □
- The implementation of this algorithm is achieved by the script GENERATE_ModelNN; some details are given in Appendix E.
6.2. Simulation Results
![]() |
- □
- The script CONTROL_loopNN.m included in the attached folder implements the above algorithm.
7. Discussion
7.1. Comparison between the PSO and ML Predictors
- Did the ML predictors succeed in “learning” the behaviour of the couple (APSOA, PM) such that the process’s evolution would be quasi-optimal?
- Did the controller’s execution time decrease significantly?
- The similarity at this level would imply the same sequences of states, but we just stated that the ML controllers could experience new unobserved states. So, the three processes do not pass through the same set of states (the sets of accessible states are different).
- The learning is made at the level of each sampling period and “learns” couples (state, control value), not globally to the control profile level; our method is not based on learning CPs. On the other hand, the PSO predictor is very “noisy” due to its stochastic character and produces outliers among the 200 control values from time to time.
- (1) The two ML Controllers have predictors that have learned the behaviour of the couple (APSOA, PM) such that, in closed-loop working, the process evolves almost identically.
- (2) The resulting controllers have execution times hundreds of times smaller than that of the PSO Controller.
7.2. Comparison between the LR and RNN Controllers
- The PSO predictor predicts an optimal control value, but first, it searches for the optimal value following its optimization mechanism using a swarm of particles and the PM. That is why it takes a “long” time to find this value after a convergence process.
- The ML predictor (LR or RNN) predicts using an already-known regression function. Being an ML model, it reproduces what it has learned, the PSO predictor’s behaviour. It does not search for anything. Moreover it does not make numerical integrations of the PM. That is why it takes a “short” time to calculate the predicted value.
- The ML predictor replaces the PSO predictor only in execution when the controller achieves the control action. So, the controller’s execution time is hundreds of times smaller than initially. That was our desideratum.
- When we solve a new OCP, sometimes we need a metaheuristic (PSO, EA, etc) that searches for the optimal solution inside of a control structure. If the controller’s execution time is not acceptable, we can use the approach presented in this paper to create an ML controller. However, initially, we need something to search for the optimal solution.
8. Conclusions
Supplementary Materials
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Appendix A
| = 172 m2·kg−1 | absorption coefficient |
| = 870 m2·kg−1 | scattering coefficient |
| = 0.0008 | backward scattering fraction |
| = 0.16 h−1 | specific growth rate |
| = 0.013 h−1 | specific decay rate |
| = 120 µmol·m−2·s−1 | saturation constant |
| = 2500 µmol·m−2·s−1 | inhibition constant |
| = 1.45·10−3 m3 | the volume of the PBR |
| L = 0.04 m | depth of the PBR |
| A = 3.75·10−2 m2 | lighted surface |
| = 0.36 g/L | the initial biomass concentration |
| C =3600·10−2 | light intensity conversion constant |
| =100 | number of discretization points |
| lower technological light intensity | |
| upper technological light intensity | |
| = 3 g. | the minimal final biomass |
| tfinal = 120 h | control horizon |
| T= 1 h | sampling period |
Appendix B
- ControlLoop_PSO_RHC.m that implements the “ControlLoop_PSO” program;
- INV_PSO_Predictor1.m that implements the “Predictor_PSO” function;
- INV_RealProcessStep.m that implements the “ProcessStep” function.

Appendix C

Appendix D
Appendix E
References
- Siarry, P. Metaheuristics; Springer: Berlin/Heidelberg, Germany, 2016; ISBN 978-3-319-45403-0. [Google Scholar]
- Talbi, E.G. Metaheuristics—From Design to Implementation; Wiley: Hoboken, NJ, USA, 2009; ISBN 978-0-470-27858-1. [Google Scholar]
- Kruse, R.; Borgelt, C.; Braune, C.; Mostaghim, S.; Steinbrecher, M. Computational Intelligence—A Methodological Introduction, 2nd ed.; Springer: Berlin/Heidelberg, Germany, 2016. [Google Scholar]
- Faber, R.; Jockenhövelb, T.; Tsatsaronis, G. Dynamic optimization with simulated annealing. Comput. Chem. Eng. 2005, 29, 273–290. [Google Scholar] [CrossRef]
- Onwubolu, G.; Babu, B.V. New Optimization Techniques in Engineering; Springer: Berlin/Heidelberg, Germany, 2004. [Google Scholar]
- Valadi, J.; Siarry, P. Applications of Metaheuristics in Process Engineering; Springer International Publishing: Berlin/Heidelberg, Germany, 2014; pp. 1–39. [Google Scholar] [CrossRef]
- Minzu, V.; Riahi, S.; Rusu, E. Optimal control of an ultraviolet water disinfection system. Appl. Sci. 2021, 11, 2638. [Google Scholar] [CrossRef]
- Minzu, V.; Ifrim, G.; Arama, I. Control of Microalgae Growth in Artificially Lighted Photobioreactors Using Metaheuristic-Based Predictions. Sensors 2021, 21, 8065. [Google Scholar] [CrossRef] [PubMed]
- Abraham, A.; Jain, L.; Goldberg, R. Evolutionary Multiobjective Optimization—Theoretical Advances and Applications; Springer: Berlin/Heidelberg, Germany, 2005; ISBN 1-85233-787-7. [Google Scholar]
- Hu, X.B.; Chen, W.H. Genetic algorithm based on receding horizon control for arrival sequencing and scheduling. Eng. Appl. Artif. Intell. 2005, 18, 633–642. [Google Scholar] [CrossRef]
- Mînzu, V.; Arama, I. A Machine Learning Algorithm That Experiences the Evolutionary Algorithm’s Predictions—An Application to Optimal Control. Mathematics 2024, 12, 187. [Google Scholar] [CrossRef]
- Mayne, D.Q.; Michalska, H. Receding Horizon Control of Nonlinear Systems. IEEE Trans. Autom. Control. 1990, 35, 814–824. [Google Scholar] [CrossRef]
- Mînzu, V.; Rusu, E.; Arama, I. Execution Time Decrease for Controllers Based on Adaptive Particle Swarm Optimization. Inventions 2023, 8, 9. [Google Scholar] [CrossRef]
- Goggos, V.; King, R. Evolutionary predictive control. Comput. Chem. Eng. 1996, 20 (Suppl. 2), S817–S822. [Google Scholar] [CrossRef]
- Chiang, P.-K.; Willems, P. Combine Evolutionary Optimization with Model Predictive Control in Real-time Flood Control of a River System. Water Resour. Manag. 2015, 29, 2527–2542. [Google Scholar] [CrossRef]
- Minzu, V.; Serbencu, A. Systematic procedure for optimal controller implementation using metaheuristic algorithms. Intell. Autom. Soft Comput. 2020, 26, 663–677. [Google Scholar] [CrossRef]
- Alatefi, S.; Abdel Azim, R.; Alkouh, A.; Hamada, G. Integration of Multiple Bayesian Optimized Machine Learning Techniques and Conventional Well Logs for Accurate Prediction of Porosity in Carbonate Reservoirs. Processes 2023, 11, 1339. [Google Scholar] [CrossRef]
- Guo, R.; Zhao, Z.; Huo, S.; Jin, Z.; Zhao, J.; Gao, D. Research on State Recognition and Failure Prediction of Axial Piston Pump Based on Performance Degradation Data. Processes 2020, 8, 609. [Google Scholar] [CrossRef]
- Minzu, V.; Riahi, S.; Rusu, E. Implementation aspects regarding closed-loop control systems using evolutionary algorithms. Inventions 2021, 6, 53. [Google Scholar] [CrossRef]
- The MathWorks Inc. (2024a). Regression Neural Network Toolbox Documentation, Natick, Massachusetts: The MathWorks Inc. Available online: https://www.mathworks.com/help/stats/regressionneuralnetwork.html.
- Minzu, V.; Georgescu, L.; Rusu, E. Predictions Based on Evolutionary Algorithms Using Predefined Control Profiles. Electronics 2022, 11, 1682. [Google Scholar] [CrossRef]
- Goodfellow, I.; Bengio, Y.; Courville, A. Machine Learning Basics. In Deep Learning; The MIT Press, USA, 2016; pp. 95–161; ISBN 978-0262035613.
- Zou, S.; Chu, C.; Shen, N.; Ren, J. Healthcare Cost Prediction Based on Hybrid Machine Learning Algorithms. Mathematics 2023, 11, 4778. [Google Scholar] [CrossRef]
- Cuadrado, D.; Valls, A.; Riaño, D. Predicting Intensive Care Unit Patients’ Discharge Date with a Hybrid Machine Learning Model That Combines Length of Stay and Days to Discharge. Mathematics 2023, 11, 4773. [Google Scholar] [CrossRef]
- Albahli, S.; Irtaza, A.; Nazir, T.; Mehmood, A.; Alkhalifah, A.; Albattah, W. A Machine Learning Method for Prediction of Stock Market Using Real-Time Twitter Data. Electronics 2022, 11, 3414. [Google Scholar] [CrossRef]
- Wilson, C.; Marchetti, F.; Di Carlo, M.; Riccardi, A.; Minisci, E. Classifying Intelligence in Machines: A Taxonomy of Intelligent Control. Robotics 2020, 9, 64. [Google Scholar] [CrossRef]
- Banga, J.R.; Balsa-Canto, E.; Moles, C.G.; Alonso, A. Dynamic optimization of bioprocesses: Efficient and robust numerical strategies. J. Biotechnol. 2005, 117, 407–419. [Google Scholar] [CrossRef] [PubMed]
- Balsa-Canto, E.; Banga, J.R.; Aloso, A.V.; Vassiliadis. Dynamic optimization of chemical and biochemical processes using restricted second-order information 2001. Comput. Chem. Eng. 2001, 25, 539–546. [Google Scholar]
- Newbold, P.; Carlson, W.L.; Thorne, B. Multiple Regression. In Statistics for Business and Economics, 6th ed.; Pfaltzgraff, M., Bradley, A., Eds.; Publisher: P ding x1, FStat = 12.7755, pearson Education, Inc: New Jersey, 07458, USA, 2007; pp. 454–537. [Google Scholar]
- The MathWorks Inc. (2024a). Stepwise Regression Toolbox Documentation, Natick, Massachusetts: The MathWorks Inc. Available online: https://www.mathworks.com/help/stats/stepwise-regression.html.
- Goodfellow, I.; Bengio, Y.; Courville, A. Example: Linear Regression. In Deep Learning; The MIT Press: USA, 2016; pp. 104–113. ISBN 978-0262035613. [Google Scholar]












| XT | UT |
| …… | …… |
| /*This pseudocode describes the construction of the data sets needed by the ML models at the level of each sampling period*/ Inputs: cell array STATE, matrix UstarRHC; Outputs: matrix SOCSK, table datak, cell arrays DATAKTest, DATAKTrain | |
| 1. | #Load the file containing the data structure STATE and UstarRHC (see Figure 5) |
| 2. | k ← 0 |
| 3. | while k ≤ 0 H-1 |
| 4. | for i=1, ∙∙∙, M |
| 5. | SOCSKi ← [STATEi (k,1:n) UstarRHC(i,k)] |
| 6. | end |
| 7. | #Convert the matrix SOCSK into the table datak. |
| 8. | datakTest lines #1 – 60 of datak |
| 9. | datakTrain lines #61 – 120 of datak |
| 10. | DATAKTest datakTest |
| 11. | DATAKTrain datakTrain |
| 12. | |
| 13. | end |
| 14. | #Save the cell array DATAKTrain and DATAKTest in a file. |
| The general algorithm of the ML controller | |
|---|---|
| /*The controller program is called at each sampling period, k */ | |
| 1 | Get the current value of the state vector, X(k); /* Initialize */ |
| 2 | Predict the optimal control value using the regression model /* whatever is the regression model’s type */ |
| 3 | Send the optimal control value towards the process. |
| 4 | Wait for the next sampling period. |


| k | C0 | C1 | C2 |
|---|---|---|---|
| 0 | 564.18 | 0 | 0 |
| 1 | 585.53 | 0 | 0 |
| 2 | -20.368 | 1441.5 | 0 |
| : | : | : | : |
| 9 | 591.85 | 0 | 0 |
| 10 | 119.74 | 0 | 620.84 |
| 11 | 591.48 | 0 | 0 |
| 12 | 590.95 | 0 | 0 |
| 13 | -985.91 | 2147.7 | 0 |
| 14 | -328.16 | 1205.6 | 0 |
| : | : | : | : |
| 111 | 4055.1 | -1476.6 | 0 |
| 112 | 5482.6 | -2067.6 | 0 |
| 113 | 597.8 | 0 | 0 |
| 114 | 3300.2 | 0 | -308.67 |
| 115 | 587.66 | 0 | 0 |
| 116 | 6446.3 | -2451.2 | 0 |
| 117 | 7144 | -2732.8 | 0 |
| 118 | 4410.7 | 0 | -419.32 |
| 119 | 565.2 | 0 | 0 |




| >>ControlLoop_PSO_RHC |
|---|
| x00= 0.3660 |
| yield mass= 3.0000 |
| Light= 9.2474 |
| Perf Index= 9.2474 |
| Elapsed time is 447.281879 seconds. |
| PSO Controller | LR Controller | RNN Controller | |
|---|---|---|---|
| x00 | 0.360 | 0.360 | 0.360 |
| yield mass | 3.0000 | 3.0282 | 3.0249 |
| Light | 9.2474 | 9.3166 | 9.3115 |
| Perf Index | 9.2474 | 9.5981 | 9.5604 |
| Control time [s] | 447.28 | 0.64 | 1.35 |
| Training time [s] | - | 5.4 | 232.83 |
| Model size | - | 3 kB | 17 kB |
|
Root Mean Squared Error (RMSE for k=10) |
- | 113.73 | 116.63 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
