diff --git a/DESCRIPTION b/DESCRIPTION index 3b37cf1..f9707eb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,7 @@ Authors@R: c( ) Description: An implementation of Karaboga (2005) Artificial Bee Colony Optimization algorithm . - This was developed upon the basic version programmed in C and distributed + This was developed upon the basic version programmed in C and available at the algorithm's official website. Classification/ACM: G.1.6 Classification/JEL: C61 @@ -26,3 +26,4 @@ Imports: RoxygenNote: 6.0.1.9000 Suggests: testthat, covr +Roxygen: list(markdown = TRUE) diff --git a/R/ABCoptim-package.R b/R/ABCoptim-package.R index d07c566..0d61b12 100644 --- a/R/ABCoptim-package.R +++ b/R/ABCoptim-package.R @@ -3,33 +3,29 @@ #' An implementation of the Artificial Bee Colony (ABC) Algorithm #' #' This is an implementation of Karaboga (2005) ABC optimization algorithm. It -#' was developed upon the basic version programmed in \code{C} and distributed +#' was developed upon the basic version programmed in `C` and distributed #' at the algorithm's official website (see the references). #' -#' Please consider that this version is in alpha state of development, thus any -#' evident (precision) error should be blaimed to the package author (not to -#' the algorithm itself) +#' Any evident (precision) error should be blaimed to the package author (not to +#' the algorithm itself). #' #' Please visit the project home for more information: -#' \url{https://github.com/gvegayon/ABCoptim}. +#' https://github.com/gvegayon/ABCoptim. #' #' @name ABCoptim-package #' @aliases ABCoptim-package ABCoptim abc #' @docType package -#' @author George Vega Yon \email{g.vegayon@@gmail.com} [aut], -#' -#' Enyelbert Muñoz \email{enyeldoc2011@@gmail.com} [cnt) -#' @references D. Karaboga, \emph{An Idea based on Honey Bee Swarm for -#' Numerical Optimization}, tech. report TR06,Erciyes University, Engineering +#' @references D. Karaboga, *An Idea based on Honey Bee Swarm for +#' Numerical Optimization*, tech. report TR06,Erciyes University, Engineering #' Faculty, Computer Engineering Department, 2005 -#' \url{http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf} +#' http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf #' #' #' Artificial Bee Colony (ABC) Algorithm (website) -#' \url{http://mf.erciyes.edu.tr/abc/index.htm} +#' http://mf.erciyes.edu.tr/abc/index.htm #' -#' Basic version of the algorithm implemented in \code{C} (ABC's official -#' website) \url{http://mf.erciyes.edu.tr/abc/form.aspx} +#' Basic version of the algorithm implemented in `C` (ABC's official +#' website) http://mf.erciyes.edu.tr/abc/form.aspx #' @keywords package #' @examples #' diff --git a/R/RcppExports.R b/R/RcppExports.R index de7160a..253125a 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1,7 +1,7 @@ # Generated by using Rcpp::compileAttributes() -> do not edit by hand # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 -abc_cpp_ <- function(par, fn, lb, ub, FoodNumber = 20L, limit = 100L, maxCycle = 1000L, criter = 50L) { - .Call(`_ABCoptim_abc_cpp_`, par, fn, lb, ub, FoodNumber, limit, maxCycle, criter) +.abc_cpp <- function(par, fn, lb, ub, FoodNumber = 20L, limit = 100L, maxCycle = 1000L, criter = 50L) { + .Call(`_ABCoptim_abc_cpp`, par, fn, lb, ub, FoodNumber, limit, maxCycle, criter) } diff --git a/R/abc_optim.R b/R/abc_optim.R index 869bd09..e77157b 100644 --- a/R/abc_optim.R +++ b/R/abc_optim.R @@ -6,62 +6,62 @@ #' @param fn A function to be minimized, with first argument of the vector of #' parameters over which minimization is to take place. It should return a #' scalar result. -#' @param ... In the case of \code{abc_*}, further arguments to be passed to 'fn', +#' @param ... In the case of `abc_*`, further arguments to be passed to 'fn', #' otherwise, further arguments passed to the method. #' @param FoodNumber Number of food sources to exploit. Notice that the param -#' \code{NP} has been deprecated. +#' `NP` has been deprecated. #' @param lb,ub Numeric vectors or scalars. Upper and lower bounds of the #' parameters to be optimized. #' @param limit Integer scalar. Limit of a food source. #' @param maxCycle Integer scalar. Maximum number of iterations. #' @param optiinteger Logical scalar. Whether to optimize binary parameters or not. #' @param criter Integer scalar. Stop criteria (numer of unchanged results) until stopping -#' @param parscale Numeric vector of length \code{length(par)}. Scale applied -#' to the parameters (see \code{\link[stats:optim]{optim}}). -#' @param fnscale Numeric scalar. Scale applied function. If \code{fnscale < 0}, -#' then the problem becomes a maximization problem (see \code{\link[stats:optim]{optim}}). +#' @param parscale Numeric vector of length `length(par)`. Scale applied +#' to the parameters (see [stats:optim::optim()]). +#' @param fnscale Numeric scalar. Scale applied function. If `fnscale < 0`, +#' then the problem becomes a maximization problem (see [stats:optim::optim()]). #' #' @details #' #' This implementation of the ABC algorithm was developed based on the basic -#' version written in \code{C} and published at the algorithm's official +#' version written in `C` and published at the algorithm's official #' website (see references). #' -#' \code{abc_optim} and \code{abc_cpp} are two different implementations of the -#' algorithm, the former using pure \code{R} code, and the later using \code{C++}, +#' `abc_optim` and `abc_cpp` are two different implementations of the +#' algorithm, the former using pure `R` code, and the later using `C++`, #' via the \pkg{Rcpp} package. Besides of the output, another important -#' difference between the two implementations is speed, with \code{abc_cpp} +#' difference between the two implementations is speed, with `abc_cpp` #' showing between 50\% and 100\% faster performance. #' -#' Upper and Lower bounds (\code{ub}, \code{lb}) equal to infinite will be replaced -#' by either \code{.Machine$double.xmax} or \code{-.Machine$double.xmax}. +#' Upper and Lower bounds (`ub`, `lb`) equal to infinite will be replaced +#' by either `.Machine$double.xmax` or `-.Machine$double.xmax`. #' -#' If \code{D} (the number of parameters to be optimzed) is greater than one, -#' then \code{lb} and \code{ub} can be either scalars (assuming that all the +#' If `D` (the number of parameters to be optimzed) is greater than one, +#' then `lb` and `ub` can be either scalars (assuming that all the #' parameters share the same boundaries) or vectors (the parameters have #' different boundaries each other). #' -#' @return An list of class \code{abc_answer}, holding the following elements: +#' @return An list of class `abc_answer`, holding the following elements: #' \item{Foods}{Numeric matrix. Last position of the bees.} -#' \item{f}{Numeric vector. Value of the function evaluated at each set of \code{Foods}.} -#' \item{fitness}{Numeric vector. Fitness of each \code{Foods}.} -#' \item{trial}{Integer vector. Number of trials at each \code{Foods}.} +#' \item{f}{Numeric vector. Value of the function evaluated at each set of `Foods`.} +#' \item{fitness}{Numeric vector. Fitness of each `Foods`.} +#' \item{trial}{Integer vector. Number of trials at each `Foods`.} #' \item{value}{Numeric scalar. Value of the function evaluated at the optimum.} #' \item{par}{Numeric vector. Optimum found.} #' \item{counts}{Integer scalar. Number of cycles.} #' \item{hist}{Numeric matrix. Trace of the global optimums.} #' #' @author George Vega Yon \email{g.vegayon@@gmail.com} -#' @references D. Karaboga, \emph{An Idea based on Honey Bee Swarm for -#' Numerical Optimization}, tech. report TR06,Erciyes University, Engineering +#' @references D. Karaboga, *An Idea based on Honey Bee Swarm for +#' Numerical Optimization*, tech. report TR06,Erciyes University, Engineering #' Faculty, Computer Engineering Department, 2005 -#' \url{http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf} +#' http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf #' #' Artificial Bee Colony (ABC) Algorithm (website) -#' \url{http://mf.erciyes.edu.tr/abc/index.htm} +#' http://mf.erciyes.edu.tr/abc/index.htm #' -#' Basic version of the algorithm implemented in \code{C} (ABC's official -#' website) \url{http://mf.erciyes.edu.tr/abc/form.aspx} +#' Basic version of the algorithm implemented in `C` (ABC's official +#' website) http://mf.erciyes.edu.tr/abc/form.aspx #' @keywords optimization #' @examples #' @@ -428,7 +428,7 @@ abc_optim <- function( } #' @export -#' @param x An object of class \code{abc_answer}. +#' @param x An object of class `abc_answer`. #' @rdname abc_optim print.abc_answer <- function(x, ...) { cat("\n") @@ -545,7 +545,7 @@ abc_cpp <- function( fun <- function(par) fn(par/parscale, ...)/fnscale - ans <- abc_cpp_(par, fun, lb, ub, FoodNumber, limit, maxCycle, criter) + ans <- .abc_cpp(par, fun, lb, ub, FoodNumber, limit, maxCycle, criter) ans[["fn"]] <- fn structure( @@ -557,18 +557,18 @@ abc_cpp <- function( } #' @export -#' @details The \code{plot} method shows the trace of the objective function +#' @details The `plot` method shows the trace of the objective function #' as the algorithm unfolds. The line is merely the result of the objective -#' function evaluated at each point (row) of the \code{hist} matrix return by -#' \code{abc_optim}/\code{abc_cpp}. +#' function evaluated at each point (row) of the `hist` matrix return by +#' `abc_optim`/`abc_cpp`. #' -#' For now, the function will return with error if \code{...} was passed to -#' \code{abc_optim}/\code{abc_cpp}, since those argumens are not stored with the +#' For now, the function will return with error if `...` was passed to +#' `abc_optim`/`abc_cpp`, since those argumens are not stored with the #' result. #' #' @rdname abc_optim #' @param y Ignored -#' @param main,xlab,ylab,type Passed to \code{\link[graphics:plot.default]{plot}}. +#' @param main,xlab,ylab,type Passed to [graphics:plot.default::plot()]. plot.abc_answer <- function( x, y = NULL, diff --git a/man/ABCoptim-package.Rd b/man/ABCoptim-package.Rd index 33a21e5..f5b65fc 100644 --- a/man/ABCoptim-package.Rd +++ b/man/ABCoptim-package.Rd @@ -17,7 +17,7 @@ evident (precision) error should be blaimed to the package author (not to the algorithm itself) Please visit the project home for more information: -\url{https://github.com/gvegayon/ABCoptim}. +https://github.com/gvegayon/ABCoptim. } \examples{ @@ -30,17 +30,16 @@ Please visit the project home for more information: D. Karaboga, \emph{An Idea based on Honey Bee Swarm for Numerical Optimization}, tech. report TR06,Erciyes University, Engineering Faculty, Computer Engineering Department, 2005 -\url{http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf} - +http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf Artificial Bee Colony (ABC) Algorithm (website) -\url{http://mf.erciyes.edu.tr/abc/index.htm} +http://mf.erciyes.edu.tr/abc/index.htm Basic version of the algorithm implemented in \code{C} (ABC's official -website) \url{http://mf.erciyes.edu.tr/abc/form.aspx} +website) http://mf.erciyes.edu.tr/abc/form.aspx } \author{ -George Vega Yon \email{g.vegayon@gmail.com} [aut], +George Vega Yon \email{g.vegayon@gmail.com} \link{aut}, Enyelbert Muñoz \email{enyeldoc2011@gmail.com} [cnt) } diff --git a/man/abc_optim.Rd b/man/abc_optim.Rd index e8935bd..c923ea8 100644 --- a/man/abc_optim.Rd +++ b/man/abc_optim.Rd @@ -48,16 +48,16 @@ parameters to be optimized.} \item{criter}{Integer scalar. Stop criteria (numer of unchanged results) until stopping} \item{parscale}{Numeric vector of length \code{length(par)}. Scale applied -to the parameters (see \code{\link[stats:optim]{optim}}).} +to the parameters (see \code{\link[stats:optim:optim]{stats:optim::optim()}}).} -\item{fnscale}{Numeric scalar. Scale applied function. If \code{fnscale < 0}, -then the problem becomes a maximization problem (see \code{\link[stats:optim]{optim}}).} +\item{fnscale}{Numeric scalar. Scale applied function. If \code{fnscale < 0}, +then the problem becomes a maximization problem (see \code{\link[stats:optim:optim]{stats:optim::optim()}}).} \item{x}{An object of class \code{abc_answer}.} \item{y}{Ignored} -\item{main, xlab, ylab, type}{Passed to \code{\link[graphics:plot.default]{plot}}.} +\item{main, xlab, ylab, type}{Passed to \code{\link[graphics:plot.default:plot]{graphics:plot.default::plot()}}.} } \value{ An list of class \code{abc_answer}, holding the following elements: @@ -177,13 +177,13 @@ coef(lm(y~0+X)) D. Karaboga, \emph{An Idea based on Honey Bee Swarm for Numerical Optimization}, tech. report TR06,Erciyes University, Engineering Faculty, Computer Engineering Department, 2005 -\url{http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf} +http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf Artificial Bee Colony (ABC) Algorithm (website) -\url{http://mf.erciyes.edu.tr/abc/index.htm} +http://mf.erciyes.edu.tr/abc/index.htm Basic version of the algorithm implemented in \code{C} (ABC's official -website) \url{http://mf.erciyes.edu.tr/abc/form.aspx} +website) http://mf.erciyes.edu.tr/abc/form.aspx } \author{ George Vega Yon \email{g.vegayon@gmail.com} diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index db1735c..50e1c8d 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -5,9 +5,9 @@ using namespace Rcpp; -// abc_cpp_ -List abc_cpp_(NumericVector& par, Function& fn, const NumericVector& lb, const NumericVector& ub, int FoodNumber, int limit, int maxCycle, int criter); -RcppExport SEXP _ABCoptim_abc_cpp_(SEXP parSEXP, SEXP fnSEXP, SEXP lbSEXP, SEXP ubSEXP, SEXP FoodNumberSEXP, SEXP limitSEXP, SEXP maxCycleSEXP, SEXP criterSEXP) { +// abc_cpp +List abc_cpp(NumericVector& par, Function& fn, const NumericVector& lb, const NumericVector& ub, int FoodNumber, int limit, int maxCycle, int criter); +RcppExport SEXP _ABCoptim_abc_cpp(SEXP parSEXP, SEXP fnSEXP, SEXP lbSEXP, SEXP ubSEXP, SEXP FoodNumberSEXP, SEXP limitSEXP, SEXP maxCycleSEXP, SEXP criterSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; @@ -19,13 +19,13 @@ BEGIN_RCPP Rcpp::traits::input_parameter< int >::type limit(limitSEXP); Rcpp::traits::input_parameter< int >::type maxCycle(maxCycleSEXP); Rcpp::traits::input_parameter< int >::type criter(criterSEXP); - rcpp_result_gen = Rcpp::wrap(abc_cpp_(par, fn, lb, ub, FoodNumber, limit, maxCycle, criter)); + rcpp_result_gen = Rcpp::wrap(abc_cpp(par, fn, lb, ub, FoodNumber, limit, maxCycle, criter)); return rcpp_result_gen; END_RCPP } static const R_CallMethodDef CallEntries[] = { - {"_ABCoptim_abc_cpp_", (DL_FUNC) &_ABCoptim_abc_cpp_, 8}, + {"_ABCoptim_abc_cpp", (DL_FUNC) &_ABCoptim_abc_cpp, 8}, {NULL, NULL, 0} }; diff --git a/src/abc.cpp b/src/abc.cpp index 345406d..13103a7 100644 --- a/src/abc.cpp +++ b/src/abc.cpp @@ -207,8 +207,8 @@ void SendScoutBees( return; } -// [[Rcpp::export]] -List abc_cpp_( +// [[Rcpp::export(name=".abc_cpp")]] +List abc_cpp( NumericVector & par, Function & fn, const NumericVector & lb,