Teaching-Learning-Based Optimization (TLBO)¶
A population method for continuous problems that needs no tuning beyond the population size.
TLBO ¶
TLBO(*, max_iter=None, pop_size=100, max_nfe=None, target=None, max_time=None, display=False, x0=None, local_search=None, local_search_prob=0.1, local_search_nfe=100)
Teaching-Learning-Based Optimization (Rao, Savsani and Vakharia, 2011).
Each iteration has two phases, and each phase evaluates pop_size new solutions.
Teacher phase: the teacher is the best learner of the class. Every learner moves by
r * (teacher - TF * mean), where mean is the mean of the class, r is
uniform in [0, 1] per component and the teaching factor TF is 1 or 2 at random
for each learner.
Learner phase: every learner i picks a random partner j (not i). It moves by
r * (x_i - x_j) (away from j) if it is better than j, otherwise by
r * (x_j - x_i) (toward j).
In both phases a new solution replaces the learner only if it is strictly better.
TLBO has no settings beyond the common ones (pop_size must be at least 2).
Unlike the paper, each phase updates all learners at once, from the same class. An
iteration costs 2 * pop_size evaluations, while the paper counts pop_size per
generation, so its budgets are half the real cost.
Reference
R. V. Rao, V. J. Savsani and D. P. Vakharia, "Teaching-learning-based optimization: A novel method for constrained mechanical design optimization problems", Computer-Aided Design 43(3), 2011.
Example¶
import ypea
problem = ypea.Problem(
ypea.Real("x", shape=20, lb=-10, ub=10),
lambda sol: ypea.benchmarks.sphere(sol.x),
vectorized=True,
name="sphere",
)
alg = ypea.TLBO(max_nfe=20_000)
result = alg.solve(problem, seed=1)
print(result.summary())
TLBO on sphere
best objective value: 7.28338e-06
feasible: True (violation 0)
evaluations: 20000, iterations: 100, time: 0.0198 s, stopped by: max_nfe
Differs from Python: MATLAB draws its own random numbers, so the best value differs from Python's.
problem = ypea.Problem( ...
vars=ypea.Real("x", shape=20, lb=-10, ub=10), ...
objective=@(sol) ypea.benchmarks.sphere(sol.x), ...
vectorized=true, ...
name="sphere");
alg = ypea.TLBO(max_nfe=20000);
result = alg.solve(problem, seed=1);
disp(result.summary())
TLBO on sphere
best objective value: 4.62862e-05
feasible: true (violation 0)
evaluations: 20000, iterations: 100, time: 0.276 s, stopped by: max_nfe
Search on Rastrigin¶