Skip to content

Commit

Permalink
add more examples; improve docs of return value of EMOAs
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Sep 4, 2017
1 parent 1ab4ced commit b431c15
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/mcMSTEmoaBG.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#' @param max.iter [\code{integer(1)}]\cr
#' Maximal number of iterations.
#' Default is \code{100}.
#' @return [\code{\link[ecr]{ecr_result}}]
#' @template ret_ecrresult
#' @examples
#' inst = genRandomMCGP(10)
#' res = mcMSTEmoaBG(inst, mu = 20L, max.iter = 100L)
Expand Down
1 change: 1 addition & 0 deletions R/mcMSTEmoaZhou.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#' Defaults to \code{\link{mutUniformPruefer}}, i.e., each digit of the Pruefer encoding
#' is replaced with some probability with a random number from \eqn{V = \{1, \ldots, n\}}.
#' @inheritParams mcMSTEmoaBG
#' @template ret_ecrresult
#' @family mcMST EMOAs
#' @family mcMST algorithms
#' @seealso Mutator \code{\link{mutUniformPruefer}}
Expand Down
36 changes: 36 additions & 0 deletions R/transformations.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
#'
#' @template arg_pcode
#' @return [\code{matrix(2, length(pcode) + 1)}] Edge list.
#' @examples
#' # here we generate a random Pruefer-code representing
#' # a random spanning tree of a graph with n = 10 nodes
#' pcode = sample(1:10, 8, replace = TRUE)
#' print(pcode)
#' edgelist = prueferToEdgeList(pcode)
#' print(edgelist)
#' @family transformation functions
#' @export
prueferToEdgeList = function(pcode) {
Expand Down Expand Up @@ -63,6 +70,15 @@ prueferToEdgeList = function(pcode) {
#' @template arg_edgelist
#' @template arg_n
#' @template ret_charvec
#' @examples
#' # first we generate a small edge list by hand
#' # (assume the given graph has n = 4 nodes)
#' edgelist = matrix(c(1, 2, 2, 4, 3, 4), ncol = 3)
#' print(edgelist)
#' # next we transform the edge into
#' # a characteristic vector
#' cvec = edgeListToCharVec(edgelist, n = 4)
#' print(cvec)
#' @family transformation functions
#' @export
edgeListToCharVec = function(edgelist, n = NULL) {
Expand All @@ -85,6 +101,12 @@ edgeListToCharVec = function(edgelist, n = NULL) {
#'
#' @template arg_pcode
#' @template ret_charvec
#' @examples
#' # here we generate a random Pruefer-code representing
#' # a random spanning tree of a graph with n = 10 nodes
#' pcode = sample(1:10, 8, replace = TRUE)
#' print(pcode)
#' print(prueferToCharVec(pcode))
#' @family transformation functions
#' @export
prueferToCharVec = function(pcode) {
Expand All @@ -95,6 +117,13 @@ prueferToCharVec = function(pcode) {
#'
#' @template arg_perm
#' @return [\code{matrix(2, length(perm))}] Edge list.
#' @examples
#' # first generate a random permutation, e.g., representing
#' # a roundtrip tour in a graph
#' perm = sample(1:10)
#' print(perm)
#' # now convert into an edge list
#' permutationToEdgelist(perm)
#' @family transformation functions
#' @export
permutationToEdgelist = function(perm) {
Expand All @@ -113,6 +142,13 @@ permutationToEdgelist = function(perm) {
#' @template arg_perm
#' @template arg_n
#' @template ret_charvec
#' @examples
#' # first generate a random permutation, e.g., representing
#' # a roundtrip tour in a graph
#' perm = sample(1:10)
#' print(perm)
#' # now convert into an edge list
#' permutationToCharVec(perm, n = 10)
#' @family transformation functions
#' @export
permutationToCharVec = function(perm, n) {
Expand Down
2 changes: 1 addition & 1 deletion man-roxygen/ret_charvec.R
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#' @return [integer] Characteristic vector cv with cv[i] = 1 if the i-th edge is in the tree.
#' @return [\code{integer}] Characteristic vector cv with cv[i] = 1 if the i-th edge is in the tree.
13 changes: 13 additions & 0 deletions man-roxygen/ret_ecrresult.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#' @return [\code{\link[ecr]{ecr_result}}] List of type \code{\link[ecr]{ecr_result}}
#' with the following components:
#' \describe{
#' \item{task}{The \code{ecr_optimization_task}.}
#' \item{log}{Logger object.}
#' \item{pareto.idx}{Indizes of the non-dominated solutions in the last population.}
#' \item{pareto.front}{(n x d) matrix of the approximated non-dominated front where n
#' is the number of non-dominated points and d is the number of objectives.}
#' \item{pareto.set}{Matrix of decision space values resulting with objective values
#' given in pareto.front.}
#' \item{last.population}{Last population.}
#' \item{message}{Character string describing the reason of termination.}
#' }
12 changes: 11 additions & 1 deletion man/edgeListToCharVec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion man/mcMSTEmoaBG.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions man/mcMSTEmoaZhou.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/permutationToCharVec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/permutationToEdgelist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion man/prueferToCharVec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/prueferToEdgelist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b431c15

Please sign in to comment.