mealpy.math_based package
mealpy.math_based.AOA module
- class mealpy.math_based.AOA.OriginalAOA(epoch: int = 10000, pop_size: int = 100, alpha: float = 5, miu: float = 0.5, moa_min: float = 0.2, moa_max: float = 0.9, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Arithmetic Optimization Algorithm (AOA)
- 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.
alpha (float) – Fixed parameter, sensitive exploitation parameter, in range [2, 10]. Default is 5.
miu (float) – Fixed parameter, control parameter to adjust the search process, in range [0.1, 2.0]. Default is 0.5.
moa_min (float) – Range min of Math Optimizer Accelerated, in range (0.0, 0.41). Default is 0.2.
moa_max (float) – Range max of Math Optimizer Accelerated, in range (0.41, 1.0). Default is 0.9.
References
Abualigah, L., Diabat, A., Mirjalili, S., Abd Elaziz, M. and Gandomi, A.H., 2021. The arithmetic optimization algorithm. Computer methods in applied mechanics and engineering, 376, p.113609. https://doi.org/10.1016/j.cma.2020.113609
Examples
>>> import numpy as np >>> from mealpy import FloatVar, AOA >>> >>> 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 = AOA.OriginalAOA(epoch=1000, pop_size=50, alpha = 5, miu = 0.5, moa_min = 0.2, moa_max = 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='original', name='Arithmetic Optimization Algorithm', year=2021, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.CEM module
- class mealpy.math_based.CEM.OriginalCEM(epoch: int = 10000, pop_size: int = 100, n_best: int = 20, alpha: float = 0.7, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Cross-Entropy Method (CEM)
- 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.
n_best (int) – N selected solutions as a samples for next evolution, in range [2, int(pop_size/2)]. Default is 20.
alpha (float) – Weight factor for means and stdevs (normal distribution), in range (0.0, 1.0). Default is 0.7.
Links
References
De Boer, P.T., Kroese, D.P., Mannor, S. and Rubinstein, R.Y., 2005. A tutorial on the cross-entropy method. Annals of operations research, 134(1), pp.19-67.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, CEM >>> >>> 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 = CEM.OriginalCEM(epoch=1000, pop_size=50, n_best = 20, alpha = 0.7) >>> 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='Cross-Entropy Method', year=2005, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.CGO module
- class mealpy.math_based.CGO.OriginalCGO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Chaos Game Optimization (CGO)
- 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.
caution:: (..) –
4th seed is mutation process, but it is not clear mutation on multiple variables or 1 variable
There is no usage of the variable alpha 4th in the paper
The replacement of the worst solutions by generated seed are not clear (Lots of grammar errors in this section)
References
Talatahari, S. and Azizi, M., 2021. Chaos Game Optimization: a novel metaheuristic algorithm. Artificial Intelligence Review, 54(2), pp.917-1004. https://doi.org/10.1007/s10462-020-09867-w
Examples
>>> import numpy as np >>> from mealpy import FloatVar, CGO >>> >>> 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 = CGO.OriginalCGO(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='Chaos Game Optimization', year=2021, family=None, scientific_status='questionable', concerns=(<ScientificConcern.AMBIGUOUS_METHODOLOGY: 'ambiguous_methodology'>, <ScientificConcern.QUESTIONABLE_MATH: 'questionable_mathematical_model'>), evidence_urls=())
mealpy.math_based.CircleSA module
- class mealpy.math_based.CircleSA.OriginalCircleSA(epoch=10000, pop_size=100, c_factor=0.8, **kwargs)[source]
Bases:
OptimizerThe original version of: Circle Search Algorithm (CircleSA)
- 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.
c_factor (float) – C factor, in range (0.0, 1.0). Default is 0.8.
References
Qais, M. H., Hasanien, H. M., Turky, R. A., Alghuwainem, S., Tostado-Véliz, M., & Jurado, F. (2022). Circle Search Algorithm: A Geometry-Based Metaheuristic Optimization Algorithm. Mathematics, 10(10), 1626. https://doi.org/10.3390/math10101626
Examples
>>> import numpy as np >>> from mealpy import FloatVar, CircleSA >>> >>> 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 = CircleSA.OriginalCircleSA(epoch=1000, pop_size=50, c_factor=0.8) >>> 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='Circle Search Algorithm', year=2022, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.GBO module
- class mealpy.math_based.GBO.OriginalGBO(epoch: int = 10000, pop_size: int = 100, pr: float = 0.5, beta_min: float = 0.2, beta_max: float = 1.2, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Gradient-Based Optimizer (GBO)
- 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.
pr (float) – Probability Parameter, in range (0.0, 1.0). Default is 0.5.
beta_min (float) – Fixed parameter (no name in the paper), in range (0.0, 2.0). Default is 0.2.
beta_max (float) – Fixed parameter (no name in the paper), in range (0.0, 5.0). Default is 1.2.
References
Ahmadianfar, I., Bozorg-Haddad, O. and Chu, X., 2020. Gradient-based optimizer: A new metaheuristic optimization algorithm. Information Sciences, 540, pp.131-159. https://doi.org/10.1016/j.ins.2020.06.037
Examples
>>> import numpy as np >>> from mealpy import FloatVar, GBO >>> >>> 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 = GBO.OriginalGBO(epoch=1000, pop_size=50, pr = 0.5, beta_min = 0.2, beta_max = 1.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='medium', kind='original', name='Gradient-Based Optimizer', year=2020, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.HC module
- class mealpy.math_based.HC.OriginalHC(epoch: int = 10000, pop_size: int = 2, neighbour_size: int = 50, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Hill Climbing (HC)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size, in range [2, 10000]. Default is 2.
neighbour_size (int) – Fixed parameter, sensitive exploitation parameter, in range [2, 1000]. Default is 50.
Note
The number of neighbour solutions are equal to user defined
The step size to calculate neighbour group is randomized
HC is single-based solution, so the pop_size parameter is not matter in this algorithm
References
Mitchell, M., Holland, J. and Forrest, S., 1993. When will a genetic algorithm outperform hill climbing. Advances in neural information processing systems, 6.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, HC >>> >>> 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 = HC.OriginalHC(epoch=1000, pop_size=50, neighbour_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='Hill Climbing', year=1993, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.math_based.HC.SwarmHC(epoch=10000, pop_size=100, neighbour_size=10, **kwargs)[source]
Bases:
OptimizerThe developed version: Swarm-based Hill Climbing (S-HC)
- 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.
neighbour_size (int) – Fixed parameter, sensitive exploitation parameter, in range [2, pop_size/2]. Default is 10.
Note
Based on swarm-of people are trying to climb on the mountain idea
The number of neighbour solutions are equal to population size
- The step size to calculate neighbour is randomized and based on rank of solution.
The guys near on top of mountain will move slower than the guys on bottom of mountain.
Imagination: exploration when far from global best, and exploitation when near global best
Who on top of mountain first will be the winner. (global optimal)
Examples
>>> import numpy as np >>> from mealpy import FloatVar, HC >>> >>> 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 = HC.SwarmHC(epoch=1000, pop_size=50, neighbour_size = 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='easy', kind='developed', name='Swarm-based Hill Climbing', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.INFO module
- class mealpy.math_based.INFO.OriginalINFO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: weIghted meaN oF vectOrs (INFO)
- 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
Ahmadianfar, I., Heidari, A. A., Noshadian, S., Chen, H., & Gandomi, A. H. (2022). INFO: An efficient optimization algorithm based on weighted mean of vectors. Expert Systems with Applications, 195, 116516. https://doi.org/10.1016/j.eswa.2022.116516
Van Thieu, Nguyen, and Nguyen Van Son. “INFO Optimization Algorithm.” Encyclopedia of Engineering Optimization and Heuristics. Singapore: Springer Nature Singapore, 2026. 1-13. https://doi.org/10.1007/978-981-96-8165-5_58-1
Examples
>>> import numpy as np >>> from mealpy import FloatVar, INFO >>> >>> 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 = INFO.OriginalINFO(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='weIghted meaN oF vectOrs', year=2022, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.PSS module
- class mealpy.math_based.PSS.OriginalPSS(epoch: int = 10000, pop_size: int = 100, acceptance_rate: float = 0.9, sampling_method: str = 'LHS', **kwargs: object)[source]
Bases:
OptimizerThe original version of: Pareto-like Sequential Sampling (PSS)
- 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.
acceptance_rate (float) – The probability of accepting a solution in the normal range, in range (0.0, 1.0). Default is 0.9.
sampling_method (str) – ‘LHS’: Latin-Hypercube or ‘MC’: ‘MonteCarlo’, in [“MC”, “LHS”]. Default is “LHS”.
References
Shaqfa, M. and Beyer, K., 2021. Pareto-like sequential sampling heuristic for global optimisation. Soft Computing, 25(14), pp.9077-9096. https://doi.org/10.1007/s00500-021-05853-8
Examples
>>> import numpy as np >>> from mealpy import FloatVar, PSS >>> >>> 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 = PSS.OriginalPSS(epoch=1000, pop_size=50, acceptance_rate = 0.8, sampling_method = "LHS") >>> 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='Pareto-like Sequential Sampling', year=2021, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.RUN module
- class mealpy.math_based.RUN.OriginalRUN(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: RUNge Kutta Optimizer (RUN)
- 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
Ahmadianfar, I., Heidari, A. A., Gandomi, A. H., Chu, X., & Chen, H. (2021). RUN beyond the metaphor: An efficient optimization algorithm based on Runge Kutta method. Expert Systems with Applications, 181, 115079. https://doi.org/10.1016/j.eswa.2021.115079
Van Thieu, Nguyen, and Nguyen Thi Hanh. “RUN Optimization Algorithm.” Encyclopedia of Engineering Optimization and Heuristics. Singapore: Springer Nature Singapore, 2026. 1-10. https://doi.org/10.1007/978-981-96-8165-5_59-1
Examples
>>> import numpy as np >>> from mealpy import FloatVar, RUN >>> >>> 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 = RUN.OriginalRUN(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='RUNge Kutta Optimizer', year=2021, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.SCA module
- class mealpy.math_based.SCA.DevSCA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerOur developed version: Sine Cosine Algorithm (SCA)
- Parameters
epoch (int) – Maximum number of iterations. Default is 10000.
pop_size (int) – Number of population size. Default is 100.
Note
The flow and few equations are changed
Third loops are removed faster computational time
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SCA >>> >>> 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 = SCA.DevSCA(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='Sine Cosine Algorithm (Dev)', year=None, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.math_based.SCA.OriginalSCA(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
DevSCAThe original version of: Sine Cosine Algorithm (SCA)
- Parameters
epoch (int) – Maximum number of iterations. Default is 10000.
pop_size (int) – Number of population size. Default is 100.
Links
References
Mirjalili, S., 2016. SCA: a sine cosine algorithm for solving optimization problems. Knowledge-based systems, 96, pp.120-133.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SCA >>> >>> 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 = SCA.OriginalSCA(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='Sine Cosine Algorithm', year=2016, family=None, scientific_status='normal', concerns=(), evidence_urls=())
- class mealpy.math_based.SCA.QleSCA(epoch: int = 10000, pop_size: int = 100, alpha: float = 0.1, gama: float = 0.9, **kwargs: object)[source]
Bases:
DevSCAThe original version of: QLE Sine Cosine Algorithm (QLE-SCA)
- Parameters
epoch (int) – Maximum number of iterations. Default is 10000.
pop_size (int) – Number of population size. Default is 100.
alpha (float) – The learning rate, in range [0.0, 1.0]. Default is 0.1.
gama (float) – The discount factor, in range [0.0, 1.0]. Default is 0.9.
References
Hamad, Q. S., Samma, H., Suandi, S. A., & Mohamad-Saleh, J. (2022). Q-learning embedded sine cosine algorithm (QLESCA). Expert Systems with Applications, 193, 116417. https://doi.org/10.1016/j.eswa.2021.116417
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SCA >>> >>> 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 = SCA.QleSCA(epoch=1000, pop_size=50, alpha=0.1, gama=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='hard', kind='variant', name='QLE Sine Cosine Algorithm', year=2022, 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
mealpy.math_based.SHIO module
- class mealpy.math_based.SHIO.OriginalSHIO(epoch: int = 10000, pop_size: int = 100, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Success History Intelligent Optimizer (SHIO)
Links
Note
The algorithm is designed with simplicity and ease of implementation in mind, utilizing basic operators.
This algorithm has several limitations and weak when dealing with several problems
The algorithm’s convergence is slow. The Matlab code has many errors and unnecessary things.
References
Fakhouri, H. N., Hamad, F., & Alawamrah, A. (2022). Success history intelligent optimizer. The Journal of Supercomputing, 1-42.
Examples
>>> import numpy as np >>> from mealpy import FloatVar, SHIO >>> >>> 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 = SHIO.OriginalSHIO(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='Success History Intelligent Optimizer', year=2022, family=None, scientific_status='normal', concerns=(), evidence_urls=())
mealpy.math_based.TS module
- class mealpy.math_based.TS.OriginalTS(epoch: int = 10000, pop_size: int = 2, tabu_size: int = 5, neighbour_size: int = 10, perturbation_scale: float = 0.05, **kwargs: object)[source]
Bases:
OptimizerThe original version of: Tabu Search (TS)
- Parameters
epoch (int) – Maximum number of iterations, in range [1, 100000]. Default is 10000.
pop_size (int) – Number of population size. This is not an official parameter, in range [2, 10000]. Default is 2.
tabu_size (int) – Maximum size of the tabu list, in range [2, 10000]. Default is 5.
neighbour_size (int) – Size of the neighborhood for generating candidate solutions, in range [2, 10000]. Default is 10.
perturbation_scale (float) – Scale of the perturbations for generating candidate solutions, in range (0, 100). Default is 0.05.
Note
The pop_size is not an official parameter in this algorithm. However, we need it here to adapt to Mealpy library.
You should set pop_size = 2 to reduce the initial computation for the initial population of this algorithm.
The perturbation_scale is important parameter that effect the most to this algorithm.
References
Hajji, O., Brisset, S., & Brochet, P. (2004). A new tabu search method for optimization with continuous parameters. IEEE Transactions on Magnetics, 40(2), 1184-1187. https://doi.org/10.1109/TMAG.2004.824909
Examples
>>> import numpy as np >>> from mealpy import FloatVar, TS >>> >>> 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 = TS.OriginalTS(epoch=1000, pop_size=50, tabu_size = 5, neighbour_size = 20, perturbation_scale = 0.05) >>> 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='Tabu Search', year=2004, family=None, scientific_status='normal', concerns=(), evidence_urls=())