| Title: | Marine Predators Algorithm |
|---|---|
| Description: | Implementation of the Marine Predators Algorithm (MPA) in R. MPA is a nature-inspired optimization algorithm that follows the rules governing optimal foraging strategy and encounter rate policy between predator and prey in marine ecosystems. Based on the paper by Faramarzi et al. (2020) <doi:10.1016/j.eswa.2020.113377>. |
| Authors: | Marc Grossouvre [trl, cre] (R implementation), Afshin Faramarzi [aut] (Original MATLAB code), Seyedali Mirjalili [aut] (Original MATLAB code) |
| Maintainer: | Marc Grossouvre <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1 |
| Built: | 2026-06-05 09:17:53 UTC |
| Source: | https://github.com/urbs-dev/marinepredator |
The Sphere function is a simple unimodal test function commonly used to evaluate the performance of optimization algorithms. It has a single global minimum at the origin.
F01(x)F01(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Unimodal
Separable: Yes
Differentiable: Yes
Convex: Yes
Default bounds:
Default dimensions: 50
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F01(c(0, 0, 0)) # Returns 0 (global minimum) F01(c(1, 2, 3)) # Returns 1 + 4 + 9 = 14 F01(rep(0, 50)) # Returns 0 in 50 dimensionsF01(c(0, 0, 0)) # Returns 0 (global minimum) F01(c(1, 2, 3)) # Returns 1 + 4 + 9 = 14 F01(rep(0, 50)) # Returns 0 in 50 dimensions
A unimodal test function that combines the sum of absolute values and the product of absolute values.
F02(x)F02(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Unimodal
Separable: No (due to product term)
Differentiable: No (at points where any x_i = 0)
Convex: Yes
Default bounds:
Default dimensions: 50
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F02(c(0, 0)) # Returns 0 (global minimum) F02(c(1, 2)) # Returns |1| + |2| + |1|*|2| = 1 + 2 + 2 = 5 F02(c(-1, -2)) # Returns 1 + 2 + 2 = 5F02(c(0, 0)) # Returns 0 (global minimum) F02(c(1, 2)) # Returns |1| + |2| + |1|*|2| = 1 + 2 + 2 = 5 F02(c(-1, -2)) # Returns 1 + 2 + 2 = 5
A unimodal test function that calculates the sum of squared cumulative sums, also known as the Schwefel 2.22 variant.
F03(x)F03(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Unimodal
Separable: No
Differentiable: Yes
Convex: Yes
Default bounds:
Default dimensions: 50
This function is non-separable because each term depends on all previous variables, making it useful for testing algorithms' ability to handle variable dependencies.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F03(c(0, 0, 0)) # Returns 0 (global minimum) F03(c(1, 2, 3)) # Returns 1^2 + (1+2)^2 + (1+2+3)^2 = 1 + 9 + 36 = 46F03(c(0, 0, 0)) # Returns 0 (global minimum) F03(c(1, 2, 3)) # Returns 1^2 + (1+2)^2 + (1+2+3)^2 = 1 + 9 + 36 = 46
A unimodal test function that returns the maximum absolute value in the input vector, also known as the Schwefel 2.21 function.
F04(x)F04(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Unimodal
Separable: No
Differentiable: No
Convex: Yes
Default bounds:
Default dimensions: 50
This function is particularly challenging because it only depends on the single variable with the largest absolute value, making gradient-based information less useful.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F04(c(0, 0, 0)) # Returns 0 (global minimum) F04(c(-1, 2, -3)) # Returns 3 F04(c(5, -5, 5)) # Returns 5F04(c(0, 0, 0)) # Returns 0 (global minimum) F04(c(-1, 2, -3)) # Returns 3 F04(c(5, -5, 5)) # Returns 5
The Rosenbrock function (also known as Rosenbrock's valley or banana function)
is a classic test function with a narrow, curved valley. While often described
as unimodal, it is technically multimodal for .
F05(x)F05(x)
x |
Numeric vector of input values (minimum length 2). |
Formula:
Global minimum:
Characteristics:
Type: Unimodal (for n < 4), Multimodal (for n >= 4)
Separable: No
Differentiable: Yes
Convex: No
Default bounds:
Default dimensions: 50
The global minimum lies inside a long, narrow, parabolic-shaped flat valley. Finding the valley is trivial, but converging to the global minimum is difficult.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F05(c(1, 1)) # Returns 0 (global minimum) F05(c(0, 0)) # Returns 1 F05(c(1, 1, 1, 1)) # Returns 0 (global minimum in 4D)F05(c(1, 1)) # Returns 0 (global minimum) F05(c(0, 0)) # Returns 1 F05(c(1, 1, 1, 1)) # Returns 0 (global minimum in 4D)
A shifted version of the Sphere function with the minimum at
, also known as the Step function.
F06(x)F06(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Unimodal
Separable: Yes
Differentiable: Yes
Convex: Yes
Default bounds:
Default dimensions: 50
This function tests the algorithm's ability to find optima that are not located at the origin.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F06(c(-0.5, -0.5)) # Returns 0 (global minimum) F06(c(0, 0)) # Returns 0.5 F06(rep(-0.5, 50)) # Returns 0 in 50 dimensionsF06(c(-0.5, -0.5)) # Returns 0 (global minimum) F06(c(0, 0)) # Returns 0.5 F06(rep(-0.5, 50)) # Returns 0 in 50 dimensions
A unimodal test function with quartic terms and added uniform random noise. The noise makes this a stochastic function, useful for testing robustness.
F07(x)F07(x)
x |
Numeric vector of input values. |
Formula:
Global minimum: (stochastic, depends on noise)
Characteristics:
Type: Unimodal (with noise)
Separable: Yes (deterministic part)
Differentiable: Yes
Stochastic: Yes (random noise added)
Default bounds:
Default dimensions: 50
The random noise component makes function evaluations non-deterministic, testing an algorithm's ability to handle noisy objective functions.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F07(c(0, 0, 0)) # Returns a value close to 0 (with some noise) # Multiple calls may return different values due to noise: replicate(5, F07(c(0, 0, 0)))F07(c(0, 0, 0)) # Returns a value close to 0 (with some noise) # Multiple calls may return different values due to noise: replicate(5, F07(c(0, 0, 0)))
A multimodal test function with many local minima. The global minimum is geometrically distant from the next best local minima, making this function deceptive and challenging for optimization algorithms.
F08(x)F08(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Multimodal
Separable: Yes
Differentiable: Yes (except at x_i = 0)
Default bounds:
Default dimensions: 50
The Schwefel function is deceptive in that the global minimum is geometrically distant from the next best local minima. This tests an algorithm's ability to escape local optima and explore widely.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F08(c(420.9687, 420.9687)) # Returns approximately -837.97 (near global minimum) F08(c(0, 0)) # Returns 0F08(c(420.9687, 420.9687)) # Returns approximately -837.97 (near global minimum) F08(c(0, 0)) # Returns 0
A highly multimodal test function with many local minima arranged in a regular lattice pattern. The global minimum is at the origin.
F09(x)F09(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Multimodal
Separable: Yes
Differentiable: Yes
Number of local minima:
Default bounds:
Default dimensions: 50
The Rastrigin function is a typical example of non-linear multimodal function. The large number of local minima makes it difficult for optimization algorithms to find the global minimum.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F09(c(0, 0)) # Returns 0 (global minimum) F09(c(1, 1)) # Returns approximately 2 F09(rep(0, 10)) # Returns 0 in 10 dimensionsF09(c(0, 0)) # Returns 0 (global minimum) F09(c(1, 1)) # Returns approximately 2 F09(rep(0, 10)) # Returns 0 in 10 dimensions
A widely used multimodal test function characterized by a nearly flat outer region with a large central hole at the origin. It poses a risk for optimization algorithms to be trapped in local minima.
F10(x)F10(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Default bounds:
Default dimensions: 50
The Ackley function has an exponential term covering its surface with numerous local minima. The function poses a risk of premature convergence for hill-climbing algorithms.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F10(c(0, 0)) # Returns approximately 0 (global minimum) F10(c(1, 1)) # Returns approximately 3.6F10(c(0, 0)) # Returns approximately 0 (global minimum) F10(c(1, 1)) # Returns approximately 3.6
A multimodal test function with many regularly distributed local minima. The complexity increases with the number of dimensions.
F11(x)F11(x)
x |
Numeric vector of input values. |
Formula:
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Default bounds:
Default dimensions: 50
The Griewank function has a product term that introduces interdependence among the variables. As dimension increases, the function becomes more difficult to optimize.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F11(c(0, 0)) # Returns 0 (global minimum) F11(c(1, 1)) # Returns approximately 0.007F11(c(0, 0)) # Returns 0 (global minimum) F11(c(1, 1)) # Returns approximately 0.007
A multimodal test function with penalty terms that create a complex
search landscape. Uses the Ufun helper function.
F12(x)F12(x)
x |
Numeric vector of input values (minimum length 2). |
Formula:
where and is a penalty function.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes (in the interior)
Penalized: Yes (boundary penalty)
Default bounds:
Default dimensions: 50
The penalty term adds a cost when variables exceed
the threshold , helping to constrain solutions to a feasible region.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters,
Ufun for the penalty function.
F12(c(-1, -1, -1)) # Returns approximately 0 (near global minimum) F12(c(0, 0, 0)) # Returns a small positive valueF12(c(-1, -1, -1)) # Returns approximately 0 (near global minimum) F12(c(0, 0, 0)) # Returns a small positive value
A multimodal test function with different penalty terms than F12,
creating a complex search landscape. Uses the Ufun helper function.
F13(x)F13(x)
x |
Numeric vector of input values (minimum length 2). |
Formula:
where is a penalty function.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes (in the interior)
Penalized: Yes (boundary penalty)
Default bounds:
Default dimensions: 50
This function differs from F12 in the sinusoidal terms and penalty threshold, resulting in different landscape characteristics.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters,
Ufun for the penalty function.
F13(c(1, 1, 1)) # Returns approximately 0 (near global minimum) F13(c(0, 0, 0)) # Returns a small positive valueF13(c(1, 1, 1)) # Returns approximately 0 (near global minimum) F13(c(0, 0, 0)) # Returns a small positive value
A multimodal test function with 25 local minima of different depths, arranged in a grid pattern. Fixed dimension of 2.
F14(x)F14(x)
x |
Numeric vector of length 2 (2-dimensional input). |
Formula:
where are predefined constants forming a 5x5 grid.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 2
Number of local minima: 25
Default bounds:
The 25 minima are located at points from a 5x5 grid with coordinates
in each dimension.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F14(c(-32, -32)) # Returns approximately 0.998 (global minimum) F14(c(0, 0)) # Returns approximately 10F14(c(-32, -32)) # Returns approximately 0.998 (global minimum) F14(c(0, 0)) # Returns approximately 10
A multimodal test function used for testing optimization algorithms, based on fitting experimental data. Fixed dimension of 4.
F15(x)F15(x)
x |
Numeric vector of length 4 (4-dimensional input). |
Formula:
where and are predefined constants from experimental data.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 4
Default bounds:
This function is derived from a curve-fitting problem and has several local minima near the global minimum.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F15(c(0.1928, 0.1908, 0.1231, 0.1358)) # Returns approximately 0.0003 F15(c(0, 0, 0, 0)) # Returns a larger valueF15(c(0.1928, 0.1908, 0.1231, 0.1358)) # Returns approximately 0.0003 F15(c(0, 0, 0, 0)) # Returns a larger value
A multimodal test function with six local minima, two of which are global. Fixed dimension of 2.
F16(x)F16(x)
x |
Numeric vector of length 2 (2-dimensional input). |
Formula:
Global minimum:
There are two global minima at approximately and
.
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 2
Number of local minima: 6
Number of global minima: 2
Default bounds:
The function has a shape resembling a camel's back with six humps (minima).
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F16(c(0.0898, -0.7126)) # Returns approximately -1.0316 (global minimum) F16(c(-0.0898, 0.7126)) # Returns approximately -1.0316 (global minimum) F16(c(0, 0)) # Returns 0F16(c(0.0898, -0.7126)) # Returns approximately -1.0316 (global minimum) F16(c(-0.0898, 0.7126)) # Returns approximately -1.0316 (global minimum) F16(c(0, 0)) # Returns 0
A multimodal test function with three global minima, commonly used for testing optimization algorithms. Fixed dimension of 2.
F17(x)F17(x)
x |
Numeric vector of length 2 (2-dimensional input). |
Formula:
Global minimum: at three locations:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 2
Number of global minima: 3
Default bounds: ,
The Branin function is often used as a benchmark because it has three global minima that are well-separated.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F17(c(-pi, 12.275)) # Returns approximately 0.398 (global minimum) F17(c(pi, 2.275)) # Returns approximately 0.398 (global minimum) F17(c(9.42478, 2.475)) # Returns approximately 0.398 (global minimum)F17(c(-pi, 12.275)) # Returns approximately 0.398 (global minimum) F17(c(pi, 2.275)) # Returns approximately 0.398 (global minimum) F17(c(9.42478, 2.475)) # Returns approximately 0.398 (global minimum)
A multimodal test function with four local minima and one global minimum. Fixed dimension of 2.
F18(x)F18(x)
x |
Numeric vector of length 2 (2-dimensional input). |
Formula:
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 2
Number of local minima: 4
Default bounds:
The Goldstein-Price function has a complex landscape with the global minimum surrounded by local minima of increasing value.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters.
F18(c(0, -1)) # Returns 3 (global minimum) F18(c(0, 0)) # Returns 600F18(c(0, -1)) # Returns 3 (global minimum) F18(c(0, 0)) # Returns 600
A multimodal test function with 4 local minima in 3 dimensions. Fixed dimension of 3.
F19(x)F19(x)
x |
Numeric vector of length 3 (3-dimensional input). |
Formula:
where , , and are predefined constants.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 3
Number of local minima: 4
Default bounds:
The Hartmann functions are a family of multimodal test functions commonly used in optimization benchmarks.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters,
F20 for the 6D version.
F19(c(0.114614, 0.555649, 0.852547)) # Returns approximately -3.86278 F19(c(0.5, 0.5, 0.5)) # Returns a value > -3.86F19(c(0.114614, 0.555649, 0.852547)) # Returns approximately -3.86278 F19(c(0.5, 0.5, 0.5)) # Returns a value > -3.86
A multimodal test function with 6 local minima in 6 dimensions. Fixed dimension of 6.
F20(x)F20(x)
x |
Numeric vector of length 6 (6-dimensional input). |
Formula:
where , , and are predefined constants.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 6
Number of local minima: 6
Default bounds:
The Hartmann 6D function is more challenging than the 3D version due to the higher dimensionality.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters,
F19 for the 3D version.
F20(c(0.20169, 0.150011, 0.476874, 0.275332, 0.311652, 0.6573)) # Returns approximately -3.32237F20(c(0.20169, 0.150011, 0.476874, 0.275332, 0.311652, 0.6573)) # Returns approximately -3.32237
A multimodal test function from the Shekel family with 5 local minima. Fixed dimension of 4.
F21(x)F21(x)
x |
Numeric vector of length 4 (4-dimensional input). |
Formula:
where are 4-dimensional vectors and are scalars.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 4
Number of local minima: 5
Default bounds:
The Shekel functions are parameterized by the number of terms m (here m=5). As m increases, the function becomes more challenging.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters,
F22 for Shekel 7, F23 for Shekel 10.
F21(c(4, 4, 4, 4)) # Returns approximately -10.15 (near global minimum) F21(c(0, 0, 0, 0)) # Returns a value close to 0F21(c(4, 4, 4, 4)) # Returns approximately -10.15 (near global minimum) F21(c(0, 0, 0, 0)) # Returns a value close to 0
A multimodal test function from the Shekel family with 7 local minima. Fixed dimension of 4.
F22(x)F22(x)
x |
Numeric vector of length 4 (4-dimensional input). |
Formula:
where are 4-dimensional vectors and are scalars.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 4
Number of local minima: 7
Default bounds:
The Shekel 7 function has more local minima than Shekel 5, making it slightly more challenging.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters,
F21 for Shekel 5, F23 for Shekel 10.
F22(c(4, 4, 4, 4)) # Returns approximately -10.40 (near global minimum) F22(c(0, 0, 0, 0)) # Returns a value close to 0F22(c(4, 4, 4, 4)) # Returns approximately -10.40 (near global minimum) F22(c(0, 0, 0, 0)) # Returns a value close to 0
A multimodal test function from the Shekel family with 10 local minima. Fixed dimension of 4.
F23(x)F23(x)
x |
Numeric vector of length 4 (4-dimensional input). |
Formula:
where are 4-dimensional vectors and are scalars.
Global minimum:
Characteristics:
Type: Multimodal
Separable: No
Differentiable: Yes
Fixed dimension: 4
Number of local minima: 10
Default bounds:
The Shekel 10 function is the most challenging of the Shekel family due to having the most local minima.
Numeric scalar representing the function value.
test-functions for an overview of all test functions,
get_function_details to retrieve function parameters,
F21 for Shekel 5, F22 for Shekel 7.
F23(c(4, 4, 4, 4)) # Returns approximately -10.54 (near global minimum) F23(c(0, 0, 0, 0)) # Returns a value close to 0F23(c(4, 4, 4, 4)) # Returns approximately -10.54 (near global minimum) F23(c(0, 0, 0, 0)) # Returns a value close to 0
Retrieves the details (bounds, dimension, and function object) for a specific benchmark test function.
get_function_details(function_name)get_function_details(function_name)
function_name |
Name of the test function (e.g., "F01", "F02", ..., "F23") |
A list containing:
lb |
Lower bounds for the function |
ub |
Upper bounds for the function |
dim |
Number of dimensions |
fobj |
The objective function |
# Get details for the Sphere function (F01) details <- get_function_details("F01") str(details)# Get details for the Sphere function (F01) details <- get_function_details("F01") str(details)
Initializes the first population of search agents (prey) for the Marine Predators Algorithm.
initialize_population(SearchAgents_no, dim, ub, lb)initialize_population(SearchAgents_no, dim, ub, lb)
SearchAgents_no |
Number of search agents |
dim |
Number of dimensions |
ub |
Upper bounds for each dimension |
lb |
Lower bounds for each dimension |
A matrix of initialized positions
# Initialize a population of 25 agents in 30 dimensions with bounds [-100, 100] population <- initialize_population(25, 30, 100, -100)# Initialize a population of 25 agents in 30 dimensions with bounds [-100, 100] population <- initialize_population(25, 30, 100, -100)
Generates Levy flight random steps for optimization algorithms. Levy flight is characterized by a heavy-tailed power-law distribution and is used to model the movement patterns of marine predators, allowing for occasional long jumps that help escape local optima.
levy(n, m, beta)levy(n, m, beta)
n |
Number of rows (typically the number of search agents). |
m |
Number of columns (typically the number of dimensions). |
beta |
Power law exponent controlling the tail heaviness of the
distribution. Must satisfy |
The Levy flight step is computed using Mantegna's algorithm:
where and , with:
Levy flights are used in MPA during Phase 2 (for half the population) and Phase 3 (for all agents) to balance exploration and exploitation.
A numeric matrix of dimension n x m containing Levy flight
step values. Each element represents a random step drawn from the Levy
distribution.
Mantegna, R. N. (1994). Fast, accurate algorithm for numerical simulation of Levy stable stochastic processes. Physical Review E, 49(5), 4677.
Yang, X. S., & Deb, S. (2013). Multiobjective cuckoo search for design optimization. Computers & Operations Research, 40(6), 1616-1624.
[mpa()] for the main algorithm that uses Levy flights.
# Generate 10 Levy flight steps in 2 dimensions with beta = 1.5 steps <- levy(10, 2, 1.5) dim(steps) # 10 x 2 # Visualize the distribution of Levy steps steps_1d <- levy(1000, 1, 1.5) hist(steps_1d, breaks = 50, main = "Levy Flight Distribution")# Generate 10 Levy flight steps in 2 dimensions with beta = 1.5 steps <- levy(10, 2, 1.5) dim(steps) # 10 x 2 # Visualize the distribution of Levy steps steps_1d <- levy(1000, 1, 1.5) hist(steps_1d, breaks = 50, main = "Levy Flight Distribution")
Implementation of the Marine Predators Algorithm (MPA) in R. MPA is a nature-inspired optimization algorithm that follows the rules governing optimal foraging strategy and encounter rate policy between predator and prey in marine ecosystems.
mpa(SearchAgents_no, Max_iter, lb, ub, dim, fobj, logFile = NULL, ...)mpa(SearchAgents_no, Max_iter, lb, ub, dim, fobj, logFile = NULL, ...)
SearchAgents_no |
Number of search agents (predators). At least 2. Typical values range from 20 to 50. |
Max_iter |
Maximum number of iterations. At least 3. Typical values range from 100 to 500 depending on problem complexity. |
lb |
Lower bounds for each dimension. Can be a single value (applied to
all dimensions) or a vector of length |
ub |
Upper bounds for each dimension. Can be a single value (applied to
all dimensions) or a vector of length |
dim |
Number of dimensions (decision variables) in the optimization problem. |
fobj |
Objective function to minimize. Must accept a numeric vector of
length |
logFile |
A path for logging (text file). Defaulted to |
... |
Additional arguments. Currently supports |
This is a minimization algorithm. To maximize a function, negate its
output (e.g., use function(x) -f(x) instead of f).
An object of class mpa_result, which is a list containing:
Top_predator_fit |
Best fitness value found (numeric scalar) |
Top_predator_pos |
Best position found (numeric vector of length |
Convergence_curve |
Convergence curve over iterations (numeric vector
of length |
The MPA algorithm operates in three distinct phases based on the iteration count:
High velocity ratio - The prey moves faster than the predator. Exploration is emphasized using Brownian motion. This phase promotes global search across the solution space.
Unit velocity ratio - Predator and prey move at similar speeds. The population is split: half uses Brownian motion (exploitation), half uses Levy flight (exploration). This balances exploration and exploitation.
Low velocity ratio - The predator moves faster than the prey. Levy flight is used for all agents, focusing on exploitation around the best solution found.
The algorithm uses two internal parameters that are not exposed:
Fish Aggregating Devices effect parameter, set to 0.2. Controls the probability of applying the FADs effect which helps escape local optima.
Prey movement probability, set to 0.5. Controls the step size scaling factor during position updates.
MPA implements a memory mechanism (Marine Memory) that preserves the best positions found by each agent. If a new position has worse fitness than the previous one, the agent reverts to its previous position.
The ... parameter currently accepts:
A character string to prefix log messages. Defaults to empty string if not provided.
Faramarzi, A., Heidarinejad, M., Mirjalili, S., & Gandomi, A. H. (2020). Marine Predators Algorithm: A Nature-inspired Metaheuristic. Expert Systems with Applications, 152, 113377. doi:10.1016/j.eswa.2020.113377
[get_function_details()] for benchmark functions, [levy()] for Levy flight implementation, [initialize_population()] for population initialization.
# Basic usage with the Sphere function (F01) result <- mpa( SearchAgents_no = 25, Max_iter = 100, lb = -100, ub = 100, dim = 30, fobj = F01 ) print(result) # Using different bounds per dimension result2 <- mpa( SearchAgents_no = 20, Max_iter = 50, lb = c(-5, 0), ub = c(10, 15), dim = 2, fobj = F17 ) # Maximization example (negate the objective function) maximize_f <- function(x) -sum(x^2) result3 <- mpa( SearchAgents_no = 20, Max_iter = 50, lb = -10, ub = 10, dim = 5, fobj = function(x) -maximize_f(x) ) # The actual maximum value is -result3$Top_predator_fit# Basic usage with the Sphere function (F01) result <- mpa( SearchAgents_no = 25, Max_iter = 100, lb = -100, ub = 100, dim = 30, fobj = F01 ) print(result) # Using different bounds per dimension result2 <- mpa( SearchAgents_no = 20, Max_iter = 50, lb = c(-5, 0), ub = c(10, 15), dim = 2, fobj = F17 ) # Maximization example (negate the objective function) maximize_f <- function(x) -sum(x^2) result3 <- mpa( SearchAgents_no = 20, Max_iter = 50, lb = -10, ub = 10, dim = 5, fobj = function(x) -maximize_f(x) ) # The actual maximum value is -result3$Top_predator_fit
Prints a summary of the Marine Predators Algorithm optimization results.
## S3 method for class 'mpa_result' print(x, ...)## S3 method for class 'mpa_result' print(x, ...)
x |
An object of class |
... |
Additional arguments (currently unused). |
Invisibly returns the input object x.
result <- mpa(SearchAgents_no = 10, Max_iter = 20, lb = -10, ub = 10, dim = 5, fobj = F01) print(result)result <- mpa(SearchAgents_no = 10, Max_iter = 20, lb = -10, ub = 10, dim = 5, fobj = F01) print(result)
Collection of benchmark test functions for evaluating optimization algorithms. These functions are commonly used in the literature to test the performance of metaheuristic optimization algorithms.
The following test functions are implemented:
Unimodal Functions:
F01 - Sphere function: Simple quadratic function with a single minimum at the origin. F01
F02 - Sum of absolute values and products: Combines sum and product of absolute values. F02
F03 - Sum of squared terms: Sum of squared cumulative sums. F03
F04 - Maximum absolute value: Returns the maximum absolute value in the vector. F04
F05 - Rosenbrock function: Classic test function with a banana-shaped valley. F05
F06 - Shifted sphere function: Sphere function shifted to (-0.5, -0.5, ...). F06
F07 - Quartic function with noise: Quartic terms with added random noise. F07
Multimodal Functions:
F08 - Schwefel function: Multimodal function with many local minima. F08
F09 - Rastrigin function: Many local minima arranged in a regular pattern. F09
F10 - Ackley function: Global minimum at origin with many local minima. F10
F11 - Griewank function: Many local minima regularly distributed. F11
F12 - Penalized function 1: Complex landscape with penalty terms. F12
F13 - Penalized function 2: Different penalty terms creating complex landscape. F13
F14 - Shekel's Foxholes: 25 minima of different depths. F14
F15 - Kowalik function: Multimodal function for testing optimization. F15
F16 - Six-Hump Camel Back: Six local minima, two global. F16
F17 - Branin function: Commonly used for testing optimization algorithms. F17
F18 - Goldstein-Price function: Four local minima. F18
F19 - Hartman 3D function: 3 dimensions with multiple local minima. F19
F20 - Hartman 6D function: 6 dimensions with multiple local minima. F20
F21 - Shekel 5 function: Based on Shekel's family with 5 terms. F21
F22 - Shekel 7 function: Based on Shekel's family with 7 terms. F22
F23 - Shekel 10 function: Based on Shekel's family with 10 terms. F23
Faramarzi, A., Heidarinejad, M., Mirjalili, S., & Gandomi, A. H. (2020). Marine Predators Algorithm: A Nature-inspired Metaheuristic. Expert Systems with Applications, 113377. DOI: 10.1016/j.eswa.2020.113377
F01 through F23 for individual function documentation.
get_function_details to retrieve function details programmatically.
# Get details for a specific function details <- get_function_details("F01") # Use a test function directly F01(c(0, 0, 0)) # Returns 0 (global minimum) # List all available test functions available_functions <- c("F01", "F02", "F03", "F04", "F05", "F06", "F07", "F08", "F09", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23")# Get details for a specific function details <- get_function_details("F01") # Use a test function directly F01(c(0, 0, 0)) # Returns 0 (global minimum) # List all available test functions available_functions <- c("F01", "F02", "F03", "F04", "F05", "F06", "F07", "F08", "F09", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23")