Skip to content

Commit

Permalink
add function to compute dominated hypervolume (not finished)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed May 13, 2015
1 parent 7318a75 commit ee9a8b1
Show file tree
Hide file tree
Showing 16 changed files with 1,473 additions and 1 deletion.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Imports:
Suggests:
testthat (>= 0.9.1)
ByteCompile: yes
LazyData: yes
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ S3method(print,ecr_control)
S3method(print,ecr_result)
export(computeAverageHausdorffDistance)
export(computeCrowdingDistance)
export(computeDominatedHypervolume)
export(computeGenerationalDistance)
export(computeInvertedGenerationalDistance)
export(doNondominatedSorting)
Expand Down Expand Up @@ -63,3 +64,4 @@ import(gridExtra)
import(parallelMap)
import(reshape2)
import(smoof)
useDynLib(ecr)
37 changes: 37 additions & 0 deletions R/computeDominatedHypervolume.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#' Computation of the dominated hypervolume.
#'
#' Given a set of points \code{x}, this function computes the dominated hypervolume
#' of the points regarding the reference point \code{ref.point}. If the latter
#' is not provided, one is automatically determined by computing the maximum
#' in each dimension.
#'
#' @param x [\code{matrix}]\cr
#' Matrix of points.
#' @param ref.point [\code{numeric} | \code{NULL}]\cr
#' Reference point. Set to the maximum in each dimension by default if not provided.
#' @return [\code{numeric(1)}] Dominated hypervolume.
#' @export
computeDominatedHypervolume = function(x, ref.point = NULL) {
# sanity checks
assertMatrix(x, mode = "numeric", any.missing = FALSE)
if (any(is.infinite(x))) {
warningf("Set of points contains infinite %i values.", which(is.infinite(x)))
return(NaN)
}

if (is.null(ref.point)) {
ref.point = apply(x, 1, max)
}

if (length(ref.point) != nrow(x)) {
stopf("Set of points and reference point need to have the same dimension, but
set of points has dimension %i and reference points has dimension %i.", nrow(x), length(ref.point))
}

if (any(is.infinite(ref.point))) {
warningf("Reference point contains infinite %i values.", which(is.infinite(ref.point)))
return(NaN)
}

return(.Call("computeDominatedHypervolumeC", as.numeric(x), ref.point))
}
3 changes: 2 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
#' @import parallelMap
#' @import reshape2
#' @import gridExtra
NULL
#' @useDynLib ecr
NULL
25 changes: 25 additions & 0 deletions man/computeDominatedHypervolume.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/computeDominatedHypervolume.R
\name{computeDominatedHypervolume}
\alias{computeDominatedHypervolume}
\title{Computation of the dominated hypervolume.}
\usage{
computeDominatedHypervolume(x, ref.point = NULL)
}
\arguments{
\item{x}{[\code{matrix}]\cr
Matrix of points.}

\item{ref.point}{[\code{numeric} | \code{NULL}]\cr
Reference point. Set to the maximum in each dimension by default if not provided.}
}
\value{
[\code{numeric(1)}] Dominated hypervolume.
}
\description{
Given a set of points \code{x}, this function computes the dominated hypervolume
of the points regarding the reference point \code{ref.point}. If the latter
is not provided, one is automatically determined by computing the maximum
in each dimension.
}

7 changes: 7 additions & 0 deletions src/Makevars
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all: $(SHLIB)

hv.o: hv.c
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -DVARIANT=4 -c -o hv.o hv.c

avl.o: avl.c
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -DVARIANT=4 -c -o avl.o avl.c

0 comments on commit ee9a8b1

Please sign in to comment.