mealpy.human_based package¶
mealpy.human_based.BRO¶
- class mealpy.human_based.BRO.BaseBRO(problem, epoch=10000, pop_size=100, threshold=3, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerMy changed version of: Battle Royale Optimization (BRO)
Notes
I change the flow of algorithm
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
threshold (int): [2, 5], dead threshold, default=3
Examples
>>> import numpy as np >>> from mealpy.human_based.BRO import BaseBRO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> threshold = 3 >>> model = BaseBRO(problem_dict1, epoch, pop_size, threshold) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- ID_DAM = 2¶
- create_solution()[source]¶
- To get the position, fitness wrapper, target and obj list
A[self.ID_POS] –> Return: position
A[self.ID_TAR] –> Return: [target, [obj1, obj2, …]]
A[self.ID_TAR][self.ID_FIT] –> Return: target
A[self.ID_TAR][self.ID_OBJ] –> Return: [obj1, obj2, …]
- Returns
wrapper of solution with format [position, [target, [obj1, obj2, …]], damage]
- Return type
list
- class mealpy.human_based.BRO.OriginalBRO(problem, epoch=10000, pop_size=100, threshold=3, **kwargs)[source]¶
Bases:
mealpy.human_based.BRO.BaseBROThe original version of: Battle Royale Optimization (BRO)
- Links:
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
threshold (int): [2, 5], dead threshold, default=3
Examples
>>> import numpy as np >>> from mealpy.human_based.BRO import BaseBRO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> threshold = 3 >>> model = BaseBRO(problem_dict1, epoch, pop_size, threshold) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Rahkar Farshi, T., 2021. Battle royale optimization algorithm. Neural Computing and Applications, 33(4), pp.1139-1157.
mealpy.human_based.BSO¶
- class mealpy.human_based.BSO.BaseBSO(problem, epoch=10000, pop_size=100, m_clusters=5, p1=0.2, p2=0.8, p3=0.4, p4=0.5, slope=20, miu=0, xichma=1, **kwargs)[source]¶
Bases:
mealpy.human_based.BSO.ImprovedBSOThe original version of: Brain Storm Optimization (BSO)
- Links:
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
m_clusters (int): [3, 10], number of clusters (m in the paper)
p1 (float): [0.1, 0.5], probability
p2 (float): [0.5, 0.95], probability
p3 (float): [0.2, 0.8], probability
p4 (float): [0.2, 0.8], probability
slope (int): [10, 15, 20, 25], changing logsig() function’s slope (k: in the paper)
miu (float): [0], mean of normal distribution (gaussian)
xichma (float): [1], standard deviation of normal distribution (gaussian)
Examples
>>> import numpy as np >>> from mealpy.human_based.BSO import BaseBSO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> m_clusters = 5 >>> p1 = 0.2 >>> p2 = 0.8 >>> p3 = 0.4 >>> p4 = 0.5 >>> slope = 20 >>> miu = 0 >>> xichma = 1 >>> model = BaseBSO(problem_dict1, epoch, pop_size, m_clusters, p1, p2, p3, p4, slope, miu, xichma) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Shi, Y., 2011, June. Brain storm optimization algorithm. In International conference in swarm intelligence (pp. 303-309). Springer, Berlin, Heidelberg.
- class mealpy.human_based.BSO.ImprovedBSO(problem, epoch=10000, pop_size=100, m_clusters=5, p1=0.25, p2=0.5, p3=0.75, p4=0.5, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerMy improved version of: Brain Storm Optimization (BSO)
Notes
Remove some probability parameters, and some useless equations.
Add Levy-flight technique for more robust
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
m_clusters (int): [3, 10], number of clusters (m in the paper)
p1 (float): 25% percent
p2 (float): 50% percent changed by its own (local search), 50% percent changed by outside (global search)
p3 (float): 75% percent develop the old idea, 25% invented new idea based on levy-flight
p4 (float): [0.4, 0.6], Need more weights on the centers instead of the random position
Examples
>>> import numpy as np >>> from mealpy.human_based.BSO import ImprovedBSO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> m_clusters = 5 >>> p1 = 0.25 >>> p2 = 0.5 >>> p3 = 0.75 >>> p4 = 0.6 >>> model = ImprovedBSO(problem_dict1, epoch, pop_size, m_clusters, p1, p2, p3, p4) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
mealpy.human_based.CA¶
- class mealpy.human_based.CA.OriginalCA(problem, epoch=10000, pop_size=100, accepted_rate=0.15, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerThe original version of: Culture Algorithm (CA)
- Links:
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
accepted_rate (float): [0.1, 0.5], probability of accepted rate, default: 0.15
Examples
>>> import numpy as np >>> from mealpy.human_based.CA import OriginalCA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> accepted_rate = 0.15 >>> model = OriginalCA(problem_dict1, epoch, pop_size, accepted_rate) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Chen, B., Zhao, L. and Lu, J.H., 2009, April. Wind power forecast using RBF network and culture algorithm. In 2009 International Conference on Sustainable Power Generation and Supply (pp. 1-6). IEEE.
mealpy.human_based.CHIO¶
- class mealpy.human_based.CHIO.BaseCHIO(problem, epoch=10000, pop_size=100, brr=0.06, max_age=150, **kwargs)[source]¶
Bases:
mealpy.human_based.CHIO.OriginalCHIOMy changed version of: Coronavirus Herd Immunity Optimization (CHIO)
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
brr (float): [0.01, 0.2], Basic reproduction rate, default=0.06
max_age (int): [50, 200], Maximum infected cases age, default=150
Examples
>>> import numpy as np >>> from mealpy.human_based.CHIO import BaseCHIO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> brr = 0.06 >>> max_age = 150 >>> model = BaseCHIO(problem_dict1, epoch, pop_size, brr, max_age) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- class mealpy.human_based.CHIO.OriginalCHIO(problem, epoch=10000, pop_size=100, brr=0.06, max_age=150, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerThe original version of: Coronavirus Herd Immunity Optimization (CHIO)
- Links:
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
brr (float): [0.01, 0.2], Basic reproduction rate, default=0.06
max_age (int): [50, 200], Maximum infected cases age, default=150
Examples
>>> import numpy as np >>> from mealpy.human_based.CHIO import OriginalCHIO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> brr = 0.06 >>> max_age = 150 >>> model = OriginalCHIO(problem_dict1, epoch, pop_size, brr, max_age) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Al-Betar, M.A., Alyasseri, Z.A.A., Awadallah, M.A. et al. Coronavirus herd immunity optimizer (CHIO). Neural Comput & Applic 33, 5011–5042 (2021). https://doi.org/10.1007/s00521-020-05296-6
mealpy.human_based.FBIO¶
- class mealpy.human_based.FBIO.BaseFBIO(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerMy changed version of: Forensic-Based Investigation Optimization (FBIO)
Notes
I remove all the third loop, change a few equations and the flow of the algorithm
Examples
>>> import numpy as np >>> from mealpy.human_based.FBIO import BaseFBIO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = BaseFBIO(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- class mealpy.human_based.FBIO.OriginalFBIO(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.human_based.FBIO.BaseFBIOThe original version of: Forensic-Based Investigation Optimization (FBIO)
- Links:
Examples
>>> import numpy as np >>> from mealpy.human_based.FBIO import OriginalFBIO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = OriginalFBIO(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Chou, J.S. and Nguyen, N.M., 2020. FBI inspired meta-optimization. Applied Soft Computing, 93, p.106339.
mealpy.human_based.GSKA¶
- class mealpy.human_based.GSKA.BaseGSKA(problem, epoch=10000, pop_size=100, pb=0.1, kr=0.7, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerMy changed version of: Gaining Sharing Knowledge-based Algorithm (GSKA)
Notes
I remove all the third loop, remove 2 parameters
Solution represent junior or senior instead of dimension of solution
Change some equations for large-scale optimization
Apply the ideas of levy-flight and global best
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
pb (float): [0.1, 0.5], percent of the best (p in the paper), default = 0.1
kr (float): [0.5, 0.9], knowledge ratio, default = 0.7
Examples
>>> import numpy as np >>> from mealpy.human_based.GSKA import BaseGSKA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> pb = 0.1 >>> kr = 0.9 >>> model = BaseGSKA(problem_dict1, epoch, pop_size, pb, kr) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- class mealpy.human_based.GSKA.OriginalGSKA(problem, epoch=10000, pop_size=100, pb=0.1, kf=0.5, kr=0.9, kg=5, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerThe original version of: Gaining Sharing Knowledge-based Algorithm (GSKA)
- Links:
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
pb (float): [0.1, 0.5], percent of the best (p in the paper), default = 0.1
kf (float): [0.3, 0.8], knowledge factor that controls the total amount of gained and shared knowledge added from others to the current individual during generations, default = 0.5
kr (float): [0.5, 0.95], knowledge ratio, default = 0.9
kg (int): [3, 20], number of generations effect to D-dimension, default = 5
Examples
>>> import numpy as np >>> from mealpy.human_based.GSKA import OriginalGSKA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> pb = 0.1 >>> kf = 0.5 >>> kr = 0.9 >>> kg = 5 >>> model = OriginalGSKA(problem_dict1, epoch, pop_size, pb, kf, kr, kg) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Mohamed, A.W., Hadi, A.A. and Mohamed, A.K., 2020. Gaining-sharing knowledge based algorithm for solving optimization problems: a novel nature-inspired algorithm. International Journal of Machine Learning and Cybernetics, 11(7), pp.1501-1529.
mealpy.human_based.ICA¶
- class mealpy.human_based.ICA.BaseICA(problem, epoch=10000, pop_size=100, empire_count=5, assimilation_coeff=1.5, revolution_prob=0.05, revolution_rate=0.1, revolution_step_size=0.1, zeta=0.1, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerThe original version of: Imperialist Competitive Algorithm (ICA)
- Links:
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
empire_count (int): [3, 10], Number of Empires (also Imperialists)
assimilation_coeff (float): [1.0, 3.0], Assimilation Coefficient (beta in the paper)
revolution_prob (float): [0.01, 0.1], Revolution Probability
revolution_rate (float): [0.05, 0.2], Revolution Rate (mu)
revolution_step_size (float): [0.05, 0.2], Revolution Step Size (sigma)
zeta (float): [0.05, 0.2], Colonies Coefficient in Total Objective Value of Empires
Examples
>>> import numpy as np >>> from mealpy.human_based.ICA import BaseICA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> empire_count = 5 >>> assimilation_coeff = 1.5 >>> revolution_prob = 0.05 >>> revolution_rate = 0.1 >>> revolution_step_size = 0.1 >>> zeta = 0.1 >>> model = BaseICA(problem_dict1, epoch, pop_size, empire_count, assimilation_coeff, revolution_prob, revolution_rate, revolution_step_size, zeta) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Atashpaz-Gargari, E. and Lucas, C., 2007, September. Imperialist competitive algorithm: an algorithm for optimization inspired by imperialistic competition. In 2007 IEEE congress on evolutionary computation (pp. 4661-4667). Ieee.
mealpy.human_based.LCO¶
- class mealpy.human_based.LCO.BaseLCO(problem, epoch=10000, pop_size=100, r1=2.35, **kwargs)[source]¶
Bases:
mealpy.human_based.LCO.OriginalLCOMy changed version of: Life Choice-based Optimization (LCO)
Notes
I only change the flow with simpler if else statement than the original
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
r1 (float): [1.5, 4], coefficient factor, default = 2.35
Examples
>>> import numpy as np >>> from mealpy.human_based.LCO import BaseLCO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> r1 = 2.35 >>> model = BaseLCO(problem_dict1, epoch, pop_size, r1) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- class mealpy.human_based.LCO.ImprovedLCO(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerMy improved version of: Life Choice-based Optimization (ILCO)
Notes
The flow of the original LCO is kept.
Add gaussian distribution and mutation mechanism
Remove the hyper-parameter r1
Examples
>>> import numpy as np >>> from mealpy.human_based.LCO import BaseLCO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = BaseLCO(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- class mealpy.human_based.LCO.OriginalLCO(problem, epoch=10000, pop_size=100, r1=2.35, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerThe original version of: Life Choice-based Optimization (LCO)
- Links:
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
r1 (float): [1.5, 4], coefficient factor, default = 2.35
Examples
>>> import numpy as np >>> from mealpy.human_based.LCO import OriginalLCO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> r1 = 2.35 >>> model = OriginalLCO(problem_dict1, epoch, pop_size, r1) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Khatri, A., Gaba, A., Rana, K.P.S. and Kumar, V., 2020. A novel life choice-based optimizer. Soft Computing, 24(12), pp.9121-9141.
mealpy.human_based.QSA¶
- class mealpy.human_based.QSA.BaseQSA(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerMy changed version of: Queuing Search Algorithm (QSA)
Notes
All third loop is removed, the global best solution is used in business 3 instead of random solution
Examples
>>> import numpy as np >>> from mealpy.human_based.QSA import BaseQSA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = BaseQSA(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- class mealpy.human_based.QSA.ImprovedQSA(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.human_based.QSA.OppoQSA,mealpy.human_based.QSA.LevyQSAThe original version of: Improved Queuing Search Algorithm (QSA)
Examples
>>> import numpy as np >>> from mealpy.human_based.QSA import ImprovedQSA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = ImprovedQSA(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Nguyen, B.M., Hoang, B., Nguyen, T. and Nguyen, G., 2021. nQSV-Net: a novel queuing search variant for global space search and workload modeling. Journal of Ambient Intelligence and Humanized Computing, 12(1), pp.27-46.
- class mealpy.human_based.QSA.LevyQSA(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.human_based.QSA.BaseQSAMy Levy-flight version of: Queuing Search Algorithm (LQSA)
Notes
Added the Levy-flight technique to QSA
Examples
>>> import numpy as np >>> from mealpy.human_based.QSA import LevyQSA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = LevyQSA(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- class mealpy.human_based.QSA.OppoQSA(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.human_based.QSA.BaseQSAMy Opposition-based learning version of: Queuing Search Algorithm (OQSA)
Notes
Added the opposition-based learning technique
Examples
>>> import numpy as np >>> from mealpy.human_based.QSA import OppoQSA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = OppoQSA(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- class mealpy.human_based.QSA.OriginalQSA(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.human_based.QSA.BaseQSAThe original version of: Queuing Search Algorithm (QSA)
Examples
>>> import numpy as np >>> from mealpy.human_based.QSA import OriginalQSA >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = OriginalQSA(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Zhang, J., Xiao, M., Gao, L. and Pan, Q., 2018. Queuing search algorithm: A novel metaheuristic algorithm for solving engineering optimization problems. Applied Mathematical Modelling, 63, pp.464-490.
mealpy.human_based.SARO¶
- class mealpy.human_based.SARO.BaseSARO(problem, epoch=10000, pop_size=100, se=0.5, mu=50, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerMy changed version of: Search And Rescue Optimization (SARO)
Notes
All third loop is removed
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
se (float): [0.3, 0.8], social effect, default = 0.5
mu (int): [10, 100], maximum unsuccessful search number, default = 50
Examples
>>> import numpy as np >>> from mealpy.human_based.SARO import BaseSARO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> se = 0.5 >>> mu = 50 >>> model = BaseSARO(problem_dict1, epoch, pop_size, se, mu) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
- amend_position(position=None)[source]¶
If solution out of bound at dimension x, then it will re-arrange to random location in the range of domain
- Parameters
position – vector position (location) of the solution.
- Returns
Amended position
- class mealpy.human_based.SARO.OriginalSARO(problem, epoch=10000, pop_size=100, se=0.5, mu=50, **kwargs)[source]¶
Bases:
mealpy.human_based.SARO.BaseSAROThe original version of: Search And Rescue Optimization (SARO)
- Links:
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
se (float): [0.3, 0.8], social effect, default = 0.5
mu (int): [10, 100], maximum unsuccessful search number, default = 50
Examples
>>> import numpy as np >>> from mealpy.human_based.SARO import OriginalSARO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> se = 0.5 >>> mu = 50 >>> model = OriginalSARO(problem_dict1, epoch, pop_size, se, mu) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Shabani, A., Asgarian, B., Gharebaghi, S.A., Salido, M.A. and Giret, A., 2019. A new optimization algorithm based on search and rescue operations. Mathematical Problems in Engineering, 2019.
mealpy.human_based.SSDO¶
- class mealpy.human_based.SSDO.BaseSSDO(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerThe original version of: Social Ski-Driver Optimization (SSDO)
- Links:
Examples
>>> import numpy as np >>> from mealpy.human_based.SSDO import BaseSSDO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = BaseSSDO(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Tharwat, A. and Gabel, T., 2020. Parameters optimization of support vector machines for imbalanced data using social ski driver algorithm. Neural Computing and Applications, 32(11), pp.6925-6938.
- ID_LOC = 3¶
- ID_VEL = 2¶
- create_solution()[source]¶
- To get the position, fitness wrapper, target and obj list
A[self.ID_POS] –> Return: position
A[self.ID_TAR] –> Return: [target, [obj1, obj2, …]]
A[self.ID_TAR][self.ID_FIT] –> Return: target
A[self.ID_TAR][self.ID_OBJ] –> Return: [obj1, obj2, …]
- Returns
wrapper of solution with format [position, [target, [obj1, obj2, …]], velocity, best_local_position]
- Return type
list
mealpy.human_based.TLO¶
- class mealpy.human_based.TLO.BaseTLO(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.optimizer.OptimizerThe original version of: Teaching Learning-based Optimization (TLO)
Notes
Removed the third loop to make it faster
This version taken the advantages of numpy np.array to faster handler operations
The global best solution is used
Examples
>>> import numpy as np >>> from mealpy.human_based.TLO import BaseTLO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = BaseTLO(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Rao, R. and Patel, V., 2012. An elitist teaching-learning-based optimization algorithm for solving complex constrained optimization problems. international journal of industrial engineering computations, 3(4), pp.535-560.
- class mealpy.human_based.TLO.ITLO(problem, epoch=10000, pop_size=100, n_teachers=5, **kwargs)[source]¶
Bases:
mealpy.human_based.TLO.BaseTLOThe original version of: Improved Teaching-Learning-based Optimization (ITLO)
Notes
Removed the third loop to make it faster
Kinda similar to the paper, but the pseudo-code in the paper is not clear.
- Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
n_teachers (int): [3, 10], number of teachers in class, default=5
Examples
>>> import numpy as np >>> from mealpy.human_based.TLO import ITLO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = ITLO(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Rao, R.V. and Patel, V., 2013. An improved teaching-learning-based optimization algorithm for solving unconstrained optimization problems. Scientia Iranica, 20(3), pp.710-720.
- class mealpy.human_based.TLO.OriginalTLO(problem, epoch=10000, pop_size=100, **kwargs)[source]¶
Bases:
mealpy.human_based.TLO.BaseTLOThe original version of: Teaching Learning-based Optimization (TLO)
Notes
Removed the third loop to make it faster
This is slower version which inspired from link below
Examples
>>> import numpy as np >>> from mealpy.human_based.TLO import OriginalTLO >>> >>> def fitness_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict1 = { >>> "fit_func": fitness_function, >>> "lb": [-10, -15, -4, -2, -8], >>> "ub": [10, 15, 12, 8, 20], >>> "minmax": "min", >>> "verbose": True, >>> } >>> >>> epoch = 1000 >>> pop_size = 50 >>> model = OriginalTLO(problem_dict1, epoch, pop_size) >>> best_position, best_fitness = model.solve() >>> print(f"Solution: {best_position}, Fitness: {best_fitness}")
References
[1] Rao, R.V., Savsani, V.J. and Vakharia, D.P., 2011. Teaching–learning-based optimization: a novel method for constrained mechanical design optimization problems. Computer-aided design, 43(3), pp.303-315.