Skip to content
/ xMLC Public

Machine learning control based on linear genetic programming for feedback control law optimization.


Notifications You must be signed in to change notification settings


Repository files navigation


Copyright: 2022 Guy Y. Cornejo Maceda (

MIT License

This software aims to make machine learning control (MLC) based on linear genetic programming easy for students to understand and to apply with a matlab program. It comes along with the book xMLC---A Toolkit for Machine Learning Control freely available on this link: The user is invited to study the code along with the book as the latter contains:

  • detailed information on the MLC algorithm based on genetic programming;
  • a user's guide to get started with the code;
  • an application on the net drag reduction of the fluidic pinball;
  • a guide to adapt/inteface xMLC with your DNS solvers and experiments.

xMLC is a fork of OpenMLC-MATLAB-2 ( by T. Duriez, an implementation of MLC based on tree-based genetic programming.

For reference

@Book{CornejoMaceda2022book, author = {Cornejo Maceda, Guy Y. and Lusseyran, Fran\c{c}ois and Noack, Bernd R.}, editor = {Semaan, Richard and Noack, Bernd R.}, title = {xMLC - A Toolkit for Machine Learning Control}, series = {Machine Learning Tools in Fluid Mechanics}, year = {2022}, edition = {First edition}, publisher = {Technische Universit{"a}t Braunschweig}, address = {Braunschweig}, volume = {2}, doi = {10.24355/dbbs.084-202208220937-0}, url = {}, file = {:} }

Getting Started

Unzip the tar.gz file.


The software needs MATLAB or Octave. No additional packages are needed. This version has been developped on MATLAB version (R2018b) and Octave version 4.2.2. Please contact the author ( in case of error.


The main folder should contain the following folders and files:

  • Initialization.m, Restart.m, to initialize and restart the toy problem.
  • @MLC/, @MLCind/, @MLCpop/, @MLCtable/ contains the object definition files for the MLC algorithm.
  • MLC_tools/ contains functions and scripts that are not methods used by the MLC class objects.
  • ODE_Solvers/ contains other functions such ODE solvers
  • Plant/ contains all the problems and associated parameters. One folder for each problem. Default parameters are in MLC_tools/.
  • save_runs/ contains the savings.

Initialization and run

To start, run matlab in the main folder, then run Initialization.m to load the folders and class object.


A mlc object is created containing the toy problem. The toy problem is the stabilization of a damped Landau oscillator. To load a different problem, just specify it when the MLC object is created.


To start the optimization process of the toy problem, run the go.m method. Run alone it process one generation of optimization. For the first iteration, it will initialize the data base with new individiduals. Then it will create the new generations by evolving the last population thanks to genetic operators.


To run several generations, precise it.

mlc.go(10); %To run 10 generations.

Post processing and analysis.

To visualize the best individual, use :


To visualize the learning process, use :


The current figure can be directly saved in save_runs/NameOfMyRun/Figures/ thanks to the following command:

mlc.print('NameOfMyFigure',1); % to overwrite an existing figure

Useful parameters = 'NameOfMyRun'; % This is the used to save;
mlc.parameters.Elitism = 1;
mlc.parameters.CrossoverProb = 0.3;
mlc.parameters.MutationProb = 0.4;
mlc.parameters.ReplicationProb = 0.7;
mlc.parameters.PopulationSize = 50; % Size of the population


One can save and load one run. /!\ When loading, the current mlc object will be overwritten, be careful!


See the CheatSheet.m file for a quick start.


Version 0.10 - First public GitHub release. If you experience compatibility issues with previous versions, please contact the first author.



  • The author thanks Thomas Duriez ( and Ruying Li for the great help they provided by sharing their own code.


Machine learning control based on linear genetic programming for feedback control law optimization.







No releases published