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: object

Parallelizes 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.

__del__()[source]

Shuts down the executor and cleans up resources.

__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

cleanUp()[source]

Shuts down the executor and waits for all processes to finish.

objective(X)[source]

Evaluates the objective function in parallel using multiple processes.

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.

class minionpy.parallel.Thread_Parallel(Nthreads, class_name, *args, **kwargs)[source]

Bases: object

Parallelizes 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.

__del__()[source]

Shuts down the executor and cleans up resources.

__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

cleanUp()[source]

Shuts down the executor and waits for all threads to finish.

objective(X)[source]

Evaluates the objective function in parallel for multiple inputs.

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.

class minionpy.algorithms.ABC(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "population_size"       :  0,  
    "limit"                 : 100,
    "bound_strategy"        : "reflect-random"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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.

  • limit (int): Scout trigger threshold for abandoned food sources.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.ACMAES(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation of the active Covariance Matrix Adaptation Evolution Strategy (ACMAES).

This class inherits from MinimizerBase.

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n    Implementation of the active Covariance Matrix Adaptation Evolution Strategy (ACMAES).\n\n    This class inherits from `MinimizerBase`.\n    ', '__init__': <function ACMAES.__init__>, 'optimize': <function ACMAES.optimize>, '__annotations__': {}})
__init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]

Initialize the ACMAES algorithm.

Default options are:

{
"maxiters"                 : -1,
"population_size"  : 0,
    "rel_initial_step" : 0.3,
    "x_tol"            : 1e-8,
    "f_tol": -1.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.AGSK(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation of the Adaptive Gaining-Sharing Knowledge-based (AGSK) algorithm.

Reference:
    1. 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)

{
    "maxiters"                 : -1,
    "population_size"         : 0,      # auto -> 40*D if D>5 else 100
    "minimum_population_size" : 12,
    "x_tol"                   : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"          : "reflect-random"
}

Notes

  • Setting population_size to 0 reproduces the reference scaling rule.

  • minimum_population_size enforces 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            "maxiters"                 : -1,\n            "population_size"         : 0,      # auto -> 40*D if D>5 else 100\n            "minimum_population_size" : 12,\n            "x_tol"                   : 1e-8,\n            "f_tol": -1.0,\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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called at each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue.

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. Algorithms without built-in restart strategies accept maxiters; the default -1 disables the iteration cap. Algorithms with tolerance-based stopping use x_tol for coordinate spread and f_tol for relative objective-value spread. The default values are x_tol=1e-8 and f_tol=-1.0 where supported. Set either tolerance to a negative value to disable that specific convergence check.

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()[source]

Run the AGSK optimizer and capture history/statistics.

class minionpy.algorithms.ARRDE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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], where X is 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]]. :param maxevals: Maximum number of objective evaluations. Default is 100000.

  • callback – Optional callback invoked after each iteration. Return True to stop optimization early; return False or None to continue.

  • 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 only.

