mealpy.human_based package
mealpy.human_based.AFT module
- class mealpy.human_based.AFT.OriginalAFT(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Ali baba and the Forty Thieves (AFT) optimizer
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
References
Braik, M., Ryalat, M. H., & Al-Zoubi, H. (2022). A novel meta-heuristic algorithm for solving numerical optimization problems: Ali Baba and the forty thieves. Neural Computing and Applications, 34(1), 409-455. https://doi.org/10.1007/s00521-021-06392-x
Examples
>>> import numpy as np >>> from mealpy import FloatVar, AFT >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = AFT.OriginalAFT(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='Ali baba and the Forty Thieves', year=2022, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.BRO module
- class mealpy.human_based.BRO.DevBRO(epoch: int = 10000, pop_size: int = 100, threshold: float = 3, **kwargs: object)[source]
Bases:
OptimizerOur developed version of: Battle Royale Optimization (BRO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
threshold (float) – Dead threshold, in range [1, 10]. Default is 3.
Note
The flow of algorithm is changed. Thrid loop is removed
References
Rahkar Farshi, T., 2021. Battle royale optimization algorithm. Neural Computing and Applications, 33(4), pp.1139-1157. https://doi.org/10.1007/s00521-020-05004-4
Examples
>>> import numpy as np >>> from mealpy import FloatVar, BRO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = BRO.DevBRO(epoch=1000, pop_size=50, threshold = 3) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='developed', name='Battle Royale Optimization (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- evolve(epoch)[source]
The main operations (equations) of algorithm. Inherit from Optimizer class
- Parameters
epoch (int) – The current iteration
- class mealpy.human_based.BRO.OriginalBRO(epoch: int = 10000, pop_size: int = 100, threshold: float = 3, **kwargs: object)[source]
Bases:
DevBROThe original version of: Battle Royale Optimization (BRO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
threshold (float) – Dead threshold, in range [1, 10]. Default is 3.
References
Rahkar Farshi, T., 2021. Battle royale optimization algorithm. Neural Computing and Applications, 33(4), pp.1139-1157. https://doi.org/10.1007/s00521-020-05004-4
Examples
>>> import numpy as np >>> from mealpy import FloatVar, BRO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = BRO.OriginalBRO(epoch=1000, pop_size=50, threshold = 3) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='Battle Royale Optimization', year=2021, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.BSO module
- class mealpy.human_based.BSO.ImprovedBSO(epoch: int = 10000, pop_size: int = 100, m_clusters: int = 5, p1: float = 0.25, p2: float = 0.5, p3: float = 0.75, p4: float = 0.5, **kwargs: object)[source]
Bases:
OptimizerOur improved version: Improved Brain Storm Optimization (IBSO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [10, 10000]. Default is 100.
m_clusters (int) – Number of clusters (m in the paper), in range [2, int(self.pop_size/5)]. Default is 5.
p1 (float) – 25% percent, in range (0.0, 1.0). Default is 0.25.
p2 (float) – 50% percent changed by its own (local search), 50% percent changed by outside (global search), in range (0.0, 1.0). Default is 0.5.
p3 (float) – 75% percent develop the old idea, 25% invented new idea based on levy-flight, in range (0.0, 1.0). Default is 0.75.
p4 (float) – Need more weights on the centers instead of the random position, in range (0.0, 1.0). Default is 0.5.
Note
Remove some probability parameters, and some unnecessary equations.
The Levy-flight technique is employed to enhance the algorithm’s robustness and resilience in challenging environments.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, BSO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = BSO.ImprovedBSO(epoch=1000, pop_size=50, m_clusters = 5, p1 = 0.25, p2 = 0.5, p3 = 0.75, p4 = 0.6) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='developed', name='Brain Storm Optimization (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.BSO.OriginalBSO(epoch: int = 10000, pop_size: int = 100, m_clusters: int = 5, p1: float = 0.2, p2: float = 0.8, p3: float = 0.4, p4: float = 0.5, slope: int = 20, **kwargs: object)[source]
Bases:
ImprovedBSOThe original version of: Brain Storm Optimization (BSO)
- Parameters
epoch (int) – Maximum number of iterations. Default is 10000.
pop_size (int) – Number of population size. Default is 100.
m_clusters (int) – Number of clusters (m in the paper). Default is 5.
p1 (float) – Probability percent, in range (0.0, 1.0). Default is 0.2.
p2 (float) – Probability percent changed by its own (local search), 50% percent changed by outside (global search), in range (0.0, 1.0). Default is 0.8.
p3 (float) – Probability percent develop the old idea, 25% invented new idea based on levy-flight, in range (0.0, 1.0). Default is 0.4.
p4 (float) – Probability. Default is 0.5.
slope (int) – Changing logsig() function’s slope (k: in the paper), in range [10, 50]. Default is 20.
References
Shi, Y., 2011, June. Brain storm optimization algorithm. In International conference in swarm intelligence (pp. 303-309). Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-21515-5_36
Examples
>>> import numpy as np >>> from mealpy import FloatVar, BSO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = BSO.OriginalBSO(epoch=1000, pop_size=50, m_clusters = 5, p1 = 0.2, p2 = 0.8, p3 = 0.4, p4 = 0.5, slope = 20) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Brain Storm Optimization', year=2011, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.CA module
- class mealpy.human_based.CA.OriginalCA(epoch: int = 10000, pop_size: int = 100, accepted_rate: float = 0.15, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Culture Algorithm (CA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
accepted_rate (float) – Probability of accepted rate, in range (0.0, 1.0). Default is 0.15.
References
Reynolds, R. G. (1994, February). An introduction to cultural algorithms. In Proceedings of the third annual conference on evolutionary programming (Vol. 24, No. 26, pp. 131-139). https://doi.org/10.1142/9789814534116
Examples
>>> import numpy as np >>> from mealpy import FloatVar, CA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = CA.OriginalCA(epoch=1000, pop_size=50, accepted_rate = 0.15) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='Culture Algorithm', year=1994, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.CDDO module
- class mealpy.human_based.CDDO.OriginalCDDO(epoch: int = 10000, pop_size: int = 100, pattern_size=10, creativity_rate=0.1, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Child Drawing Development Optimization (CCDO)
- Parameters
epoch (int) – Maximum number of iterations. Default is 10000.
pop_size (int) – Population size (number of trees). Default is 100.
pattern_size (int) – Size of the pattern matrix, in range [1, 1000]. Default is 10.
creativity_rate (float) – Creativity rate, in range [0.0, 1.0]. Default is 0.1.
Danger
This source code was converted from the original Matlab implementation in the paper into Python. The Matlab code itself has many issues, for example, parameters are defined but never used. Several variables are declared, such as p1, p2, p3. Parameters like child skill rate and child level rate are initialized as hyperparameters at the beginning, but inside the loop they are randomly generated, which is far from the paper.
Moreover, the biggest flaw of this algorithm lies in the if–else condition during the update process. There is a high chance that neither condition will be executed, because the golden ratio is not necessarily within the interval [1.5, 2], as it is computed based on a random position. In addition, when comparing the position with a random integer T (hand pressure), it is unclear why this is done. It is highly likely that the algorithm will only execute that single condition.
References
Abdulhameed, S., Rashid, T.A. Child Drawing Development Optimization Algorithm Based on Child’s Cognitive Development. Arab J Sci Eng 47, 1337–1351 (2022). https://doi.org/10.1007/s13369-021-05928-6
Examples
>>> import numpy as np >>> from mealpy import FloatVar, CDDO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = CDDO.OriginalCDDO(epoch=1000, pop_size=50, pattern_size=10, creativity_rate=0.1) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Child Drawing Development Optimization', year=2022, family=None, scientific_status='questionable', concerns=(<ScientificConcern.LACK_OF_NOVELTY: 'lack_of_novelty'>, <ScientificConcern.QUESTIONABLE_MATH: 'questionable_mathematical_model'>, <ScientificConcern.INCORRECT_EQUATIONS: 'incorrect_equations'>, <ScientificConcern.FABRICATED_RESULTS: 'fabricated_results'>), evidence_urls=())
mealpy.human_based.CHIO module
- class mealpy.human_based.CHIO.DevCHIO(epoch: int = 10000, pop_size: int = 100, brr: float = 0.15, max_age: int = 10, **kwargs: object)[source]
Bases:
OriginalCHIOOur developed version of: Coronavirus Herd Immunity Optimization (CHIO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
brr (float) – Basic reproduction rate, in range (0.0, 1.0). Default is 0.15.
max_age (int) – Maximum infected cases age, in range [1, 1+int(epoch/5)]. Default is 10.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, CHIO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = CHIO.DevCHIO(epoch=1000, pop_size=50, brr = 0.15, max_age = 10) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='developed', name='Coronavirus Herd Immunity Optimization (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.CHIO.OriginalCHIO(epoch: int = 10000, pop_size: int = 100, brr: float = 0.15, max_age: int = 10, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Coronavirus Herd Immunity Optimization (CHIO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
brr (float) – Basic reproduction rate, in range (0.0, 1.0). Default is 0.15.
max_age (int) – Maximum infected cases age, in range [1, 1+int(epoch/5)]. Default is 10.
References
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
Examples
>>> import numpy as np >>> from mealpy import FloatVar, CHIO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = CHIO.OriginalCHIO(epoch=1000, pop_size=50, brr = 0.15, max_age = 10) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Coronavirus Herd Immunity Optimization', year=2021, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.DOA module
- class mealpy.human_based.DOA.OriginalDOA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Dream Optimization Algorithm (DOA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
Links
Note
The Matlab code is sloppy and incorrect. Many variables are defined and computed but never actually used in the solution update process. For example, the variable fitness is calculated during the exploitation phase but not applied.
The agent’s position is also not updated properly, meaning it remains unchanged even after the supposed update in the Matlab code.
I suspect the results reported in this paper might not exist at all but were fabricated by the authors, since the benchmark functions are completely missing from the Matlab code.
References
Lang, Y., & Gao, Y. (2025). Dream Optimization Algorithm (DOA): A novel metaheuristic optimization algorithm inspired by human dreams and its applications to real-world engineering problems. Computer Methods in Applied Mechanics and Engineering, 436, 117718.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, DOA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = DOA.OriginalDOA(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='hard', kind='original', name='Dream Optimization Algorithm', year=2025, family=None, scientific_status='questionable', concerns=(<ScientificConcern.QUESTIONABLE_MATH: 'questionable_mathematical_model'>, <ScientificConcern.INCORRECT_EQUATIONS: 'incorrect_equations'>, <ScientificConcern.POOR_REPRODUCIBILITY: 'poor_reproducibility'>, <ScientificConcern.FABRICATED_RESULTS: 'fabricated_results'>), evidence_urls=())
mealpy.human_based.FBIO module
- class mealpy.human_based.FBIO.DevFBIO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerOur developed version: Forensic-Based Investigation Optimization (FBIO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
Note
Third loop is removed, the flowand a few equations is improved
Examples
>>> import numpy as np >>> from mealpy import FloatVar, FBIO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = FBIO.DevFBIO(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='developed', name='Forensic-Based Investigation Optimization (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.FBIO.OriginalFBIO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
DevFBIOThe original version of: Forensic-Based Investigation Optimization (FBIO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
Links
https://ww2.mathworks.cn/matlabcentral/fileexchange/76299-forensic-based-investigation-algorithm-fbi
References
Chou, J.S. and Nguyen, N.M., 2020. FBI inspired meta-optimization. Applied Soft Computing, 93, p.106339.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, FBIO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = FBIO.OriginalFBIO(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Forensic-Based Investigation Optimization', year=2020, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.GSKA module
- class mealpy.human_based.GSKA.DevGSKA(epoch: int = 10000, pop_size: int = 100, pb: float = 0.1, kr: float = 0.7, **kwargs: object)[source]
Bases:
OptimizerOur developed version: Gaining Sharing Knowledge-based Algorithm (GSKA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, n: pop_size, m: clusters, in range [5, 10000]. Default is 100.
pb (float) – Percent of the best 0.1%, 0.8%, 0.1% (p in the paper), in range (0.0, 1.0). Default is 0.1.
kr (float) – Knowledge ratio, in range (0.0, 1.0). Default is 0.7.
Note
Third loop is removed, 2 parameters is removed
Solution represent junior or senior instead of dimension of solution
Equations is based vector, can handle large-scale problem
Apply the ideas of levy-flight and global best
Keep the better one after updating process
Examples
>>> import numpy as np >>> from mealpy import FloatVar, GSKA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = GSKA.DevGSKA(epoch=1000, pop_size=50, pb = 0.1, kr = 0.9) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='developed', name='Gaining Sharing Knowledge-based Algorithm (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.GSKA.OriginalGSKA(epoch: int = 10000, pop_size: int = 100, pb: float = 0.1, kf: float = 0.5, kr: float = 0.9, kg: int = 5, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Gaining Sharing Knowledge-based Algorithm (GSKA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, n: pop_size, m: clusters, in range [5, 10000]. Default is 100.
pb (float) – Percent of the best 0.1%, 0.8%, 0.1% (p in the paper), in range (0.0, 1.0). Default is 0.1.
kf (float) – Knowledge factor that controls the total amount of gained and shared knowledge added from others to the current individual during generations, in range (0.0, 1.0). Default is 0.5.
kr (float) – Knowledge ratio, in range (0.0, 1.0). Default is 0.9.
kg (int) – Number of generations effect to D-dimension, in range [1, 1 + int(epoch / 2)]. Default is 5.
References
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. https://doi.org/10.1007/s13042-019-01053-x
Examples
>>> import numpy as np >>> from mealpy import FloatVar, GSKA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = GSKA.OriginalGSKA(epoch=1000, pop_size=50, pb = 0.1, kf = 0.5, kr = 0.9, kg = 5) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Gaining Sharing Knowledge-based Algorithm', year=2020, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.HBO module
- class mealpy.human_based.HBO.OriginalHBO(epoch: int = 10000, pop_size: int = 100, degree: int = 2, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Heap-based optimizer (HBO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
degree (int) – The degree level in Corporate Rank Hierarchy (CRH), in range [2, 10]. Default is 2.
Links
References
Askari, Q., Saeed, M., & Younas, I. (2020). Heap-based optimizer inspired by corporate rank hierarchy for global optimization. Expert Systems with Applications, 161, 113702.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, HBO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = HBO.OriginalHBO(epoch=1000, pop_size=50, degree = 3) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='hard', kind='original', name='Heap-based optimizer', year=2020, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.HCO module
- class mealpy.human_based.HCO.OriginalHCO(epoch: int = 10000, pop_size: int = 100, wfp: float = 0.65, wfv: float = 0.05, c1: float = 1.4, c2: float = 1.4, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Human Conception Optimizer (HCO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
wfp (float) – Weight factor for probability of fitness selection, in range [0.0, 1.0]. Default is 0.65.
wfv (float) – Weight factor for velocity update stage, in range [0.0, 1.0]. Default is 0.05.
c1 (float) – Acceleration coefficient, same as PSO, in range [0.0, 100.0]. Default is 1.4.
c2 (float) – Acceleration coefficient, same as PSO, in range [1.0, 100.0]. Default is 1.4.
Caution
This algorithm shares some similarities with the PSO algorithm (equations)
The implementation of Matlab code is kinda different to the paper
Links
References
Acharya, D., & Das, D. K. (2022). A novel Human Conception Optimizer for solving optimization problems. Scientific Reports, 12(1), 21631.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, HCO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = HCO.OriginalHCO(epoch=1000, pop_size=50, wfp=0.65, wfv=0.05, c1=1.4, c2=1.4) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Human Conception Optimizer', year=2022, family=None, scientific_status='questionable', concerns=(<ScientificConcern.LACK_OF_NOVELTY: 'lack_of_novelty'>, <ScientificConcern.SUSPECTED_PLAGIARISM: 'suspected_plagiarism'>, <ScientificConcern.POOR_REPRODUCIBILITY: 'poor_reproducibility'>, <ScientificConcern.FABRICATED_RESULTS: 'fabricated_results'>), evidence_urls=())
mealpy.human_based.ICA module
- class mealpy.human_based.ICA.OriginalICA(epoch: int = 10000, pop_size: int = 100, empire_count: int = 5, assimilation_coeff: float = 1.5, revolution_prob: float = 0.05, revolution_rate: float = 0.1, revolution_step_size: float = 0.1, zeta: float = 0.1, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Imperialist Competitive Algorithm (ICA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size (n: pop_size, m: clusters), in range [10, 10000]. Default is 100.
empire_count (int) – Number of Empires (also Imperialists), in range [2, 2 + int(pop_size / 5)]. Default is 5.
assimilation_coeff (float) – Assimilation Coefficient (beta in the paper), in range [1.0, 3.0]. Default is 1.5.
revolution_prob (float) – Revolution Probability, in range (0.0, 1.0). Default is 0.05.
revolution_rate (float) – Revolution Rate (mu), in range (0.0, 1.0). Default is 0.1.
revolution_step_size (float) – Revolution Step Size (sigma), in range (0.0, 1.0). Default is 0.1.
zeta (float) – Colonies Coefficient in Total Objective Value of Empires, in range (0.0, 1.0). Default is 0.1.
References
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. https://doi.org/10.1109/CEC.2007.4425083
Examples
>>> import numpy as np >>> from mealpy import FloatVar, ICA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = ICA.OriginalICA(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) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='hard', kind='original', name='Imperialist Competitive Algorithm', year=2007, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.ILA module
- class mealpy.human_based.ILA.OriginalILA(epoch: int = 10000, pop_size: int = 100, n_models: int = 5, p_s1: float = 0.33, p_s2: float = 0.33, b_min: float = 0.4, b_max: float = 0.6, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Incomprehensible but Intelligible-in-time Logics Algorithm (ILA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
n_models (int) – Number of models for grouping in Stage 1, in range [2, int(pop_size / 2)]. Default is 5.
p_s1 (float) – Maximum percentage of iterations in Stage 1, in range [0.01, 0.5]. Default is 0.33.
p_s2 (float) – Maximum percentage of iterations in Stage 2, in range [0.01, 0.5]. Default is 0.33.
b_min (float) – The minimum boundary for the parameters of IbI, in range [-10.0, 10.0]. Default is 0.4.
b_max (float) – The maximum boundary for the parameters of IbI, in range [-10.0, 10.0]. Default is 0.6.
Attention
This is one of the most complex and lengthiest algorithms we have ever implemented. The complexity stems from the group partitioning logic and various logical operations that do not match the real-world behaviors described in the paper.
This algorithm cannot be parallelized; furthermore, it evaluates a high number of function evaluations (NFEs) within a single iteration. Users should exercise caution when applying it to large-scale problems.
Aside from being complex, it also involves numerous parameters that heavily impact overall performance.
References
Mirrashid, M., & Naderpour, H. (2023). Incomprehensible but Intelligible-in-time logics: Theory and optimization algorithm. Knowledge-Based Systems, 264, 110305. https://doi.org/10.1016/j.knosys.2023.110305
Examples
>>> import numpy as np >>> from mealpy import FloatVar, ILA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "obj_func": objective_function, >>> "minmax": "min", >>> } >>> >>> model = ILA.OriginalILA(epoch=1000, pop_size=50, n_models=5, p_s1=0.33, p_s2=0.33, b_min=0.4, b_max=0.6) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='nightmare', kind='original', name='Incomprehensible but Intelligible-in-time Logics Algorithm', year=2023, family=None, scientific_status='questionable', concerns=(<ScientificConcern.LACK_OF_NOVELTY: 'lack_of_novelty'>, <ScientificConcern.POOR_REPRODUCIBILITY: 'poor_reproducibility'>), evidence_urls=())
mealpy.human_based.LCO module
- class mealpy.human_based.LCO.DevLCO(epoch: int = 10000, pop_size: int = 100, r1: float = 2.35, **kwargs: object)[source]
Bases:
OriginalLCOOur developed version: Life Choice-based Optimization (LCO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
r1 (float) – Coefficient factor, in range [1.0, 3.0]. Default is 2.35.
Note
The flow is changed with if else statement.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, LCO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = LCO.DevLCO(epoch=1000, pop_size=50, r1 = 2.35) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='developed', name='Life Choice-based Optimization (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.LCO.ImprovedLCO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerOur improved version: Life Choice-based Optimization (ILCO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
Note
The flow of the original LCO is kept.
Gaussian distribution and mutation mechanism are added
R1 parameter is removed
Examples
>>> import numpy as np >>> from mealpy import FloatVar, LCO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = LCO.ImprovedLCO(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='developed', name='Life Choice-based Optimization (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.LCO.OriginalLCO(epoch: int = 10000, pop_size: int = 100, r1: float = 2.35, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Life Choice-based Optimization (LCO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
r1 (float) – Coefficient factor, in range [1.0, 3.0]. Default is 2.35.
References
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. https://doi.org/10.1007/s00500-019-04443-z
Examples
>>> import numpy as np >>> from mealpy import FloatVar, LCO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = LCO.OriginalLCO(epoch=1000, pop_size=50, r1 = 2.35) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='Life Choice-based Optimization', year=2020, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.MGOA module
- class mealpy.human_based.MGOA.OriginalMGOA(epoch: int = 5000, pop_size: int = 50, attract_dim_rate=0.2, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Market Game Optimization Algorithm (MGOA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 5000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 50.
attract_dim_rate (float) – Number of dims will be changed in attraction phase under ratio format, in range (0.0, 1.0). Default is 0.2.
References
Liu, S., Xiang, Y., Guo, X., Zhao, F., Zhao, A., & Wu, W. (2025). Market Game Optimization Algorithm: A Metaheuristic Inspired by Symmetric Competitive Behavior of Merchants and Consumers. Symmetry, 17(12), 2118. https://doi.org/10.3390/sym17122118
Examples
>>> import numpy as np >>> from mealpy import FloatVar, MGOA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-100.,) * 30, ub=(100.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = MGOA.OriginalMGOA(epoch=1000, pop_size=50, attract_dim_rate=0.2) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='Market Game Optimization Algorithm', year=2025, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.PO module
- class mealpy.human_based.PO.OriginalPO(epoch: int = 10000, pop_size: int = 8, lamda_max: float = 1.0, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Political Optimizer (PO) Algorithm
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [2, 100]. Default is 8 (Please read the note below about this parameter).
lamda_max (float) – Upper limit of the party switching rate, in range [1.0, 100.0]. Default is 1.0.
Attention
pop_size: In this algorithm, the pop_size parameter corresponds to ‘n’ from the paper. It defines the number of political parties and the number of electoral constituencies.
Actual Population Size: The true number of candidate solutions generated and evaluated is pop_size ** 2. For example, setting pop_size = 8 (the paper’s recommended value) yields an actual working population of 64 candidates (8 parties * 8 candidates).
References
Askari, Q., Younas, I., & Saeed, M. (2020). Political Optimizer: A novel socio-inspired meta-heuristic for global optimization. Knowledge-based systems, 195, 105709. https://doi.org/10.1016/j.knosys.2020.105709
Examples
>>> import numpy as np >>> from mealpy import FloatVar, PO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = PO.OriginalPO(epoch=1000, pop_size=10, lamda_max=1.0) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='hard', kind='original', name='Political Optimizer', year=2020, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- evolve(epoch)[source]
The main operations (equations) of algorithm. Inherit from Optimizer class
- Parameters
epoch (int) – The current iteration
mealpy.human_based.QSA module
- class mealpy.human_based.QSA.DevQSA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerOur developed version: Queuing Search Algorithm (QSA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 5000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 50.
Note
The third loops are removed
Global best solution is used in business 3-th instead of random solution
References
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. https://doi.org/10.1016/j.apm.2018.06.036
Examples
>>> import numpy as np >>> from mealpy import FloatVar, QSA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = QSA.DevQSA(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='developed', name='Queuing Search Algorithm (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- calculate_queue_length__(t1, t2, t3)[source]
- Calculate length of each queue based on t1, t2,t3
t1 = t1 * 1.0e+100
t2 = t2 * 1.0e+100
t3 = t3 * 1.0e+100
- class mealpy.human_based.QSA.ImprovedQSA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
-
The original version of: Novel Queuing Search Variant (nQSV)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 5000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 50.
References
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. https://doi.org/10.1007/s12652-020-02849-4
Examples
>>> import numpy as np >>> from mealpy import FloatVar, QSA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = QSA.ImprovedQSA(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='variant', name='Novel Queuing Search Variant', year=2021, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.QSA.LevyQSA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
DevQSAOur Levy-flight version: Queuing Search Algorithm (LQSA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 5000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 50.
References
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. https://doi.org/10.1007/s12652-020-02849-4
Examples
>>> import numpy as np >>> from mealpy import FloatVar, QSA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = QSA.LevyQSA(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='developed', name='Queuing Search Algorithm (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.QSA.OppoQSA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
DevQSAOur opposition-based learning version: Queuing Search Algorithm (OQSA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 5000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 50.
References
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. https://doi.org/10.1007/s12652-020-02849-4
Examples
>>> import numpy as np >>> from mealpy import FloatVar, QSA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = QSA.OppoQSA(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='developed', name='Queuing Search Algorithm (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.QSA.OriginalQSA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
DevQSAThe original version of: Queuing Search Algorithm (QSA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 5000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 50.
References
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. https://doi.org/10.1016/j.apm.2018.06.036
Examples
>>> import numpy as np >>> from mealpy import FloatVar, QSA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = QSA.OriginalQSA(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Queuing Search Algorithm', year=2018, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.SARO module
- class mealpy.human_based.SARO.DevSARO(epoch: int = 10000, pop_size: int = 100, se: float = 0.5, mu: int = 15, **kwargs: object)[source]
Bases:
OptimizerOur developed version: Search And Rescue Optimization (SARO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
se (float) – Social effect, in range (0.0, 1.0). Default is 0.5.
mu (int) – Maximum unsuccessful search number, in range [2, 2 + int(pop_size / 2)]. Default is 15.
References
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. https://doi.org/10.1155/2019/2482543
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SARO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = SARO.DevSARO(epoch=1000, pop_size=50, se = 0.5, mu = 50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Search And Rescue Optimization', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- amend_solution(solution: ndarray) ndarray[source]
This function is based on optimizer’s strategy. In each optimizer, this function can be overridden
- Parameters
solution – The position
- Returns
The valid solution based on optimizer’s strategy
- class mealpy.human_based.SARO.OriginalSARO(epoch: int = 10000, pop_size: int = 100, se: float = 0.5, mu: int = 15, **kwargs: object)[source]
Bases:
DevSAROThe original version of: Search And Rescue Optimization (SARO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
se (float) – Social effect, in range (0.0, 1.0). Default is 0.5.
mu (int) – Maximum unsuccessful search number, in range [2, 2 + int(pop_size / 2)]. Default is 15.
References
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. https://doi.org/10.1155/2019/2482543
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SARO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = SARO.OriginalSARO(epoch=1000, pop_size=50, se = 0.5, mu = 50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='developed', name='Search And Rescue Optimization (Dev)', year=2019, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.SPBO module
- class mealpy.human_based.SPBO.DevSPBO(epoch=10000, pop_size=100, **kwargs)[source]
Bases:
OriginalSPBOOur developed version of: Student Psychology Based Optimization (SPBO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
Note
Replace uniform random number by normal random number
Sort the population and select 1/3 pop size for each category
References
Das, B., Mukherjee, V., & Das, D. (2020). Student psychology based optimization algorithm: A new population based optimization algorithm for solving optimization problems. Advances in Engineering software, 146, 102804. https://doi.org/10.1016/j.advengsoft.2020.102804
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SPBO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = SPBO.DevSPBO(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='developed', name='Student Psychology Based Optimization (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.SPBO.OriginalSPBO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Student Psychology Based Optimization (SPBO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
Links
References
Das, B., Mukherjee, V., & Das, D. (2020). Student psychology based optimization algorithm: A new population based optimization algorithm for solving optimization problems. Advances in Engineering software, 146, 102804.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SPBO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = SPBO.OriginalSPBO(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='Student Psychology Based Optimization', year=2020, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.SSDO module
- class mealpy.human_based.SSDO.OriginalSSDO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Social Ski-Driver Optimization (SSDO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
Links
References
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.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SSDO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = SSDO.OriginalSSDO(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='original', name='Social Ski-Driver Optimization', year=2020, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.TLO module
- class mealpy.human_based.TLO.ETLBO(epoch: int = 10000, pop_size: int = 100, elite_size: int = 4, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Elitist Teaching Learning-based Optimization (ETLBO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
elite_size (int) – Number of elite solutions, in range [1, pop_size/2]. Default is 4.
References
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. https://doi.org/10.5267/j.ijiec.2012.03.007
Examples
>>> import numpy as np >>> from mealpy import FloatVar, TLO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = TLO.ETLBO(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='medium', kind='variant', name='Elitist Teaching Learning-based Optimization', year=2012, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.TLO.ImprovedTLO(epoch: int = 10000, pop_size: int = 100, n_teachers: int = 5, **kwargs: object)[source]
Bases:
OriginalTLOThe original version of: Improved Teaching-Learning-based Optimization (ImprovedTLO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
n_teachers (int) – Number of teachers in class, in range [2, int(np.sqrt(pop_size) - 1)]. Default is 5.
References
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. https://doi.org/10.1016/j.scient.2012.12.005
Examples
>>> import numpy as np >>> from mealpy import FloatVar, TLO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = TLO.ImprovedTLO(epoch=1000, pop_size=50, n_teachers = 5) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='hard', kind='variant', name='Improved Teaching-Learning-based Optimization', year=2013, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.human_based.TLO.OriginalTLO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Teaching Learning-based Optimization (TLO)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
References
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. https://doi.org/10.1016/j.cad.2010.12.015
Examples
>>> import numpy as np >>> from mealpy import FloatVar, TLO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = TLO.OriginalTLO(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='Teaching Learning-based Optimization', year=2011, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.human_based.TOA module
- class mealpy.human_based.TOA.OriginalTOA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Teamwork Optimization Algorithm (TOA)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
danger:: (..) –
Algorithm design is similar to Zebra Optimization Algorithm (ZOA), Osprey Optimization Algorithm (OOA), Coati Optimization Algorithm (CoatiOA), Siberian Tiger Optimization (STO), Language Education Optimization (LEO), Serval Optimization Algorithm (SOA), Walrus Optimization Algorithm (WOA), Fennec Fox Optimization (FFO), Three-periods optimization algorithm (TPOA), Pelican Optimization Algorithm (POA), Northern goshawk optimization (NGO), Tasmanian devil optimization (TDO), Archery algorithm (AA), Cat and mouse based optimizer (CMBO)
It may be useful to compare the Matlab code of this algorithm with those of the similar algorithms to ensure its accuracy and completeness.
While this article may share some similarities with previous work by the same authors, it is important to recognize the potential value in exploring different meta-metaphors and concepts to drive innovation and progress in optimization research.
Further investigation may be warranted to verify the benchmark results reported in the papers and ensure their reliability and accuracy.
References
Dehghani, M., & Trojovský, P. (2021). Teamwork optimization algorithm: A new optimization approach for function minimization/maximization. Sensors, 21(13), 4567. https://doi.org/10.3390/s21134567
Examples
>>> import numpy as np >>> from mealpy import FloatVar, TOA >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = TOA.OriginalTOA(epoch=1000, pop_size=50) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='Teamwork Optimization Algorithm', year=2021, family=None, scientific_status='under_investigation', concerns=(<ScientificConcern.LACK_OF_NOVELTY: 'lack_of_novelty'>, <ScientificConcern.RESEARCH_MISCONDUCT: 'research_misconduct'>, <ScientificConcern.FABRICATED_RESULTS: 'fabricated_results'>, <ScientificConcern.SUSPECTED_SELF_PLAGIARISM: 'suspected_self_plagiarism'>), evidence_urls=())
mealpy.human_based.WarSO module
- class mealpy.human_based.WarSO.OriginalWarSO(epoch: int = 10000, pop_size: int = 100, rr: float = 0.1, **kwargs: object)[source]
Bases:
OptimizerThe original version of: War Strategy Optimization (WarSO) algorithm
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [5, 10000]. Default is 100.
rr (float) – The probability of switching position updating, in range (0.0, 1.0). Default is 0.1.
References
Ayyarao, Tummala SLV, and Polamarasetty P. Kumar. “Parameter estimation of solar PV models with a new proposed war strategy optimization algorithm.” International Journal of Energy Research (2022). https://doi.org/10.1002/er.7629
Examples
>>> import numpy as np >>> from mealpy import FloatVar, WarSO >>> >>> def objective_function(solution): >>> return np.sum(solution**2) >>> >>> problem_dict = { >>> "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"), >>> "minmax": "min", >>> "obj_func": objective_function >>> } >>> >>> model = WarSO.OriginalWarSO(epoch=1000, pop_size=50, rr=0.1) >>> g_best = model.solve(problem_dict) >>> print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}") >>> print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")
- OPT_INFO: ClassVar[OptInfo | None] = OptInfo(difficulty='easy', kind='original', name='War Strategy Optimization', year=2022, family=None, scientific_status='normal', concerns=(), evidence_urls=())