API (Python)
The Python API allows you to use MinionPy’s algorithms and functions within Python applications.
- class minionpy.parallel.Process_Parallel(Nprocesses, class_name, *args, **kwargs)[source]
Bases:
objectParallelizes the evaluation of an objective function using multiple processes.
This class uses a process pool executor to parallelize the evaluation of the objective function across multiple processes. Each process is provided its own instance of the class_name class, ensuring independence between processes and enabling the use of multiple CPU cores for computation.
Working Principle:
When the objective method is called, a list of inputs (X) is passed, and the function evaluations are distributed across the available processes.
Each process calls the __get_instance method, which ensures that each process gets its own instance of the class class_name. This avoids issues that may arise when sharing objects between processes.
The __calc_func method evaluates the objective function for each input x by calling the objective_function method of the process-local instance.
The results are collected from the processes as they complete, and the final output is returned after all evaluations have finished.
Parameters
- Nprocessesint
The number of processes to use for parallel processing.
- class_nameclass
The class containing the ‘objective_function’ method.
- argstuple
Positional arguments passed to the class constructor.
- kwargsdict
Keyword arguments passed to the class constructor.
Raises
- ValueError
If the provided class does not have an ‘objective_function’ method, which is required for the parallel execution.
Attributes
- Nprocessesint
The number of processes to use.
- class_nameclass
The class that provides the ‘objective_function’ method.
- argstuple
Positional arguments passed to class_name’s constructor.
- kwargsdict
Keyword arguments passed to class_name’s constructor.
- executorProcessPoolExecutor
Executor used to manage the parallel processes.
- __call__(X)[source]
Allows the object to be called directly.
Parameters
- Xlist[list[float]]
A list of input arrays to evaluate the objective function.
Returns
- list of float
A list containing the results of the objective function evaluations.
- __dict__ = mappingproxy({'__module__': 'minionpy.parallel', '__doc__': "\n Parallelizes the evaluation of an objective function using multiple processes.\n\n This class uses a process pool executor to parallelize the evaluation of the \n objective function across multiple processes. Each process is provided its own \n instance of the `class_name` class, ensuring independence between processes \n and enabling the use of multiple CPU cores for computation.\n\n Working Principle:\n\n - When the `objective` method is called, a list of inputs (`X`) is passed, and the \n function evaluations are distributed across the available processes.\n - Each process calls the `__get_instance` method, which ensures that each process \n gets its own instance of the class `class_name`. This avoids issues that may arise \n when sharing objects between processes.\n - The `__calc_func` method evaluates the objective function for each input `x` by \n calling the `objective_function` method of the process-local instance.\n - The results are collected from the processes as they complete, and the final output \n is returned after all evaluations have finished.\n\n Parameters\n ----------\n Nprocesses : int\n The number of processes to use for parallel processing.\n class_name : class\n The class containing the 'objective_function' method.\n args : tuple\n Positional arguments passed to the class constructor.\n kwargs : dict\n Keyword arguments passed to the class constructor.\n \n Raises\n ------\n ValueError\n If the provided class does not have an 'objective_function' method, \n which is required for the parallel execution.\n\n Attributes\n ----------\n Nprocesses : int\n The number of processes to use.\n class_name : class\n The class that provides the 'objective_function' method.\n args : tuple\n Positional arguments passed to `class_name`'s constructor.\n kwargs : dict\n Keyword arguments passed to `class_name`'s constructor.\n executor : ProcessPoolExecutor\n Executor used to manage the parallel processes.\n ", '__init__': <function Process_Parallel.__init__>, '__del__': <function Process_Parallel.__del__>, 'objective': <function Process_Parallel.objective>, 'cleanUp': <function Process_Parallel.cleanUp>, '__call__': <function Process_Parallel.__call__>, '__dict__': <attribute '__dict__' of 'Process_Parallel' objects>, '__weakref__': <attribute '__weakref__' of 'Process_Parallel' objects>, '__annotations__': {}})
- __init__(Nprocesses, class_name, *args, **kwargs)[source]
Initializes the Parallel object with a specified number of processes.
Parameters
- Nprocessesint
The number of processes to use for parallel execution.
- class_nameclass
The class that contains the ‘objective_function’ method.
- argstuple
Positional arguments passed to the class constructor.
- kwargsdict
Keyword arguments passed to the class constructor.
- __module__ = 'minionpy.parallel'
- __weakref__
list of weak references to the object
- class minionpy.parallel.Thread_Parallel(Nthreads, class_name, *args, **kwargs)[source]
Bases:
objectParallelizes the evaluation of an objective function using multiple threads.
This class uses a thread pool executor to parallelize the evaluation of the objective function across multiple threads. Each thread is provided its own instance of the class_name class, ensuring thread safety and allowing the objective function to be evaluated independently on each input.
Working Principle:
When the objective method is called, a list of inputs (X) is passed, and the function evaluations are distributed across the available threads.
Each thread calls the __get_instance method, which ensures that each thread gets its own instance of the class class_name. This avoids race conditions by ensuring that each thread works with a separate object.
The __calc_func method evaluates the objective function for each input x by calling the objective_function method of the thread-local instance.
The results are collected from the threads as they complete, and the final output is returned after all evaluations have finished.
Parameters
- Nthreadsint
The number of threads to use for parallel processing.
- class_nameclass
The class containing the ‘objective_function’ method.
- argstuple
Positional arguments passed to the class constructor.
- kwargsdict
Keyword arguments passed to the class constructor.
Raises
ValueError : If the provided class does not have an ‘objective_function’ method.
- __call__(X)[source]
Allows the object to be called directly.
Parameters
- Xlist of list of float
A list of input arrays to evaluate the objective function.
Returns
- list of float
A list containing the results of the objective function evaluations.
- __dict__ = mappingproxy({'__module__': 'minionpy.parallel', '__doc__': "\n Parallelizes the evaluation of an objective function using multiple threads.\n\n This class uses a thread pool executor to parallelize the evaluation of the \n objective function across multiple threads. Each thread is provided its own \n instance of the `class_name` class, ensuring thread safety and allowing \n the objective function to be evaluated independently on each input. \n\n Working Principle:\n\n - When the `objective` method is called, a list of inputs (`X`) is passed, and the \n function evaluations are distributed across the available threads.\n - Each thread calls the `__get_instance` method, which ensures that each thread \n gets its own instance of the class `class_name`. This avoids race conditions by \n ensuring that each thread works with a separate object.\n - The `__calc_func` method evaluates the objective function for each input `x` by \n calling the `objective_function` method of the thread-local instance.\n - The results are collected from the threads as they complete, and the final output \n is returned after all evaluations have finished.\n\n Parameters\n ----------\n Nthreads : int\n The number of threads to use for parallel processing.\n class_name : class\n The class containing the 'objective_function' method.\n args : tuple\n Positional arguments passed to the class constructor.\n kwargs : dict\n Keyword arguments passed to the class constructor.\n \n Raises\n ------\n ValueError : If the provided class does not have an 'objective_function' method.\n ", '__init__': <function Thread_Parallel.__init__>, '__del__': <function Thread_Parallel.__del__>, '_Thread_Parallel__get_instance': <function Thread_Parallel.__get_instance>, '_Thread_Parallel__calc_func': <function Thread_Parallel.__calc_func>, 'objective': <function Thread_Parallel.objective>, 'cleanUp': <function Thread_Parallel.cleanUp>, '__call__': <function Thread_Parallel.__call__>, '__dict__': <attribute '__dict__' of 'Thread_Parallel' objects>, '__weakref__': <attribute '__weakref__' of 'Thread_Parallel' objects>, '__annotations__': {}})
- __init__(Nthreads, class_name, *args, **kwargs)[source]
Initializes the Thread_Parallel object with the specified number of threads.
Parameters
- Nthreadsint
The number of threads to use for parallel execution.
- class_nameclass
The class that contains the ‘objective_function’ method.
- argstuple
Positional arguments passed to the class constructor.
- kwargsdict
Keyword arguments passed to the class constructor.
- __module__ = 'minionpy.parallel'
- __weakref__
list of weak references to the object
- class minionpy.algorithms.ABC(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the artifical bee colony optimization algorithm.
Inherits from MinimizerBase and implements the optimization algorithm.
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the artifical bee colony optimization algorithm.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function ABC.__init__>, 'optimize': <function ABC.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "population_size" : 0, "mutation_strategy" : "rand1, "bound_strategy" : "reflect-random" }
The available options are:
- population_size (int): Initial population size (N). If set to 0, it will be automatically determined.
- \[N = 5 \cdot D\]
where D is the dimensionality of the problem.
mutation_strategy (str): Mutation strategy, default is “rand1”, available : “rand1”, “best1”
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppABC.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.AGSK(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the Adaptive Gaining-Sharing Knowledge-based (AGSK) algorithm.
- Reference:
Mohamed, A. A. Hadi, A. K. Mohamed and N. H. Awad, “Evaluating the Performance of Adaptive GainingSharing Knowledge Based Algorithm on CEC 2020 Benchmark Problems,” 2020 IEEE Congress on Evolutionary Computation (CEC), Glasgow, UK, 2020, pp. 1-8, doi: 10.1109/CEC48606.2020.9185901.
AGSK organizes its search into junior and senior gaining-sharing phases with adaptive knowledge pools, success-based probability updates, and an AGSK-style population reduction schedule. It proved highly competitive on the CEC 2020 benchmark suite.
Options accepted via
options(defaults shown){ "population_size" : 0, # auto -> 40*D if D>5 else 100 "minimum_population_size" : 12, "bound_strategy" : "reflect-random" }
Notes
Setting
population_sizeto0reproduces the reference scaling rule.minimum_population_sizeenforces the terminal population cap during nonlinear reduction.Boundary handling reuses Minion’s standard strategies (
"random","reflect","reflect-random","clip","periodic","none").
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the Adaptive Gaining-Sharing Knowledge-based (AGSK) algorithm.\n\n Reference:\n A. W. Mohamed, A. A. Hadi, A. K. Mohamed and N. H. Awad, "Evaluating the Performance of Adaptive GainingSharing Knowledge Based Algorithm on CEC 2020 Benchmark Problems," 2020 IEEE Congress on Evolutionary Computation (CEC), Glasgow, UK, 2020, pp. 1-8, doi: 10.1109/CEC48606.2020.9185901.\n\n AGSK organizes its search into junior and senior gaining-sharing phases with adaptive\n knowledge pools, success-based probability updates, and an AGSK-style population\n reduction schedule. It proved highly competitive on the CEC 2020 benchmark suite.\n\n Options accepted via ``options`` (defaults shown) ::\n\n {\n "population_size" : 0, # auto -> 40*D if D>5 else 100\n "minimum_population_size" : 12,\n "bound_strategy" : "reflect-random"\n }\n\n Notes\n -----\n - Setting ``population_size`` to ``0`` reproduces the reference scaling rule.\n - ``minimum_population_size`` enforces the terminal population cap during\n nonlinear reduction.\n - Boundary handling reuses Minion\'s standard strategies (``"random"``,\n ``"reflect"``, ``"reflect-random"``, ``"clip"``, ``"periodic"``, ``"none"``).\n ', '__init__': <function AGSK.__init__>, 'optimize': <function AGSK.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the MinimizerBase class.
Parameters
- funccallable
Objective function to be minimized. Must accept list[list[float]]. If the function operates on a single sample, it should be vectorized.
- boundslist of tuple
List of (lower, upper) bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. Note that Minion assumes multiple initial guesses, thus, x0 is a list[list[float]] object. These guesses will be used for population initialization.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops when the relative improvement falls below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called at each iteration. It must accept the current optimization state as an argument.
- seedint, optional
Random seed for reproducibility. If None, a random seed is used.
- optionsdict, optional
Additional algorithm-specific parameters. If None, default settings are used.
Raises
- TypeError
If any of the input parameters are of an incorrect type.
- ValueError
If x0 has a different length than bounds, or if bounds are not properly formatted.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- class minionpy.algorithms.ARRDE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the Adaptive Restart Refine Differential Evolution (ARRDE) algorithm.
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the Adaptive Restart Refine Differential Evolution (ARRDE) algorithm.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function ARRDE.__init__>, 'optimize': <function ARRDE.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the ARRDE optimizer.
- Parameters:
func – Objective function. Expected signature is
func(X) -> list[float], whereXis a batch (list/array) of candidate vectors.bounds – List of
(min, max)bounds for each decision variable.x0 – Optional initial guesses as
list[list[float]].relTol – Relative convergence tolerance. Default is
1e-4.maxevals – Maximum number of objective evaluations. Default is
100000.callback – Optional callback invoked after each iteration.
seed – Optional random seed.
options –
Optional algorithm settings. Defaults to
{"population_size": 0, "bound_strategy": "reflect-random"}. Supported keys:population_size(int): Initial population size.bound_strategy(str): Boundary handling strategy:"random","reflect-random", or"clip".
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.BIPOP_aCMAES(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the BIPOP Adaptive Covariance Matrix Adaptation Evolution Strategy (BIPOP aCMA-ES).
Reference : Nikolaus Hansen. 2009. Benchmarking a BI-population CMA-ES on the BBOB-2009 function testbed. In Proceedings of the 11th Annual Conference Companion on Genetic and Evolutionary Computation Conference: Late Breaking Papers (GECCO ‘09). Association for Computing Machinery, New York, NY, USA, 2389–2396. https://doi.org/10.1145/1570256.1570333
This class inherits from MinimizerBase.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': "\n Implementation of the BIPOP Adaptive Covariance Matrix Adaptation Evolution Strategy (BIPOP aCMA-ES).\n\n Reference : Nikolaus Hansen. 2009. Benchmarking a BI-population CMA-ES on the BBOB-2009 function testbed. In Proceedings of the 11th Annual Conference Companion on Genetic and Evolutionary Computation Conference: Late Breaking Papers (GECCO '09). Association for Computing Machinery, New York, NY, USA, 2389–2396. https://doi.org/10.1145/1570256.1570333\n\n This class inherits from `MinimizerBase`.\n ", '__init__': <function BIPOP_aCMAES.__init__>, 'optimize': <function BIPOP_aCMAES.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]
Initialize the BIPOP aCMA-ES algorithm.
Parameters
- funccallable
Vectorised objective function returning a list of objective values.
- boundslist of tuple
Bounds for each decision variable.
- x0list[list[float]], optional
Optional collection of initial guesses. When multiple candidates are supplied, the best according to
funcseeds the initial mean.- relTolfloat, optional
Relative tolerance used by the stopping criterion. Default
1e-4.- maxevalsint, optional
Maximum number of function evaluations. Default
100000.- callbackcallable, optional
User callback receiving intermediate
MinionResultobjects.- seedint, optional
Seed for the pseudo-random number generator.
Nonekeeps the global RNG state.- optionsdict, optional
Additional CMA-ES configuration. If
Nonethe following defaults are applied:options = { "population_size" : 0, # If 0, determined automatically "max_restarts" : 8, # Maximum number of adaptive restarts "max_iterations" : 5000, # Max iterations per run "initial_step" : 0.3, # Initial CMA-ES step size (sigma) "bound_strategy" : "reflect-random" # Boundary handling }
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize() MinionResult[source]
- class minionpy.algorithms.CMAES(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the Covariance Matrix Adaptation Evolution Strategy (CMA-ES).
Reference : Hansen, N. and Ostermeier, A., “Adapting Arbitrary Normal Mutation Distributions in Evolution Strategies,” 1996.
This class inherits from MinimizerBase.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the Covariance Matrix Adaptation Evolution Strategy (CMA-ES).\n\n Reference : Hansen, N. and Ostermeier, A., "Adapting Arbitrary Normal Mutation\n Distributions in Evolution Strategies," 1996.\n\n This class inherits from `MinimizerBase`.\n ', '__init__': <function CMAES.__init__>, 'optimize': <function CMAES.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]
Initialize the CMA-ES algorithm.
Parameters
- funccallable
Vectorised objective function returning a list of objective values.
- boundslist of tuple
Bounds for each decision variable.
- x0list[list[float]], optional
Optional collection of initial guesses. When multiple candidates are supplied, the best according to
funcseeds the initial mean.- relTolfloat, optional
Relative tolerance used by the stopping criterion. Default
1e-4.- maxevalsint, optional
Maximum number of function evaluations. Default
100000.- callbackcallable, optional
User callback receiving intermediate
MinionResultobjects.- seedint, optional
Seed for the pseudo-random number generator.
Nonekeeps the global RNG state.- optionsdict, optional
Additional CMA-ES configuration. If
Nonethe following defaults are applied:options = { "population_size" : 0, "mu" : 0, "initial_step" : 0.3, "cc" : 0.0, "cs" : 0.0, "c1" : 0.0, "cmu" : 0.0, "damps" : 0.0, "bound_strategy" : "reflect-random" }
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize() MinionResult[source]
- class minionpy.algorithms.CalllbackWrapper(callback)[source]
Bases:
objectWraps a Python function that takes cppMinionResult as an argument to work with MinionResult.
Converts a callback function from working with cppMinionResult to MinionResult.
- __call__(minRes)[source]
Invoke the callback function with a MinionResult object.
Parameters: - minRes: MinionResult object to pass to the callback function.
Returns: - Result of the callback function.
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Wraps a Python function that takes cppMinionResult as an argument to work with MinionResult.\n \n Converts a callback function from working with cppMinionResult to MinionResult.\n ', '__init__': <function CalllbackWrapper.__init__>, '__call__': <function CalllbackWrapper.__call__>, '__dict__': <attribute '__dict__' of 'CalllbackWrapper' objects>, '__weakref__': <attribute '__weakref__' of 'CalllbackWrapper' objects>, '__annotations__': {}})
- __init__(callback)[source]
Initialize CallbackWrapper.
Parameters: - callback: A function that takes cppMinionResult as an argument.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- class minionpy.algorithms.DMSPSO(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseDynamic multi-swarm PSO with periodic regrouping and co-operative subswarms.
Options
population_size(int): swarm size (defaults to5 * Dwhen 0).inertia_weight(float),cognitive_coefficient(float),social_coefficient(float): base PSO coefficients.local_coefficient(float): influence of the subswarm best (default1.4).global_coefficient(float): influence of the global best (default0.8).subswarm_count(int): number of dynamic subswarms (default4).regroup_period(int): iterations between subswarm reshuffles (default5).velocity_clamp(float): fraction of the search range used as the velocity limit (default0.2).bound_strategy(str): boundary handling policy ("reflect-random"by default).
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Dynamic multi-swarm PSO with periodic regrouping and co-operative subswarms.\n\n Options\n -------\n - ``population_size`` (*int*): swarm size (defaults to ``5 * D`` when 0).\n - ``inertia_weight`` (*float*), ``cognitive_coefficient`` (*float*), ``social_coefficient`` (*float*): base PSO coefficients.\n - ``local_coefficient`` (*float*): influence of the subswarm best (default ``1.4``).\n - ``global_coefficient`` (*float*): influence of the global best (default ``0.8``).\n - ``subswarm_count`` (*int*): number of dynamic subswarms (default ``4``).\n - ``regroup_period`` (*int*): iterations between subswarm reshuffles (default ``5``).\n - ``velocity_clamp`` (*float*): fraction of the search range used as the velocity limit (default ``0.2``).\n - ``bound_strategy`` (*str*): boundary handling policy (``"reflect-random"`` by default).\n ', '__init__': <function DMSPSO.__init__>, 'optimize': <function DMSPSO.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]
Initialize the DMS-PSO algorithm.
Parameters
- func, bounds, x0, relTol, maxevals, callback, seed, options :
See
PSOfor the base semantics.
Notes
Additional entries recognised in
options:local_coefficient (float): Weight applied to the sub-swarm best (default
1.4).global_coefficient (float): Weight applied to the global best (default
0.8).subswarm_count (int): Number of concurrent sub-swarms.
regroup_period (int): Iterations between sub-swarm reshuffles.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize() MinionResult[source]
- class minionpy.algorithms.Differential_Evolution(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the vanilla (original) Differential Evolution algorithm.
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the vanilla (original) Differential Evolution algorithm.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function Differential_Evolution.__init__>, 'optimize': <function Differential_Evolution.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "population_size" : 0, "mutation_strategy" : "best1bin", "mutation_rate" : 0.5, "crossover_rate" : 0.8, "bound_strategy" : "reflect-random" }
The available options are:
- population_size (int): Initial population size (N). If set to 0, it will be automatically determined.
- \[N = 5 \cdot D\]
where D is the dimensionality of the problem.
- mutation_strategy (str): Mutation strategy used in the optimization process. Available strategies:
"best1bin","best1exp","rand1bin","rand1exp","current_to_pbest1bin","current_to_pbest1exp".
mutation_rate (float): the value of the mutation rate (F).
crossover_rate (float): the value of the crossover rate (F).
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppDifferential_Evolution.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.Dual_Annealing(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of dual annealing algorithm.
Reference : Tsallis C, Stariolo DA. Generalized Simulated Annealing. Physica A, 233, 395-406 (1996).
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of dual annealing algorithm.\n\n Reference : Tsallis C, Stariolo DA. Generalized Simulated Annealing. Physica A, 233, 395-406 (1996).\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function Dual_Annealing.__init__>, 'optimize': <function Dual_Annealing.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]]
Initial guesses for the solution. If more than one initial guesses are provided, the code will pick the best one as the true initial guess.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "acceptance_par" : -5.0, "visit_par" : 2.67, "initial_temp" : 5230.0, "restart_temp_ratio" : 2e-05, "use_local_search": True, "local_search_algo" : "L_BFGS_B", "finite_diff_rel_step", 1e-10, "bound_strategy" : "periodic" }
The available options are:
acceptance_par (double) : acceptance parameter. The value must be between -1.0e+4 and -5.
visit_par (double) : visiting distribution parameter. The value must be between 1.0 and 3.0.
initial_temp (double) : initial temperature. The value must be between 0.01 and 5.0e+4.
restart_temp_ratio (double) : restart temperature ratio. The value must be between 0 and 1.
use_local_search (bool) : a flag to whether or not to use local search.
local_search_algo (str) : Algorithm name for local search. Available : “NelderMead” or “L_BFGS_B”.
finite_diff_rel_step (double) : The relative step size for finite difference computations for L_BFGS_B. The default value 0.0 means that the relative step is given by the square root of machine epsilon.
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppDual_Annealing.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.GWO_DE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the Grey Wolf Optimizer with Differential Evolution (GWO-DE) algorithm.
This class inherits from MinimizerBase and implements the GWO-DE optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the Grey Wolf Optimizer with Differential Evolution (GWO-DE) algorithm.\n\n This class inherits from `MinimizerBase` and implements the GWO-DE optimization algorithm.\n ', '__init__': <function GWO_DE.__init__>, 'optimize': <function GWO_DE.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the Grey Wolf Optimizer with Differential Evolution (GWO-DE).
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for the algorithm. If None (default), the following settings are used:
options = { "population_size": 0, # Determines population size dynamically "mutation_rate": 0.5, # Probability of mutation "crossover_rate": 0.7, # Probability of crossover "elimination_prob": 0.1, # Probability of elimination "bound_strategy": "reflect-random" # Boundary handling strategy }
The available options are:
population_size (int): Initial population size. If set to 0, it will be automatically determined.
mutation_rate (float): Mutation rate variable (F).
crossover_rate (float): Crossover probability/rate (CR).
elimination_prob (float): Elimination probability.
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppGWO_DE.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the GWO-DE optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs Nelder-Mead optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.IMODE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the Improved Multi-Operator Differential Evolution (IMODE) algorithm.
Reference: Karam M. Sallam, Saber M. Elsayed, Ripon K. Chakrabortty, and Michael J. Ryan. 2020. Improved Multi-operator Differential Evolution Algorithm for Solving Unconstrained Problems. In 2020 IEEE Congress on Evolutionary Computation (CEC). IEEE Press, 1–8. https://doi.org/10.1109/CEC48606.2020.9185577.
IMODE combines multiple mutation operators, adaptive control parameters, and linear population size reduction. It is well suited for multimodal and high-dimensional benchmark problems where maintaining diversity is critical.
Options accepted via
options(defaults shown):{ "population_size" : 0, # auto -> max(18*D, 6*D^2) capped at 5000 "minimum_population_size" : 4, "memory_size" : 0, # auto -> 20*D "archive_size_ratio" : 2.6, "bound_strategy" : "none" }
Notes
Setting
population_sizeto0reproduces the MATLAB reference scaling rule.memory_sizeof0activates the heuristic20 * Dsuccess-history length.The default boundary handler is
"none"because IMODE uses its own hybrid repair.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the Improved Multi-Operator Differential Evolution (IMODE) algorithm.\n\n Reference: \n Karam M. Sallam, Saber M. Elsayed, Ripon K. Chakrabortty, and Michael J. Ryan. 2020. \n Improved Multi-operator Differential Evolution Algorithm for Solving Unconstrained Problems. In 2020 IEEE Congress on Evolutionary Computation (CEC). IEEE Press, 1–8. https://doi.org/10.1109/CEC48606.2020.9185577.\n\n IMODE combines multiple mutation operators, adaptive control parameters, and\n linear population size reduction. It is well suited for multimodal and\n high-dimensional benchmark problems where maintaining diversity is critical.\n\n Options accepted via ``options`` (defaults shown)::\n\n {\n "population_size" : 0, # auto -> max(18*D, 6*D^2) capped at 5000\n "minimum_population_size" : 4,\n "memory_size" : 0, # auto -> 20*D\n "archive_size_ratio" : 2.6,\n "bound_strategy" : "none"\n }\n\n Notes\n -----\n - Setting ``population_size`` to ``0`` reproduces the MATLAB reference scaling rule.\n - ``memory_size`` of ``0`` activates the heuristic ``20 * D`` success-history length.\n - The default boundary handler is ``"none"`` because IMODE uses its own hybrid repair.\n ', '__init__': <function IMODE.__init__>, 'optimize': <function IMODE.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]
Initialize the MinimizerBase class.
Parameters
- funccallable
Objective function to be minimized. Must accept list[list[float]]. If the function operates on a single sample, it should be vectorized.
- boundslist of tuple
List of (lower, upper) bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. Note that Minion assumes multiple initial guesses, thus, x0 is a list[list[float]] object. These guesses will be used for population initialization.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops when the relative improvement falls below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called at each iteration. It must accept the current optimization state as an argument.
- seedint, optional
Random seed for reproducibility. If None, a random seed is used.
- optionsdict, optional
Additional algorithm-specific parameters. If None, default settings are used.
Raises
- TypeError
If any of the input parameters are of an incorrect type.
- ValueError
If x0 has a different length than bounds, or if bounds are not properly formatted.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize() MinionResult[source]
- class minionpy.algorithms.JADE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the JADE algorithm.
Reference : J. Zhang and A. C. Sanderson, “JADE: Adaptive Differential Evolution With Optional External Archive,” in IEEE Transactions on Evolutionary Computation, vol. 13, no. 5, pp. 945-958, Oct. 2009, doi: 10.1109/TEVC.2009.2014613.
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the JADE algorithm.\n\n Reference : J. Zhang and A. C. Sanderson, "JADE: Adaptive Differential Evolution With Optional External Archive," in IEEE Transactions on Evolutionary Computation, vol. 13, no. 5, pp. 945-958, Oct. 2009, doi: 10.1109/TEVC.2009.2014613.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function JADE.__init__>, 'optimize': <function JADE.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "population_size" : 0, "c" : 0.1, "mutation_strategy" : "current_to_pbest_A_1bin", "archive_size_ratio" : 1.0, "minimum_population_size" : 4, "reduction_strategy" : "linear", "bound_strategy" : "reflect-random" }
The available options are:
population_size (int): Initial population size (N). If set to
0, it will be automatically determined as follows:If the dimensionality \(D\) of the problem is \(D < 10\), then \(N = 30\).
If \(10 \leq D \leq 30\), then \(N = 100\).
If \(30 < D \leq 50\), then \(N = 200\).
If \(50 < D \leq 70\), then \(N = 300\).
Else, \(N = 400\).
c (float) : The value of c variable. The value must be between 0 and 1.
- mutation_strategy (str): Mutation strategy used in the optimization process. Available strategies:
"best1bin","best1exp","rand1bin","rand1exp","current_to_pbest1bin","current_to_pbest1exp","current_to_pbest_A_1bin","current_to_pbest_A_1exp".
archive_size_ratio (float): Ratio of the archive size to the current population size.
minimum_population_size (int): Final population size after reduction.
- reduction_strategy (str): Strategy used to reduce the population size. Available strategies:
"linear","exponential","agsk".
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppJADE.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.LSHADE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the Linear Population Reduction - Success History Adaptive Differential Evolution (LSHADE) algorithm.
Reference : R. Tanabe and A. S. Fukunaga, “Improving the search performance of SHADE using linear population size reduction,” 2014 IEEE Congress on Evolutionary Computation (CEC), Beijing, China, 2014, pp. 1658-1665, doi: 10.1109/CEC.2014.6900380.
This class inherits from MinimizerBase.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the Linear Population Reduction - Success History Adaptive Differential Evolution (LSHADE) algorithm.\n\n Reference : R. Tanabe and A. S. Fukunaga, "Improving the search performance of SHADE using linear population size reduction," 2014 IEEE Congress on Evolutionary Computation (CEC), Beijing, China, 2014, pp. 1658-1665, doi: 10.1109/CEC.2014.6900380.\n\n This class inherits from `MinimizerBase`.\n ', '__init__': <function LSHADE.__init__>, 'optimize': <function LSHADE.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the LSHADE algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "population_size" : 0, "memory_size" : 6, "mutation_strategy" : "current_to_pbest_A_1bin", "archive_size_ratio" : 2.6, "minimum_population_size" : 4, "reduction_strategy" : "linear", "bound_strategy" : "reflect-random" }
The available options are:
- population_size (int): Initial population size (N). If set to 0, it will be automatically determined.
- \[N = 5 \cdot D\]
where D is the dimensionality of the problem.
memory_size (int): Number of entries in memory to store successful crossover (CR) and mutation (F) parameters.
- mutation_strategy (str): Mutation strategy used in the optimization process. Available strategies:
"best1bin","best1exp","rand1bin","rand1exp","current_to_pbest1bin","current_to_pbest1exp","current_to_pbest_A_1bin","current_to_pbest_A_1exp".
archive_size_ratio (float): Ratio of the archive size to the current population size.
minimum_population_size (int): Final population size after reduction.
- reduction_strategy (str): Strategy used to reduce the population size. Available strategies:
"linear","exponential","agsk".
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppLSHADE.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.LSHADE_cnEpSin(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseEnsemble sinusoidal LSHADE with covariance learning (cnEpSin variant).
Reference
N. H. Awad, M. Z. Ali and P. N. Suganthan, “Ensemble Sinusoidal Differential Covariance Matrix Adaptation with Euclidean Neighborhood for Solving CEC2017 Benchmark Problems,” IEEE CEC 2017.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Ensemble sinusoidal LSHADE with covariance learning (cnEpSin variant).\n\n Reference\n ---------\n N. H. Awad, M. Z. Ali and P. N. Suganthan, "Ensemble Sinusoidal Differential\n Covariance Matrix Adaptation with Euclidean Neighborhood for Solving CEC2017\n Benchmark Problems," IEEE CEC 2017.\n ', '__init__': <function LSHADE_cnEpSin.__init__>, 'optimize': <function LSHADE_cnEpSin.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]
Initialize the LSHADE-cnEpSin algorithm.
Parameters
- funccallable
Vectorised objective function returning a list of objective values.
- boundslist of tuple
Bounds for each decision variable.
- x0list[list[float]], optional
Optional initial population. When
Nonethe population is drawn uniformly within the supplied bounds.- relTol, maxevals, callback, seed :
Same semantics as
LSHADE.- optionsdict, optional
Additional configuration. If
Nonethe following defaults are applied:options = { "population_size" : 0, "memory_size" : 5, "archive_rate" : 1.4, "minimum_population_size": 4, "p_best_fraction" : 0.11, "rotation_probability" : 0.4, "neighborhood_fraction" : 0.5, "freq_init" : 0.5, "learning_period" : 20, "sin_freq_base" : 0.5, "epsilon" : 1e-8, "bound_strategy" : "reflect-random" }
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize() MinionResult[source]
Run LSHADE-cnEpSin and expose statistics captured by the C++ backend.
- class minionpy.algorithms.LSRTDE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the LSRTDE algorithm.
Reference : V. Stanovov and E. Semenkin, “Success Rate-based Adaptive Differential Evolution L-SRTDE for CEC 2024 Competition,” 2024 IEEE Congress on Evolutionary Computation (CEC), Yokohama, Japan, 2024, pp. 1-8, doi: 10.1109/CEC60901.2024.10611907.
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the LSRTDE algorithm.\n\n Reference : V. Stanovov and E. Semenkin, "Success Rate-based Adaptive Differential Evolution L-SRTDE for CEC 2024 Competition," 2024 IEEE Congress on Evolutionary Computation (CEC), Yokohama, Japan, 2024, pp. 1-8, doi: 10.1109/CEC60901.2024.10611907.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function LSRTDE.__init__>, 'optimize': <function LSRTDE.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "population_size" : 0, "memory_size" : 5, "success_rate" : 0.5 , "bound_strategy" :"reflect-random" }
The available options are:
population_size (int): Initial population size (N). If set to
0, it will be automatically determined as follows:\[N = 20 \cdot D\]where D is the dimensionality of the problem.
memory_size (float) : memory size for storing the values of
CRandFsuccess_rate (float) : The success rate value.
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppLSRTDE.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- class minionpy.algorithms.L_BFGS(func: Callable[[ndarray, object | None], float], x0: List[List[float]], relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of L_BFGS algorithm for unconstrained optimization problem.
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of L_BFGS algorithm for unconstrained optimization problem.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function L_BFGS.__init__>, 'optimize': <function L_BFGS.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], x0: List[List[float]], relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- x0list[list[float]]
Initial guesses for the solution. If more than one initial guesses are provided, the code will pick the best one as the true initial guess.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "max_iterations": 0, "m" : 15, "g_epsilon": 1e-8, "g_epsilon_rel": 0.0, "f_reltol": 1e-8, "max_linesearch": 20, "c_1": 1e-3, "c_2": 0.9, "func_noise_ratio": 1e-16, "N_points_derivative": 3 }
The available options are: - max_iterations (int): Maximum number of iterations. Default is 0 (no limit). - m (int): The number of corrections used in the limited memory matrix. Default is 15. - g_epsilon (double): Absolute gradient tolerance for stopping criteria. Default is 1e-8. - g_epsilon_rel (double): Relative gradient tolerance for stopping criteria. Default is 0.0. - f_reltol (double): Relative function tolerance for stopping criteria. Default is 1e-8. - max_linesearch (int): Maximum number of line search steps per iteration. Default is 20. - c_1 (double): Parameter for Armijo condition (sufficient decrease). Default is 1e-3. - c_2 (double): Parameter for Wolfe condition (curvature condition). Default is 0.9. - func_noise_ratio (double): noise level ratio, defined by the ratio of noise/f. For smooth function, set to 0.0. - N_points_derivative (int) : Number of points to calculate the numerical derivative. N=1 means forward difference, N>=2 use Lanczos noise-robust derivative. For smooth function, N=1 works well and use less function calls.
Notes
The optimizer is implemented in C++ and accessed via cppL_BFGS_B.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.L_BFGS_B(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of L_BFGS_B algorithm.
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of L_BFGS_B algorithm.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function L_BFGS_B.__init__>, 'optimize': <function L_BFGS_B.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]]
Initial guesses for the solution. If more than one initial guesses are provided, the code will pick the best one as the true initial guess.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "max_iterations": 0, "m" : 15, "g_epsilon": 1e-8, "g_epsilon_rel": 0.0, "f_reltol": 1e-8, "max_linesearch": 20, "c_1": 1e-3, "c_2": 0.9, "func_noise_ratio": 1e-16, "N_points_derivative": 3 }
The available options are: - max_iterations (int): Maximum number of iterations. Default is 0 (no limit). - m (int): The number of corrections used in the limited memory matrix. Default is 15. - g_epsilon (double): Absolute gradient tolerance for stopping criteria. Default is 1e-8. - g_epsilon_rel (double): Relative gradient tolerance for stopping criteria. Default is 0.0. - f_reltol (double): Relative function tolerance for stopping criteria. Default is 1e-8. - max_linesearch (int): Maximum number of line search steps per iteration. Default is 20. - c_1 (double): Parameter for Armijo condition (sufficient decrease). Default is 1e-3. - c_2 (double): Parameter for Wolfe condition (curvature condition). Default is 0.9. - func_noise_ratio (double): noise level ratio, defined by the ratio of noise/f. For smooth function, set to 0.0. - N_points_derivative (int) : Number of points to calculate the numerical derivative. N=1 means forward difference, N>=2 use Lanczos noise-robust derivative. For smooth function, N=1 works well and use less function calls.
Notes
The optimizer is implemented in C++ and accessed via cppL_BFGS_B.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.Minimizer(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, algo: str = 'ARRDE', relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseA general-purpose optimization class that encapsulates all optimization algorithms implemented in Minion/py.
This class provides an interface for various optimization algorithms, inheriting from MinimizerBase. It allows users to minimize a given objective function using different evolutionary and classical optimization techniques.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n A general-purpose optimization class that encapsulates all optimization algorithms \n implemented in Minion/py.\n\n This class provides an interface for various optimization algorithms, inheriting \n from `MinimizerBase`. It allows users to minimize a given objective function using \n different evolutionary and classical optimization techniques.\n ', '__init__': <function Minimizer.__init__>, 'optimize': <function Minimizer.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, algo: str = 'ARRDE', relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is either:
A list of lists of floats (
list[list[float]])
The function func is assumed to be vectorized. If it only supports a single input (list[float] or 1D np.ndarray), it can be vectorized as follows:
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution.
- algostr, optional
The optimization algorithm to use. Default is “ARRDE”. Available algorithms include:
“LSHADE”
“AGSK”
“DE”
“JADE”
“jSO”
“NelderMead”
“LSRTDE”
“NLSHADE_RSP”
“j2020”
“GWO_DE”
“ARRDE”
“ABC” (artificial bee colony)
“DA” (dual annealing)
“L_BFGS_B”
“L_BFGS”
“CMAES”
“RCMAES”
“BIPOP_aCMAES”
“PSO”
“SPSO2011”
“DMSPSO”
“LSHADE_cnEpSin”
- relTolfloat, optional
Relative tolerance for convergence. The optimization stops if the relative improvement in the objective function is below this threshold. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the settings are taken from the default configuration of the chosen algorithm.
Notes
The optimizer is implemented in C++ and accessed via cppMinimizer.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.MinimizerBase(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
objectBase class for minimization algorithms.
This class performs initial validation and preprocessing of input parameters before passing them to the chosen optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Base class for minimization algorithms.\n\n This class performs initial validation and preprocessing of input parameters\n before passing them to the chosen optimization algorithm.\n ', '__init__': <function MinimizerBase.__init__>, 'func': <function MinimizerBase.func>, '_validate_bounds': <function MinimizerBase._validate_bounds>, '__dict__': <attribute '__dict__' of 'MinimizerBase' objects>, '__weakref__': <attribute '__weakref__' of 'MinimizerBase' objects>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the MinimizerBase class.
Parameters
- funccallable
Objective function to be minimized. Must accept list[list[float]]. If the function operates on a single sample, it should be vectorized.
- boundslist of tuple
List of (lower, upper) bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. Note that Minion assumes multiple initial guesses, thus, x0 is a list[list[float]] object. These guesses will be used for population initialization.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops when the relative improvement falls below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called at each iteration. It must accept the current optimization state as an argument.
- seedint, optional
Random seed for reproducibility. If None, a random seed is used.
- optionsdict, optional
Additional algorithm-specific parameters. If None, default settings are used.
Raises
- TypeError
If any of the input parameters are of an incorrect type.
- ValueError
If x0 has a different length than bounds, or if bounds are not properly formatted.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)[source]
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- class minionpy.algorithms.MinionResult(minRes)[source]
Bases:
objectStores the results of an optimization process.
This class encapsulates key optimization metrics, including:
x (list): Best solution found.
fun (float): Objective function value at x.
nit (int): Number of iterations performed.
nfev (int): Number of function evaluations.
success (bool): Whether the optimization was successful.
message (str): Descriptive message about the optimization outcome.
Notes
The structure of MinionResult closely resembles scipy.optimize.OptimizeResult, making it easy to use in similar contexts.
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Stores the results of an optimization process.\n\n This class encapsulates key optimization metrics, including:\n\n - **x** (*list*): Best solution found.\n - **fun** (*float*): Objective function value at `x`.\n - **nit** (*int*): Number of iterations performed.\n - **nfev** (*int*): Number of function evaluations.\n - **success** (*bool*): Whether the optimization was successful.\n - **message** (*str*): Descriptive message about the optimization outcome.\n\n Notes\n -----\n The structure of `MinionResult` closely resembles `scipy.optimize.OptimizeResult`,\n making it easy to use in similar contexts.\n ', '__init__': <function MinionResult.__init__>, '__repr__': <function MinionResult.__repr__>, '__dict__': <attribute '__dict__' of 'MinionResult' objects>, '__weakref__': <attribute '__weakref__' of 'MinionResult' objects>, '__annotations__': {}})
- __init__(minRes)[source]
Initialize a MinionResult instance from a C++ optimization result.
Parameters
- minResC++ MinionResult object
The optimization result returned by the C++ optimization engine.
- __module__ = 'minionpy.algorithms'
- __repr__()[source]
Return a string representation of the MinionResult object.
Returns
- str
A formatted string displaying key optimization results.
- __weakref__
list of weak references to the object
- class minionpy.algorithms.NLSHADE_RSP(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the LSHADE_RSP algorithm.
Reference : V. Stanovov, S. Akhmedova and E. Semenkin, “NL-SHADE-RSP Algorithm with Adaptive Archive and Selective Pressure for CEC 2021 Numerical Optimization,” 2021 IEEE Congress on Evolutionary Computation (CEC), Kraków, Poland, 2021, pp. 809-816, doi: 10.1109/CEC45853.2021.9504959.
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the LSHADE_RSP algorithm.\n\n Reference : V. Stanovov, S. Akhmedova and E. Semenkin, "NL-SHADE-RSP Algorithm with Adaptive Archive and Selective Pressure for CEC 2021 Numerical Optimization," 2021 IEEE Congress on Evolutionary Computation (CEC), Kraków, Poland, 2021, pp. 809-816, doi: 10.1109/CEC45853.2021.9504959.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function NLSHADE_RSP.__init__>, 'optimize': <function NLSHADE_RSP.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "population_size" : 0, "memory_size" : 100, "archive_size_ratio" : 2.6 , "bound_strategy" : "reflect-random" }
The available options are:
- population_size (int): Initial population size (N). If set to 0, it will be automatically determined.
- \[N = 30 \cdot D\]
where D is the dimensionality of the problem.
memory_size (int): Number of entries in memory to store successful crossover (CR) and mutation (F) parameters.
archive_size_ratio (float): Ratio of the archive size to the current population size.
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppNLSHADE_RSP.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.NelderMead(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the Nelder-Mead algorithm.
This class inherits from MinimizerBase.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the Nelder-Mead algorithm.\n\n This class inherits from `MinimizerBase`.\n ', '__init__': <function NelderMead.__init__>, 'optimize': <function NelderMead.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the Nelder-Mead algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "bound_strategy" : "reflect-random" }
The available options are:
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppNelderMead.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the Nelder-Mead optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs Nelder-Mead optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.algorithms.PSO(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseCanonical particle swarm optimization (global-best topology).
Options
The options dictionary accepts:
population_size(int): swarm size (defaults to5 * Dwhen 0).inertia_weight(float): inertia term \(\omega\) (default0.7).cognitive_coefficient(float): self-attraction coefficient \(c_1\).social_coefficient(float): global-attraction coefficient \(c_2\).velocity_clamp(float): fraction of the search range used as velocity limit.use_latin(bool): initialize swarm with Latin hypercube sampling ifTrue.support_tolerance(bool): enable the diversity based stop criterion.bound_strategy(str): boundary handling policy ("reflect-random"by default).
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Canonical particle swarm optimization (global-best topology).\n\n Options\n -------\n The `options` dictionary accepts:\n\n - ``population_size`` (*int*): swarm size (defaults to ``5 * D`` when 0).\n - ``inertia_weight`` (*float*): inertia term :math:`\\omega` (default ``0.7``).\n - ``cognitive_coefficient`` (*float*): self-attraction coefficient :math:`c_1`.\n - ``social_coefficient`` (*float*): global-attraction coefficient :math:`c_2`.\n - ``velocity_clamp`` (*float*): fraction of the search range used as velocity limit.\n - ``use_latin`` (*bool*): initialize swarm with Latin hypercube sampling if ``True``.\n - ``support_tolerance`` (*bool*): enable the diversity based stop criterion.\n - ``bound_strategy`` (*str*): boundary handling policy (``"reflect-random"`` by default).\n ', '__init__': <function PSO.__init__>, 'optimize': <function PSO.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]
Initialize the PSO algorithm.
Parameters
- funccallable
Objective function to minimise. The function must accept a list of candidate solutions and return a list of objective values.
- boundslist of tuple
Search-space bounds expressed as
(lower, upper)pairs.- x0list[list[float]], optional
Optional particle positions used to seed the swarm. When
None(default) the swarm is initialised within the supplied bounds.- relTolfloat, optional
Relative tolerance used by the diversity-based stopping criterion. Default is
1e-4.- maxevalsint, optional
Maximum number of objective evaluations allowed. Default
100000.- callbackcallable, optional
Callable invoked after each iteration with the current
MinionResult. DefaultNone.- seedint, optional
Random seed for reproducibility. If
None(default) a random seed is chosen.- optionsdict, optional
Configuration dictionary. If
Nonethe following defaults are used:{ "population_size" : 0, "inertia_weight" : 0.7, "cognitive_coefficient" : 1.5, "social_coefficient" : 1.5, "velocity_clamp" : 0.2, "bound_strategy" : "reflect-random" }
The available options are:
population_size (int): Swarm size (
0→5 * D).inertia_weight (float): Inertia weight \(\omega\).
cognitive_coefficient, social_coefficient (float): Accelerations \(c_1\), \(c_2\).
velocity_clamp (float): Fraction of the search range used as the velocity limit (
0disables).bound_strategy (str): Boundary handling policy.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize() MinionResult[source]
- class minionpy.algorithms.RCMAES(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the Restarting CMA-ES variant (RCMAES).
This class inherits from MinimizerBase.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the Restarting CMA-ES variant (RCMAES).\n\n This class inherits from `MinimizerBase`.\n ', '__init__': <function RCMAES.__init__>, 'optimize': <function RCMAES.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]
Initialize the RCMAES algorithm.
Parameters
- funccallable
Vectorised objective function returning a list of objective values.
- boundslist of tuple
Bounds for each decision variable.
- x0list[list[float]], optional
Optional collection of initial guesses. When multiple candidates are supplied, the best according to
funcseeds the initial mean.- relTolfloat, optional
Relative tolerance used by the stopping criterion. Default
1e-4.- maxevalsint, optional
Maximum number of function evaluations. Default
100000.- callbackcallable, optional
User callback receiving intermediate
MinionResultobjects.- seedint, optional
Seed for the pseudo-random number generator.
Nonekeeps the global RNG state.- optionsdict, optional
Additional RCMAES configuration. If
Nonethe following defaults are applied:options = { "population_size" : 0, "initial_step" : 0.2, "bound_strategy" : "reflect-random" }
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize() MinionResult[source]
- class minionpy.algorithms.SPSO2011(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseStochastic PSO 2011 (Clerc/Bratton) with constriction and adaptive neighbourhoods.
Options
Default options used when
optionsisNone:{ "population_size" : 0, "inertia_weight" : 0.729844, "cognitive_coefficient" : 1.49618, "social_coefficient" : 1.49618, "phi_personal" : 1.49618, "phi_social" : 1.49618, "neighborhood_size" : 3, "informant_degree" : 3, "velocity_clamp" : 0.0, "normalize" : False, "bound_strategy" : "reflect-random" }
population_size(int): swarm size (0→5 * D).inertia_weight(float),cognitive_coefficient(float),social_coefficient(float): PSO constants.informant_degree/neighborhood_size(int): number of informants per particle.velocity_clamp(float): optional velocity clamp fraction.normalize(bool): operate in normalised coordinates before mapping back to the original bounds.bound_strategy(str): boundary handling policy.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Stochastic PSO 2011 (Clerc/Bratton) with constriction and adaptive neighbourhoods.\n\n Options\n -------\n Default options used when ``options`` is ``None``::\n\n {\n "population_size" : 0,\n "inertia_weight" : 0.729844,\n "cognitive_coefficient" : 1.49618,\n "social_coefficient" : 1.49618,\n "phi_personal" : 1.49618,\n "phi_social" : 1.49618,\n "neighborhood_size" : 3,\n "informant_degree" : 3,\n "velocity_clamp" : 0.0,\n "normalize" : False,\n "bound_strategy" : "reflect-random"\n }\n\n - ``population_size`` (*int*): swarm size (``0`` → ``5 * D``).\n - ``inertia_weight`` (*float*), ``cognitive_coefficient`` (*float*), ``social_coefficient`` (*float*): PSO constants.\n - ``informant_degree`` / ``neighborhood_size`` (*int*): number of informants per particle.\n - ``velocity_clamp`` (*float*): optional velocity clamp fraction.\n - ``normalize`` (*bool*): operate in normalised coordinates before mapping back to the original bounds.\n - ``bound_strategy`` (*str*): boundary handling policy.\n ', '__init__': <function SPSO2011.__init__>, 'optimize': <function SPSO2011.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]
Initialize the SPSO2011 algorithm.
Parameters
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize() MinionResult[source]
- class minionpy.algorithms.j2020(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the j2020 algorithm.
Reference : J. Brest, M. S. Maučec and B. Bošković, “Differential Evolution Algorithm for Single Objective Bound-Constrained Optimization: Algorithm j2020,” 2020 IEEE Congress on Evolutionary Computation (CEC), Glasgow, UK, 2020, pp. 1-8, doi: 10.1109/CEC48606.2020.9185551.
Inherits from MinimizerBase and implements the optimization algorithm.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the j2020 algorithm.\n\n Reference : J. Brest, M. S. Maučec and B. Bošković, "Differential Evolution Algorithm for Single Objective Bound-Constrained Optimization: Algorithm j2020," 2020 IEEE Congress on Evolutionary Computation (CEC), Glasgow, UK, 2020, pp. 1-8, doi: 10.1109/CEC48606.2020.9185551.\n\n Inherits from MinimizerBase and implements the optimization algorithm.\n ', '__init__': <function j2020.__init__>, 'optimize': <function j2020.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "population_size" : 0, "tau1" : 0.1, "tau2" : 0.1 , "myEqs" : 0.25, "bound_strategy" : "reflect-random" }
The available options are:
population_size (int): Initial population size (N). If set to
0, it will be automatically determined as follows:\[N = 8 \cdot D\]where D is the dimensionality of the problem.
tau1 (float) : The value of tau1 variable. The value must be between 0 and 1.
tau2 (float) : The value of tau1 variable. The value must be between 0 and 1.
myEqs (float) : The value of myEqs variable. The value must be between 0 and 1.
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppj2020.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- class minionpy.algorithms.jSO(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Bases:
MinimizerBaseImplementation of the jSO algorithm.
Reference : J. Brest, M. S. Maučec and B. Bošković, “Single objective real-parameter optimization: Algorithm jSO,” 2017 IEEE Congress on Evolutionary Computation (CEC), Donostia, Spain, 2017, pp. 1311-1318, doi: 10.1109/CEC.2017.7969456.
Inherits from MinimizerBase.
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n Implementation of the jSO algorithm.\n\n Reference : J. Brest, M. S. Maučec and B. Bošković, "Single objective real-parameter optimization: Algorithm jSO," 2017 IEEE Congress on Evolutionary Computation (CEC), Donostia, Spain, 2017, pp. 1311-1318, doi: 10.1109/CEC.2017.7969456.\n\n Inherits from MinimizerBase.\n ', '__init__': <function jSO.__init__>, 'optimize': <function jSO.optimize>, '__annotations__': {}})
- __init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, relTol: float = 0.0001, maxevals: int = 100000, callback: Callable[[Any], None] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]
Initialize the algorithm.
Parameters
- funccallable
The objective function to be minimized.
func(X) -> list[float]
where X is a list of lists of floats. Note that func is assumed to be vectorized. If the function instead takes a single list of floats and returns a float, it can be vectorized as follows (see examples in the documentation):
def func(X): return [fun(x) for x in X]
- boundslist of tuple
List of (min, max) pairs defining the bounds for each decision variable.
- x0list[list[float]], optional
Initial guesses for the solution. These guesses will be used to initialize the population. If None (default), a random initialization within the given bounds is used.
- relTolfloat, optional
Relative tolerance for convergence. The algorithm stops if the relative improvement in the objective function is below this value. Default is 1e-4.
- maxevalsint, optional
Maximum number of function evaluations allowed. Default is 100000.
- callbackcallable, optional
A function that is called after each iteration. It must accept a single argument containing the current optimization state. Default is None.
- seedint, optional
Random seed for reproducibility. If None (default), the seed is not set.
- optionsdict, optional
Additional options for configuring the algorithm. If None (default), the following settings are used:
options = { "population_size" : 0, "memory_size" : 5, "archive_size_ratio" : 1.0, "minimum_population_size" : 4, "reduction_strategy" : "linear", "bound_strategy" : "reflect-random" }
The available options are:
population_size (int): Initial population size (N). If set to 0, it will be automatically determined as:
\[N = 25 \cdot \log(D) \cdot \sqrt{D}\]where D is the dimensionality of the problem.
memory_size (int): Number of entries in memory to store successful crossover (CR) and mutation (F) parameters.
archive_size_ratio (float): Ratio of the archive size to the current population size.
minimum_population_size (int): Final population size after reduction.
- reduction_strategy (str): Strategy used to reduce the population size. Available strategies:
"linear","exponential","agsk".
- bound_strategy (str): Method for handling boundary violations. Available strategies:
"random","reflect-random","clip".
Notes
The optimizer is implemented in C++ and accessed via cppjSO.
The callback function can be used for logging or monitoring progress.
The options dictionary allows fine-tuning of the optimization process.
- __module__ = 'minionpy.algorithms'
- __weakref__
list of weak references to the object
- func(xmat, data)
Transform the user-defined objective function into a compatible form for Minion.
Parameters
- xmatlist[list[float]]
Input matrix where each row is a decision variable vector.
- dataobject
Additional data (unused in this implementation).
Returns
- list
Function evaluation results for each row in xmat.
- optimize()[source]
Run the optimization algorithm.
Returns
- MinionResult
The optimization result containing the best solution found.
Notes
This method runs the optimization algorithm and stores the result in self.minionResult. The optimization history is also stored in self.history, containing intermediate results at each iteration.
- class minionpy.cec.CEC2011Functions(function_number, dimension=None)[source]
Bases:
objectProvides access to the 22 real-world benchmark problems from CEC2011. Each problem has a fixed dimension and bound box defined by the original suite.
- __dict__ = mappingproxy({'__module__': 'minionpy.cec', '__doc__': '\n Provides access to the 22 real-world benchmark problems from CEC2011.\n Each problem has a fixed dimension and bound box defined by the original suite.\n ', '__init__': <function CEC2011Functions.__init__>, '__call__': <function CEC2011Functions.__call__>, 'evaluate': <function CEC2011Functions.evaluate>, 'get_bounds': <function CEC2011Functions.get_bounds>, '__dict__': <attribute '__dict__' of 'CEC2011Functions' objects>, '__weakref__': <attribute '__weakref__' of 'CEC2011Functions' objects>, '__annotations__': {}})
- __module__ = 'minionpy.cec'
- __weakref__
list of weak references to the object
- class minionpy.cec.CEC2014Functions(function_number, dimension)[source]
Bases:
objectProvides access to the CEC2014 benchmark test functions.
This class implements 30 benchmark optimization problems from CEC 2014 at various dimensions.
Available dimensions: 2, 10, 20, 30, 50, 100 Available functions: 1–30
- __call__(X)[source]
Evaluate the selected CEC2014 test function.
Parameters
- Xlist[list[float]]
Input vectors to evaluate.
Returns
- list
A vector of function values corresponding to each input vector.
- __dict__ = mappingproxy({'__module__': 'minionpy.cec', '__doc__': '\n Provides access to the CEC2014 benchmark test functions.\n\n This class implements 30 benchmark optimization problems from CEC 2014\n at various dimensions.\n\n Available dimensions: **2, 10, 20, 30, 50, 100** \n Available functions: **1–30**\n ', '__init__': <function CEC2014Functions.__init__>, '__call__': <function CEC2014Functions.__call__>, '__dict__': <attribute '__dict__' of 'CEC2014Functions' objects>, '__weakref__': <attribute '__weakref__' of 'CEC2014Functions' objects>, '__annotations__': {}})
- __init__(function_number, dimension)[source]
Initialize a CEC2014Functions instance.
Parameters
- function_numberint
The function index (must be in the range 1–30).
- dimensionint
The problem dimensionality (must be one of {2, 10, 20, 30, 50, 100}).
- __module__ = 'minionpy.cec'
- __weakref__
list of weak references to the object
- class minionpy.cec.CEC2017Functions(function_number, dimension)[source]
Bases:
objectProvides access to the CEC2014 benchmark test functions.
This class implements 30 benchmark optimization problems from CEC 2017 at various dimensions.
Available dimensions: 2, 10, 20, 30, 50, 100 Available functions: 1–30
- __call__(X)[source]
Evaluate the selected CEC2014 test function.
Parameters
- Xlist[list[float]]
Input vectors to evaluate.
Returns
- list
A vector of function values corresponding to each input vector.
- __dict__ = mappingproxy({'__module__': 'minionpy.cec', '__doc__': '\n Provides access to the CEC2014 benchmark test functions.\n\n This class implements 30 benchmark optimization problems from CEC 2017\n at various dimensions.\n\n Available dimensions: **2, 10, 20, 30, 50, 100** \n Available functions: **1–30**\n ', '__init__': <function CEC2017Functions.__init__>, '__call__': <function CEC2017Functions.__call__>, '__dict__': <attribute '__dict__' of 'CEC2017Functions' objects>, '__weakref__': <attribute '__weakref__' of 'CEC2017Functions' objects>, '__annotations__': {}})
- __init__(function_number, dimension)[source]
Initialize a CEC2017Functions instance.
Parameters
- function_numberint
The function index (must be in the range 1–30). Note: Functions 11–19 are not available for dimensions 2 and 20.
- dimensionint
The problem dimensionality (must be one of {2, 10, 20, 30, 50, 100}).
- __module__ = 'minionpy.cec'
- __weakref__
list of weak references to the object
- class minionpy.cec.CEC2019Functions(function_number)[source]
Bases:
objectProvides access to the CEC2019 benchmark test functions.
This class implements 10 benchmark optimization problems from CEC 2019 at various dimensions.
Available functions: 1–10
- __call__(X)[source]
Evaluate the selected CEC2014 test function.
Parameters
- Xlist[list[float]]
Input vectors to evaluate.
Returns
- list
A vector of function values corresponding to each input vector.
- __dict__ = mappingproxy({'__module__': 'minionpy.cec', '__doc__': '\n Provides access to the CEC2019 benchmark test functions.\n\n This class implements 10 benchmark optimization problems from CEC 2019\n at various dimensions.\n\n Available functions: **1–10**\n ', '__init__': <function CEC2019Functions.__init__>, '__call__': <function CEC2019Functions.__call__>, '__dict__': <attribute '__dict__' of 'CEC2019Functions' objects>, '__weakref__': <attribute '__weakref__' of 'CEC2019Functions' objects>, '__annotations__': {}})
- __init__(function_number)[source]
Initialize a CEC2019Functions instance.
Parameters
- function_numberint
The function index (must be in the range 1–10).
- __module__ = 'minionpy.cec'
- __weakref__
list of weak references to the object
- class minionpy.cec.CEC2020Functions(function_number, dimension)[source]
Bases:
objectProvides access to the CEC2020 benchmark test functions.
This class implements 30 benchmark optimization problems from CEC 2020 at various dimensions.
Available dimensions: 5, 10, 15, 20 Available functions: 1–10
- __call__(X)[source]
Evaluate the selected CEC2014 test function.
Parameters
- Xlist[list[float]]
Input vectors to evaluate.
Returns
- list
A vector of function values corresponding to each input vector.
- __dict__ = mappingproxy({'__module__': 'minionpy.cec', '__doc__': '\n Provides access to the CEC2020 benchmark test functions.\n\n This class implements 30 benchmark optimization problems from CEC 2020\n at various dimensions.\n\n Available dimensions: **5, 10, 15, 20** \n Available functions: **1–10**\n ', '__init__': <function CEC2020Functions.__init__>, '__call__': <function CEC2020Functions.__call__>, '__dict__': <attribute '__dict__' of 'CEC2020Functions' objects>, '__weakref__': <attribute '__weakref__' of 'CEC2020Functions' objects>, '__annotations__': {}})
- __init__(function_number, dimension)[source]
Initialize a CEC2020Functions instance.
Parameters
- function_numberint
The function index (must be in the range 1–10).
- dimensionint
The problem dimensionality (must be one of {5, 10, 15, 20}).
- __module__ = 'minionpy.cec'
- __weakref__
list of weak references to the object
- class minionpy.cec.CEC2022Functions(function_number, dimension)[source]
Bases:
objectProvides access to the CEC2022 benchmark test functions.
This class implements 12 benchmark optimization problems from CEC 2022 at various dimensions.
Available dimensions: 10, 20 Available functions: 1–12
- __call__(X)[source]
Evaluate the selected CEC2014 test function.
Parameters
- Xlist[list[float]]
Input vectors to evaluate.
Returns
- list
A vector of function values corresponding to each input vector.
- __dict__ = mappingproxy({'__module__': 'minionpy.cec', '__doc__': '\n Provides access to the CEC2022 benchmark test functions.\n\n This class implements 12 benchmark optimization problems from CEC 2022\n at various dimensions.\n\n Available dimensions: **10, 20** \n Available functions: **1–12**\n ', '__init__': <function CEC2022Functions.__init__>, '__call__': <function CEC2022Functions.__call__>, '__dict__': <attribute '__dict__' of 'CEC2022Functions' objects>, '__weakref__': <attribute '__weakref__' of 'CEC2022Functions' objects>, '__annotations__': {}})
- __init__(function_number, dimension)[source]
Initialize a CEC2022Functions instance.
Parameters
- function_numberint
The function index (must be in the range 1–12).
- dimensionint
The problem dimensionality (must be one of {10, 20).
- __module__ = 'minionpy.cec'
- __weakref__
list of weak references to the object