class minionpy.algorithms.BIPOP_aCMAES(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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 func seeds the initial mean.

maxevalsint, optional

Maximum number of function evaluations. Default 100000.

callbackcallable, optional

User callback receiving intermediate MinionResult objects. Return True to stop optimization early; return False or None to continue.

seedint, optional

Seed for the pseudo-random number generator. None keeps the global RNG state.

optionsdict, optional

Additional CMA-ES configuration. If None the following defaults are applied:

options = {
    "population_size"  : 0,    # If 0, determined automatically
    "rel_initial_step" : 0.3,  # Initial CMA-ES step size
    "x_tol"            : 1e-8,
    "f_tol": -1.0,
    "max_restarts"     : -1,   # -1 means unlimited restarts
    "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.CMAES(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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 func seeds the initial mean.

maxevalsint, optional

Maximum number of function evaluations. Default 100000.

callbackcallable, optional

User callback receiving intermediate MinionResult objects. Return True to stop optimization early; return False or None to continue.

seedint, optional

Seed for the pseudo-random number generator. None keeps the global RNG state.

optionsdict, optional

Additional CMA-ES configuration. If None the following defaults are applied:

options = {
    "population_size"  : 0,
    "rel_initial_step" : 0.3,
    "x_tol"            : 1e-8,
    "f_tol": -1.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: object

Wraps a Python callback that takes a MinionResult.

The callback return value controls early stopping: True stops optimization, while False or None continues.

__call__(minRes)[source]

Invoke the callback function with a MinionResult object.

Parameters: - minRes: MinionResult object to pass to the callback function.

Returns: - True to stop optimization, False or None to continue.

__dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n    Wraps a Python callback that takes a MinionResult.\n    \n    The callback return value controls early stopping: True stops optimization,\n    while False or None continues.\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 MinionResult and optionally returns bool.

__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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Dynamic multi-swarm PSO with periodic regrouping and co-operative subswarms.

Options

  • population_size (int): swarm size (defaults to 5 * D when 0).

  • inertia_weight (float), cognitive_coefficient (float), social_coefficient (float): base PSO coefficients.

  • local_coefficient (float): influence of the subswarm best (default 1.4).

  • global_coefficient (float): influence of the global best (default 0.8).

  • subswarm_count (int): number of dynamic subswarms (default 4).

  • regroup_period (int): iterations between subswarm reshuffles (default 5).

  • velocity_clamp (float): fraction of the search range used as the velocity limit (default 0.2).

  • x_tol (float): coordinate-spread convergence tolerance.

  • f_tol (float): relative objective-value spread convergence tolerance.

  • 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    - ``x_tol`` (*float*): coordinate-spread convergence tolerance.\n    - ``f_tol`` (*float*): relative objective-value spread convergence tolerance.\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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]

Initialize the DMS-PSO algorithm.

Parameters

func, bounds, x0, maxevals, callback, seed, options :

See PSO for the base semantics. The callback may return True to stop optimization early; False or None continues.

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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "population_size"         :  0,  
    "mutation_strategy"       : "best1bin",
    "mutation_rate"           : 0.5, 
    "crossover_rate"          : 0.8,
    "x_tol"                   : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"          : "reflect-random"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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 (CR).

  • x_tol (float): Coordinate-spread convergence tolerance.

  • f_tol (float): Relative objective-value spread convergence tolerance.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.Dual_Annealing(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "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",
    "func_noise_ratio": 1e-16,
    "N_points_derivative": 3,
    "x_tol": 1e-8,
    "f_tol": -1.0,
    "bound_strategy"        : "periodic"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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”.

  • func_noise_ratio (double): Relative objective noise level used by local-search finite differences.

  • N_points_derivative (int): Number of points used by the derivative approximation.

  • x_tol (float): Coordinate-spread convergence tolerance.

  • f_tol (float): Relative objective-value spread tolerance.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.GradientDescent(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Zeroth-order gradient descent with configurable black-box gradient estimation.

The optimizer supports three update rules through options["update_rule"]: "gd", "sgd", and "adam". Gradient estimates come from either coordinate finite differences or random directional finite differences. The main step-size option is base_learning_rate. The legacy key learning_rate is still accepted for backward compatibility.

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n    Zeroth-order gradient descent with configurable black-box gradient estimation.\n\n    The optimizer supports three update rules through ``options["update_rule"]``:\n    ``"gd"``, ``"sgd"``, and ``"adam"``. Gradient estimates come from either\n    coordinate finite differences or random directional finite differences.\n    The main step-size option is ``base_learning_rate``. The legacy key\n    ``learning_rate`` is still accepted for backward compatibility.\n    ', '__init__': <function GradientDescent.__init__>, 'optimize': <function GradientDescent.optimize>, '__annotations__': {}})
__init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]

Initialize black-box gradient descent.

Parameters

funccallable

Vectorized objective function func(X) -> list[float].

boundslist of tuple

Box constraints for each decision variable.

x0list[list[float]], optional

Optional starting points. If multiple guesses are supplied, the best one is selected before the first update.

maxevalsint, optional

Maximum number of function evaluations.

callbackcallable, optional

Callback invoked with MinionResult. Return True to stop.

seedint, optional

Random seed for reproducibility.

optionsdict, optional

Configuration dictionary. Defaults are:

  {
      "maxiters": -1,
      "base_learning_rate": 1e-2,
      "update_rule": "adam",
      "gradient_estimator": "coordinate_fd",
      "use_line_search": False,
      "max_linesearch": 8,
      "line_search_c1": 1e-4,
      "line_search_rho": 0.5,
      "N_points_derivative": 2,
      "fd_epsilon": 0.0,
      "func_noise_ratio": 1e-10,
      "gradient_samples": 16,
      "coordinate_batch_size": 0,
      "beta1": 0.9,
      "beta2": 0.999,
      "epsilon": 1e-8,
      "momentum": 0.0,
      "lr_decay": 1.0,
      "g_tol": 1e-6,
      "x_tol": 1e-8,
      "f_tol": -1.0,
      "bound_strategy": "clip",
  }

``base_learning_rate`` is the constant step size for ``"gd"`` and
``"sgd"`` when ``lr_decay == 1``. For ``"adam"``, it acts as the
global scale before Adam's coordinate-wise normalization.

``use_line_search`` enables Armijo backtracking on the proposed
update. The solver tests scaled steps ``1, rho, rho^2, ...`` up to
``max_linesearch`` reductions using ``line_search_c1`` as the
sufficient-decrease constant.

``gradient_samples`` controls the number of random directions used
by ``"random_direction_fd"``. ``coordinate_batch_size`` controls
how many coordinates are differentiated per iteration when using
``"coordinate_fd"``; ``0`` means use all coordinates.
__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]
class minionpy.algorithms.IMODE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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 population spread is critical.

Options accepted via options (defaults shown):

{
    "maxiters"                 : -1,
    "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,
    "x_tol"                   : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"          : "reflect-random"
}

Notes

  • Setting population_size to 0 reproduces the MATLAB reference scaling rule.

  • memory_size of 0 activates the heuristic 20 * D success-history length.

  • The default boundary handler is "reflect-random".

__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 population spread is critical.\n\n    Options accepted via ``options`` (defaults shown)::\n\n        {\n            "maxiters"                 : -1,\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            "x_tol"                   : 1e-8,\n            "f_tol": -1.0,\n            "bound_strategy"          : "reflect-random"\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 ``"reflect-random"``.\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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called at each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue.

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. Algorithms without built-in restart strategies accept maxiters; the default -1 disables the iteration cap. Algorithms with tolerance-based stopping use x_tol for coordinate spread and f_tol for relative objective-value spread. The default values are x_tol=1e-8 and f_tol=-1.0 where supported. Set either tolerance to a negative value to disable that specific convergence check.

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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "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",
    "x_tol"                         : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"                : "reflect-random"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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".

  • x_tol (float): Coordinate-spread convergence tolerance.

  • f_tol (float): Relative objective-value spread convergence tolerance.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.LSHADE(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "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",
    "x_tol"                   : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"          : "random"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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".

  • x_tol (float): Coordinate-spread convergence tolerance.

  • f_tol (float): Relative objective-value spread convergence tolerance.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.LSHADE_cnEpSin(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Ensemble 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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 None the population is drawn uniformly within the supplied bounds.

maxevals, callback, seed :

Same semantics as LSHADE. The callback may return True to stop optimization early; False or None continues.

optionsdict, optional

Additional configuration. If None the following defaults are applied:

options = {
    "maxiters"               : -1,
    "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,
    "x_tol"                  : 1e-8,
    "f_tol": -1.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]

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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "population_size"       : 0,  
    "memory_size"           :  5,
    "success_rate"          : 0.5 , 
    "x_tol"                 : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"        : "random"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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 CR and F

  • success_rate (float) : The success rate value.

  • x_tol (float): Coordinate-spread convergence tolerance.

  • f_tol (float): Relative objective-value spread convergence tolerance.

  • 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, monitoring progress, or early stopping by returning True.

  • 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.

class minionpy.algorithms.L_BFGS(func: Callable[[ndarray, object | None], float], x0: List[List[float]], maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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]], maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "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:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.L_BFGS_B(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "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:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.Minimizer(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, algo: str = 'ARRDE', maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

A 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', maxevals: int = 100000, callback: Callable[[Any], bool] | 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”

  • “RDEX”

  • “NLSHADE_RSP”

  • “j2020”

  • “ARRDE”

  • “ABC” (artificial bee colony)

  • “DA” (dual annealing)

  • “L_BFGS_B”

  • “L_BFGS”

  • “CMAES”

  • “ACMAES”

  • “RCMAES”

  • “BIPOP_aCMAES”

  • “PSO”

  • “SPSO2011”

  • “DMSPSO”

  • “LSHADE_cnEpSin”

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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. Algorithms without built-in restart strategies accept maxiters; the default -1 disables the iteration cap. Algorithms with tolerance-based stopping use x_tol for coordinate spread and f_tol for relative objective-value spread. BIPOP_aCMAES and RCMAES also accept max_restarts; -1 means unlimited restarts. A negative x_tol or f_tol disables that specific convergence check.

Notes

  • The optimizer is implemented in C++ and accessed via cppMinimizer.

  • The callback function can be used for logging, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.MinimizerBase(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: object

Base 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called at each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue.

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. Algorithms without built-in restart strategies accept maxiters; the default -1 disables the iteration cap. Algorithms with tolerance-based stopping use x_tol for coordinate spread and f_tol for relative objective-value spread. The default values are x_tol=1e-8 and f_tol=-1.0 where supported. Set either tolerance to a negative value to disable that specific convergence check.

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: object

Stores 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.

  • status: Enum value describing why optimization stopped.

  • message (str): Descriptive message about the optimization outcome.

The public fields mirror the C++ MinionResult.

__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    - **status**: Enum value describing why optimization stopped.\n    - **message** (*str*): Descriptive message about the optimization outcome.\n\n    The public fields mirror the C++ ``MinionResult``.\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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "population_size"       :  0,  
    "minimum_population_size": 4,
    "memory_size"           : 100,
    "archive_size_ratio"    : 2.6 , 
    "x_tol"                 : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"        : "reflect-random"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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.

  • minimum_population_size (int): Final population size after reduction.

  • x_tol (float): Coordinate-spread convergence tolerance.

  • f_tol (float): Relative objective-value spread convergence tolerance.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.NelderMead(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "locality_factor"         : 0.05,
    "x_tol"                   : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"          : "reflect-random"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • bound_strategy (str): Method for handling boundary violations. Available strategies:

    "random", "reflect-random", "clip".

  • x_tol (float): Coordinate-spread convergence tolerance across the simplex.

  • f_tol (float): Relative objective-value spread tolerance across the simplex.

Notes

  • The optimizer is implemented in C++ and accessed via cppNelderMead.

  • The callback function can be used for logging, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.algorithms.PSO(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Canonical particle swarm optimization (global-best topology).

Options

The options dictionary accepts:

  • population_size (int): swarm size (defaults to 5 * D when 0).

  • inertia_weight (float): inertia term \(\omega\) (default 0.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 if True.

  • x_tol (float): coordinate-spread convergence tolerance.

  • f_tol (float): relative objective-value spread convergence tolerance.

  • 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    - ``x_tol`` (*float*): coordinate-spread convergence tolerance.\n    - ``f_tol`` (*float*): relative objective-value spread convergence tolerance.\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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of objective evaluations allowed. Default 100000.

callbackcallable, optional

Callable invoked after each iteration with the current MinionResult. Return True to stop optimization early; return False or None to continue. Default None.

seedint, optional

Random seed for reproducibility. If None (default) a random seed is chosen.

optionsdict, optional

Configuration dictionary. If None the following defaults are used:

{

“maxiters” : -1, “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:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • population_size (int): Swarm size (05 * 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 (0 disables).

  • 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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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 func seeds the initial mean.

maxevalsint, optional

Maximum number of function evaluations. Default 100000.

callbackcallable, optional

User callback receiving intermediate MinionResult objects. Return True to stop optimization early; return False or None to continue.

seedint, optional

Seed for the pseudo-random number generator. None keeps the global RNG state.

optionsdict, optional

Additional RCMAES configuration. If None the following defaults are applied:

options = {
    "population_size"  : 0,
    "rel_initial_step" : 0.3,
    "x_tol"            : 1e-8,
    "f_tol": -1.0,
    "max_restarts"     : -1,
    "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.RDEX(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation of the RDEX algorithm.

Inherits from MinimizerBase and implements the optimization algorithm.

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'minionpy.algorithms', '__doc__': '\n    Implementation of the RDEX algorithm.\n\n    Inherits from MinimizerBase and implements the optimization algorithm.\n    ', '__init__': <function RDEX.__init__>, 'optimize': <function RDEX.optimize>, '__annotations__': {}})
__init__(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Initialize the RDEX 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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 = {
    "maxiters"               : -1,
    "population_size"     : 0,
    "memory_size"         : 5,
    "success_rate"        : 0.5,
    "eb_hybrid_rate_init" : 0.7,
    "perturbation_rate"   : 0.4,
    "x_tol"               : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"      : "random",
}

Notes

  • The optimizer is implemented in C++ and accessed via cppRDEX.

  • The callback function can be used for logging, monitoring progress, or early stopping by returning True.

  • 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.

class minionpy.algorithms.SPSO2011(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Stochastic PSO 2011 (Clerc/Bratton) with constriction and adaptive neighbourhoods.

Options

Default options used when options is None:

{
    "maxiters"                 : -1,
    "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,
    "x_tol"                 : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"        : "reflect-random"
}
  • population_size (int): swarm size (05 * 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.

  • x_tol (float): coordinate-spread convergence tolerance.

  • f_tol (float): relative objective-value spread convergence tolerance.

  • 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            "maxiters"                 : -1,\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            "x_tol"                 : 1e-8,\n            "f_tol": -1.0,\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    - ``x_tol`` (*float*): coordinate-spread convergence tolerance.\n    - ``f_tol`` (*float*): relative objective-value spread convergence tolerance.\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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None) None[source]

Initialize the SPSO2011 algorithm.

Parameters

funccallable

Objective function to be minimised (vectorised, see PSO).

boundslist of tuple

Search-space bounds for each variable.

x0, maxevals, callback, seed, options :

Same semantics as PSO. The callback may return True to stop optimization early; False or None continues.

__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, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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, monitoring progress, or early stopping by returning True.

  • 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.

class minionpy.algorithms.jSO(func: Callable[[ndarray, object | None], float], bounds: List[tuple[float, float]], x0: List[List[float]] | None = None, maxevals: int = 100000, callback: Callable[[Any], bool] | None = None, seed: int | None = None, options: Dict[str, Any] = None)[source]

Bases: MinimizerBase

Implementation 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, maxevals: int = 100000, callback: Callable[[Any], bool] | 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.

maxevalsint, optional

Maximum number of function evaluations allowed. Default is 100000.

callbackcallable, optional

A function called after each iteration with the current optimization state. Return True to stop optimization early; return False or None to continue. 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",
    "x_tol"                     : 1e-8,
    "f_tol": -1.0,
    "bound_strategy"            : "random"
}

The available options are:

  • maxiters (int): Maximum number of algorithm iterations. Default is -1, which disables the iteration cap.

  • 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".

  • x_tol (float): Coordinate-spread convergence tolerance.

  • f_tol (float): Relative objective-value spread convergence tolerance.

  • 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, monitoring progress, or early stopping by returning True.

  • 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 only.

class minionpy.cec.CEC2011Functions(function_number, dimension=None)[source]

Bases: _BenchmarkMetadataMixin

Provides access to the 22 real-world benchmark problems from CEC2011. Each problem has a fixed dimension and bound box defined by the original suite.

__call__(X)[source]

Call self as a function.

__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>, '__annotations__': {}})
__init__(function_number, dimension=None)[source]

Initialize a CEC2011Functions instance.

Parameters

function_numberint

The problem index (must be in the range 1–22).

dimensionint, optional

Accepted for API consistency with the C++ constructor. CEC2011 problems have fixed suite-defined dimensions, so this argument is ignored.

__module__ = 'minionpy.cec'
__weakref__

list of weak references to the object

evaluate(xs)[source]
get_bounds()[source]
get_f_opt()
class minionpy.cec.CEC20142017Functions(function_number, dimension)[source]

Bases: _BenchmarkMetadataMixin

Provides access to the combined CEC2014 + CEC2017 benchmark suite.

This class implements 60 benchmark optimization problems: F1-F30 map to CEC2014 and F31-F60 map to CEC2017.

Available dimensions: 2, 10, 20, 30, 50, 100 Available functions: 1–60

__annotations__ = {}
__call__(X)[source]

Evaluate the selected combined CEC2014/CEC2017 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 combined CEC2014 + CEC2017 benchmark suite.\n\n    This class implements 60 benchmark optimization problems:\n    F1-F30 map to CEC2014 and F31-F60 map to CEC2017.\n\n    Available dimensions: **2, 10, 20, 30, 50, 100**\n    Available functions: **1–60**\n    ', '__init__': <function CEC20142017Functions.__init__>, '__call__': <function CEC20142017Functions.__call__>, '__annotations__': {}})
__init__(function_number, dimension)[source]

Initialize a CEC20142017Functions instance.

Parameters

function_numberint

The function index (must be in the range 1–60). Functions 41–49 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

get_bounds()
get_f_opt()
class minionpy.cec.CEC2014Functions(function_number, dimension)[source]

Bases: _BenchmarkMetadataMixin

Provides 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

__annotations__ = {}
__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__>, '__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

get_bounds()
get_f_opt()
class minionpy.cec.CEC2017Functions(function_number, dimension)[source]

Bases: _BenchmarkMetadataMixin

Provides 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

__annotations__ = {}
__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__>, '__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

get_bounds()
get_f_opt()
class minionpy.cec.CEC2019Functions(function_number, dimension=None)[source]

Bases: _BenchmarkMetadataMixin

Provides access to the CEC2019 benchmark test functions.

This class implements 10 benchmark optimization problems from CEC 2019 at various dimensions.

Available functions: 1–10

__annotations__ = {}
__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__>, '__annotations__': {}})
__init__(function_number, dimension=None)[source]

Initialize a CEC2019Functions instance.

Parameters

function_numberint

The function index (must be in the range 1–10).

dimensionint, optional

Accepted for API consistency with the C++ constructor. The CEC2019 suite uses a fixed problem dimension for each function, so this argument is ignored.

__module__ = 'minionpy.cec'
__weakref__

list of weak references to the object

get_bounds()
get_f_opt()
class minionpy.cec.CEC2020Functions(function_number, dimension)[source]

Bases: _BenchmarkMetadataMixin

Provides 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

__annotations__ = {}
__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__>, '__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

get_bounds()
get_f_opt()
class minionpy.cec.CEC2022Functions(function_number, dimension)[source]

Bases: _BenchmarkMetadataMixin

Provides 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

__annotations__ = {}
__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__>, '__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

get_bounds()
get_f_opt()