~enricoschumann/neighbours

6c9257bd6da081022f5720a61d31e4b7dc3ef0fb — Enrico Schumann 2 years ago 59c40e7 v0.1-0
Prepare version 0.1-0
6 files changed, 45 insertions(+), 27 deletions(-)

M ChangeLog
M DESCRIPTION
M NEWS
M man/compare_vectors.Rd
M man/neighbourfun.Rd
M vignettes/neighbours.Rnw
M ChangeLog => ChangeLog +6 -1
@@ 1,3 1,7 @@
2022-08-16  Enrico Schumann  <es@enricoschumann.net>

        * DESCRIPTION (Version): 0.1-0

2022-08-10  Enrico Schumann  <es@enricoschumann.net>

        * R/neighbourfun.R (neighbourfun): fix "permute"


@@ 10,7 14,8 @@

2021-09-01  Enrico Schumann  <es@enricoschumann.net>

        * R/neighbourfun.R (ans): add type "permute"
        * R/neighbourfun.R (neighbourfun): add type
        "permute"

2020-06-05  Enrico Schumann  <es@enricoschumann.net>


M DESCRIPTION => DESCRIPTION +2 -2
@@ 2,7 2,7 @@ Package: neighbours
Type: Package
Title: Neighbourhood Functions for Local-Search Algorithms
Version: 0.1-0
Date: 2022-08-15
Date: 2022-08-16
Maintainer: Enrico Schumann <es@enricoschumann.net>
Authors@R: person(given = "Enrico", family = "Schumann",
                  role  = c("aut", "cre"),


@@ 18,7 18,7 @@ Description: Neighbourhood functions are key components of
  solution.  Supported are numeric and logical solutions.
  The algorithms were originally created for
  portfolio-optimisation applications, but can be used for
  other models as well.  Several recipies for neighbour
  other models as well.  Several recipes for neighbour
  computations are taken from "Numerical Methods and
  Optimization in Finance" by M. Gilli, D. Maringer and
  E. Schumann (2019, ISBN:978-0128150658).

M NEWS => NEWS +1 -2
@@ 1,4 1,4 @@
v0.1-0  (2022-08-01)
v0.1-0  (2022-08-16)

  o Initial release.  The package provides a function
    neighbourfun() that constructs neighbourhood


@@ 8,4 8,3 @@ v0.1-0  (2022-08-01)
    applications, but can be used for other models,
    such as variable selection.  The package also
    provides a helper function for comparing solutions.


M man/compare_vectors.Rd => man/compare_vectors.Rd +1 -1
@@ 50,7 50,7 @@ nb <- neighbourfun(type = "logical")

compare_vectors(x, nb(x))
## 01010
##  |   
##  |
## 00010
## The vectors differ in  1  place.


M man/neighbourfun.Rd => man/neighbourfun.Rd +34 -19
@@ 50,12 50,13 @@ neighborfun (min = 0, max = 1, kmin = NULL, kmax = NULL,
    length-one logical vector, which means that all
    elements may be changed.
  }
  \item{update}{either \code{logical} (the default is \code{FALSE}) or
    character, specifying the type of
    updating. Currently supported is \code{"Ax"}, in
    which case the matrix \code{A} must be specified. See
    examples.
  }

  \item{update}{either \code{logical} (the default
    \code{FALSE}) or a string, specifying the type of
    updating. Currently supported is \code{"Ax"}, in which
    case the matrix \code{A} must be specified. See
    Examples.}

  \item{A}{a numeric matrix}
  \item{type}{string: either \code{"numeric"},
    \code{"logical"} or \code{"permute"}


@@ 71,34 72,48 @@ neighborfun (min = 0, max = 1, kmin = NULL, kmax = NULL,
  and \code{...}, which can be used for local-search
  algorithms.

  \code{neighborfun} is an alias for \code{neighbourfun}.


  Three types of solution vectors are supported:
  \describe{

    \item{\code{numeric}}{a neighbour is created by adding or
      subtracting typically small numbers to random elements of a solution}
    \item{\code{logical}}{\code{\link{TRUE}},
      \code{\link{FALSE}} values are switched}
    \item{\code{permute}}{elements of \code{x} are exchanged. Works with
      atomic and generic vectors (aka lists).}
  }
    \item{\code{numeric }}{a neighbour is created by adding
      or subtracting typically small numbers to random
      elements of a solution}%

    \item{\code{logical} }{\code{\link{TRUE}} and
      \code{\link{FALSE} } values are switched}%

    \item{\code{permute}}{elements of \code{x} are
      exchanged. Works with atomic and generic vectors (aka
      lists).}
  }%

  \code{neighborfun} is an alias for \code{neighbourfun}.

}
\value{

  A function (closure) with arguments \code{x} and
  \code{...}.
  \code{\dots}.

}
\section{Note on algorithms}{

  There are different strategies to implement constraints in
  local-search algorithms, and ultimately only experiments
  show which strategy works well for a given problem class.
  The algorithms used by \code{\link{neighbourfun}} always
  require a feasible initial solution, and then remain
  within the space of feasible solutions. See Gilli et
  al. (2019), Section 12.5, for a brief discussion.

}
\references{

  Gilli, M., Maringer, D. and Schumann, E. (2019) \emph{Numerical
  Methods and Optimization in Finance}. 2nd edition. Elsevier.
  Methods and Optimization in Finance}. 2nd edition. Elsevier.\cr
  \url{https://www.elsevier.com/books/numerical-methods-and-optimization-in-finance/gilli/978-0-12-815065-8}

  Schumann, E. (2019) Financial Optimisation with R (\pkg{NMOF} Manual).
  Schumann, E. (2019) Financial Optimisation with R (\pkg{NMOF} Manual).\cr
  \url{http://enricoschumann.net/NMOF.htm#NMOFmanual}

}

M vignettes/neighbours.Rnw => vignettes/neighbours.Rnw +1 -2
@@ 50,8 50,7 @@ be used.  We start by attaching the package and setting
a seed.
<<package-seed>>=
library("neighbours")
set.seed(347343)
# set.seed(34734)
set.seed(3477)
@

\noindent In the examples that follow, we will use a