| Title: | Secretary Bird Optimization for Continuous Optimization and Neural Network Training |
|---|---|
| Description: | Provides an implementation of Secretary Bird Optimization for general-purpose continuous optimization, benchmark optimization, and training single-hidden-layer feed-forward neural network models. The implemented optimizer is based on the Secretary Bird Optimization Algorithm proposed by Fu et al. (2024) <doi:10.1007/s10462-024-10729-y>. The neural network training functionality is based on Dilber and Özdemir (2026) <doi:10.1007/s00521-026-11874-x>. |
| Authors: | Burak Dilber [aut, cre, cph], A. Fırat Özdemir [aut, cph] |
| Maintainer: | Burak Dilber <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-06-01 07:03:37 UTC |
| Source: | https://github.com/burakdilber/sboatools |
Apply min-max normalization using existing bounds
apply_minmax(x, mins, maxs)apply_minmax(x, mins, maxs)
x |
Numeric vector or matrix. |
mins |
Column minima. |
maxs |
Column maxima. |
Scaled matrix.
Restricts each element of a vector to the given bounds.
clip_bounds(x, lower, upper)clip_bounds(x, lower, upper)
x |
Numeric vector. |
lower |
Lower bound vector. |
upper |
Upper bound vector. |
A bounded numeric vector.
Reverse min-max normalization
denormalize_minmax(x_scaled, mins, maxs)denormalize_minmax(x_scaled, mins, maxs)
x_scaled |
Scaled numeric vector or matrix. |
mins |
Column minima. |
maxs |
Column maxima. |
Values on the original scale.
Computes hidden-layer activations and output predictions.
forward_mlp(params, X, input_dim, hidden_dim, output_dim)forward_mlp(params, X, input_dim, hidden_dim, output_dim)
params |
Numeric parameter vector. |
X |
Input matrix. |
input_dim |
Number of input variables. |
|
Number of hidden neurons. |
|
output_dim |
Number of output neurons. |
A list containing hidden activations and predictions.
Returns a built-in benchmark definition by name.
get_benchmark(name)get_benchmark(name)
name |
Benchmark name such as |
A list containing the benchmark function and its metadata.
b <- get_benchmark("F1") b$fn(rep(0, 5))b <- get_benchmark("F1") b$fn(rep(0, 5))
Generates Lévy-distributed random steps.
levy_flight(d, beta = 1.5)levy_flight(d, beta = 1.5)
d |
Dimension of the step vector. |
beta |
Stability parameter. |
A numeric vector of length d.
Returns a summary table of the built-in F1-F23 benchmark functions.
list_benchmarks()list_benchmarks()
A data frame.
list_benchmarks()list_benchmarks()
Computes the mean absolute error between actual and predicted values.
mae_vec(actual, predicted)mae_vec(actual, predicted)
actual |
Numeric vector or matrix of observed values. |
predicted |
Numeric vector or matrix of predicted values. |
A numeric scalar.
Computes the mean absolute percentage error between actual and predicted values.
mape_vec(actual, predicted, eps = 1e-08)mape_vec(actual, predicted, eps = 1e-08)
actual |
Numeric vector or matrix of observed values. |
predicted |
Numeric vector or matrix of predicted values. |
eps |
Small constant to avoid division by zero. |
A numeric scalar.
Computes mean squared error for a single-hidden-layer MLP.
mlp_mse_fitness(params, X, Y, input_dim, hidden_dim, output_dim)mlp_mse_fitness(params, X, Y, input_dim, hidden_dim, output_dim)
params |
Numeric parameter vector. |
X |
Input matrix. |
Y |
Output matrix. |
input_dim |
Number of input variables. |
|
Number of hidden neurons. |
|
output_dim |
Number of output neurons. |
Mean squared error.
Scales each column of a matrix to the interval from 0 to 1.
normalize_minmax(x)normalize_minmax(x)
x |
Numeric vector or matrix. |
A list containing scaled data and min-max values.
Plots the convergence curve of an SBOA optimization result.
## S3 method for class 'sboa' plot(x, ...)## S3 method for class 'sboa' plot(x, ...)
x |
An object of class |
... |
Additional graphical arguments passed to |
No return value. Called for its side effect.
Plots the convergence curve of a trained SBOA-MLP model.
## S3 method for class 'sboa_mlp' plot(x, ...)## S3 method for class 'sboa_mlp' plot(x, ...)
x |
An object of class |
... |
Additional graphical arguments passed to |
No return value. Called for its side effect.
Generates predictions from a trained SBOA-MLP model.
## S3 method for class 'sboa_mlp' predict(object, newdata, ...)## S3 method for class 'sboa_mlp' predict(object, newdata, ...)
object |
An object of class |
newdata |
New predictor data. |
... |
Additional arguments, ignored. |
A matrix of predicted values.
Prints a summary of an SBOA optimization result.
## S3 method for class 'sboa' print(x, ...)## S3 method for class 'sboa' print(x, ...)
x |
An object of class |
... |
Additional arguments, ignored. |
The input object, invisibly.
Prints a summary of a trained SBOA-MLP model.
## S3 method for class 'sboa_mlp' print(x, ...)## S3 method for class 'sboa_mlp' print(x, ...)
x |
An object of class |
... |
Additional arguments, ignored. |
The input object, invisibly.
Computes the root mean squared error between actual and predicted values.
rmse_vec(actual, predicted)rmse_vec(actual, predicted)
actual |
Numeric vector or matrix of observed values. |
predicted |
Numeric vector or matrix of predicted values. |
A numeric scalar.
Computes the coefficient of determination.
rsq_vec(actual, predicted)rsq_vec(actual, predicted)
actual |
Numeric vector or matrix of observed values. |
predicted |
Numeric vector or matrix of predicted values. |
A numeric scalar.
General-purpose continuous optimization using the Secretary Bird Optimization Algorithm (SBOA).
sboa( fn, lower, upper, n_agents = 30, max_iter = 500, ..., verbose = TRUE, seed = NULL )sboa( fn, lower, upper, n_agents = 30, max_iter = 500, ..., verbose = TRUE, seed = NULL )
fn |
Objective function to be minimized, or a character string
naming a built-in benchmark function such as |
lower |
Lower bounds for decision variables. |
upper |
Upper bounds for decision variables. |
n_agents |
Number of search agents. |
max_iter |
Maximum number of iterations. |
... |
Additional arguments passed to |
verbose |
Logical; if |
seed |
Optional random seed. |
An object of class "sboa".
Fu, W., Wang, K., Liu, J., et al. (2024). Secretary Bird Optimization Algorithm. Artificial Intelligence Review. DOI: 10.1007/s10462-024-10729-y
sphere <- function(x) sum(x^2) res <- sboa( fn = sphere, lower = rep(-10, 5), upper = rep(10, 5), n_agents = 10, max_iter = 20, seed = 123, verbose = FALSE ) res2 <- sboa( fn = "F1", lower = rep(-100, 5), upper = rep(100, 5), n_agents = 10, max_iter = 20, seed = 123, verbose = FALSE ) print(res) print(res2) list_benchmarks() get_benchmark("F9")sphere <- function(x) sum(x^2) res <- sboa( fn = sphere, lower = rep(-10, 5), upper = rep(10, 5), n_agents = 10, max_iter = 20, seed = 123, verbose = FALSE ) res2 <- sboa( fn = "F1", lower = rep(-100, 5), upper = rep(100, 5), n_agents = 10, max_iter = 20, seed = 123, verbose = FALSE ) print(res) print(res2) list_benchmarks() get_benchmark("F9")
Trains a single-hidden-layer multilayer perceptron with the Secretary Bird Optimization Algorithm.
sboa_mlp( X_train, y_train, hidden_dim = 10, n_agents = 30, max_iter = 500, lower = -1, upper = 1, seed = NULL, verbose = TRUE )sboa_mlp( X_train, y_train, hidden_dim = 10, n_agents = 30, max_iter = 500, lower = -1, upper = 1, seed = NULL, verbose = TRUE )
X_train |
Training input data. |
y_train |
Training output data. |
|
Number of hidden neurons. |
|
n_agents |
Number of search agents. |
max_iter |
Maximum number of iterations. |
lower |
Lower bound for parameter search. |
upper |
Upper bound for parameter search. |
seed |
Optional random seed. |
verbose |
Logical; if |
An object of class "sboa_mlp".
Dilber, B., and Ozdemir, A. F. (2026). A novel approach to training feed-forward multi-layer perceptrons with recently proposed secretary bird optimization algorithm. Neural Computing and Applications. DOI: 10.1007/s00521-026-11874-x
set.seed(123) X_train <- matrix(runif(40), nrow = 10, ncol = 4) y_train <- matrix(runif(10), nrow = 10, ncol = 1) fit <- sboa_mlp( X_train = X_train, y_train = y_train, hidden_dim = 3, n_agents = 10, max_iter = 20, lower = -1, upper = 1, seed = 123, verbose = FALSE ) print(fit) pred <- predict(fit, X_train) head(pred)set.seed(123) X_train <- matrix(runif(40), nrow = 10, ncol = 4) y_train <- matrix(runif(10), nrow = 10, ncol = 1) fit <- sboa_mlp( X_train = X_train, y_train = y_train, hidden_dim = 3, n_agents = 10, max_iter = 20, lower = -1, upper = 1, seed = 123, verbose = FALSE ) print(fit) pred <- predict(fit, X_train) head(pred)
Computes the sigmoid transformation.
sigmoid(x)sigmoid(x)
x |
A numeric vector, matrix, or scalar. |
Transformed values in the interval (0, 1).
Converts a flat parameter vector into weight matrices and bias vectors for a single-hidden-layer multilayer perceptron.
unpack_mlp_params(params, input_dim, hidden_dim, output_dim)unpack_mlp_params(params, input_dim, hidden_dim, output_dim)
params |
Numeric parameter vector. |
input_dim |
Number of input variables. |
|
Number of hidden neurons. |
|
output_dim |
Number of output neurons. |
A list containing W1, b1, W2, and b2.