Implementation of Teaching Learning Based Optimization
Previous article Teaching Learning based Optimization (TLBO) talked about inspiration of teaching learning based optimization , it’s mathematical modelling and algorithm. In this article we will implement Teaching learning based optimization (TLBO) for two fitness functions 1) Rastrigin function 2) Sphere function. The algorithm will run for a predefined number of maximum iterations and will try to find the minimum value of these fitness functions.
Rastrigin function is a non-convex function and is often used as a performance test problem for optimization algorithms.
For an optimization algorithm, rastrigin function is a very challenging one. Its complex behaviour cause optimization algorithms to often stuck at local minima. Having a lot of cosine oscillations on the plane introduces the complex behaviour to this function.
2) Sphere function
Sphere function is a standard function for evaluating the performance of an optimization algorithm.
Choice of hyper-parameters
Parameters of problem:
- Number of dimensions (d) = 3
- Lower bound (minx) = -10.0
- Upper bound (maxx) = 10.0
Hyperparameters of the algorithm:
- Number of particles (N) = 50
- Maximum number of iterations (max_iter) = 100
- Fitness function
- Problem parameters ( mentioned above)
- Population size (N) and Maximum number of iterations (max_iter)
- Algorithm Specific hyper parameters (None in teaching learning based optimization)
The pseudocode of the teaching-learning based optimization is already described in the previous article. Data structures to store students as well as data structure to store data specific to individual student were also discussed.
Begin teaching learning based optimization on rastrigin function Goal is to minimize Rastrigin's function in 3 variables Function has known min = 0.0 at (0, 0, 0) Setting num_particles = 50 Setting max_iter = 100 Starting TLBO algorithm Iter = 10 best fitness = 3.662 Iter = 20 best fitness = 0.389 Iter = 30 best fitness = 0.389 Iter = 40 best fitness = 0.389 Iter = 50 best fitness = 0.200 Iter = 60 best fitness = 0.132 Iter = 70 best fitness = 0.051 Iter = 80 best fitness = 0.003 Iter = 90 best fitness = 0.001 TLBO completed Best Student found: ['0.000593', '-0.000040', '-0.000461'] fitness of best Student = 0.000112 End TLBO for rastrigin function Begin teaching learning based optimization on sphere function Goal is to minimize sphere function in 3 variables Function has known min = 0.0 at (0, 0, 0) Setting num_particles = 50 Setting max_iter = 100 Starting TLBO algorithm Iter = 10 best fitness = 0.009 Iter = 20 best fitness = 0.000 Iter = 30 best fitness = 0.000 Iter = 40 best fitness = 0.000 Iter = 50 best fitness = 0.000 Iter = 60 best fitness = 0.000 Iter = 70 best fitness = 0.000 Iter = 80 best fitness = 0.000 Iter = 90 best fitness = 0.000 TLBO completed Best Student found: ['0.000000', '-0.000000', '-0.000000'] fitness of best Student = 0.000000 End TLBO for sphere function
Research paper: R. V. Rao, V. J. Savsani & J. Balic (2012) Teaching–learning-based optimization algorithm for unconstrained and constrained real-parameter optimization problems, Engineering Optimization, 44:12, 1447-1462, DOI: 10.1080/0305215X.2011.652103
Inspiration of the implementation: https://www.mathworks.com/matlabcentral/fileexchange/65628-teaching-learning-based-optimization#:~:text=Teaching%20Learning%20Based%20Optimization%20is,teacher%20and%20the%20student%20phase.
Attention reader! Don’t stop learning now. Get hold of all the important Machine Learning Concepts with the Machine Learning Foundation Course at a student-friendly price and become industry ready.