Skip to content

Commit

Permalink
add some R code for R indicator family (not finished)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Jun 16, 2015
1 parent 27a1826 commit 12aad49
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions R/emoa.indicators.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,56 @@ computeHypervolumeIndicator = function(points, ref.points, ref.point = NULL) {

return (hv.ref.points - hv.points)
}

# @rdname emoa_indicators
computeRIndicator = function(points, ref.points, ideal.point = NULL, nadir.point = NULL, lambdas = NULL, utility, aggregator) {
assertMatrix(points, mode = "numeric", any.missing = FALSE)
assertMatrix(ref.points, mode = "numeric", any.missing = FALSE)
if (is.null(ideal.point)) {
ideal.point = approximateIdealPoint(points, ref.points)
}
assertNumeric(ideal.point, any.missing = FALSE)
assertMatrix(lambdas, mode = "numeric", any.missing = FALSE)
utilities = c("weightedsum", "tschbycheff", "augmented tschbycheff")
assertChoice(utility, utilities)
assertFunction(aggregator)

# convert utility to integer index which is used by the C code
utility = which((match.arg(utility, utilities)) == utilities)
utility = as.integer(utility)

n.obj = nrow(points)

if (is.null(ideal.point)) {
ideal.point = approximateIdealPoint(points, ref.points)
}
if (is.null(nadir.point)) {
nadir.point = approximateNadirPoint(points, ref.points)
}

if (is.null(lambda)) {
lambda = determineLambdaByDimension(n.obj)
}
lambda = convertInteger(lambda)

ind.points = .Call(computeRIndicator, points, ideal.point, nadir.point, lambda, utility)
ind.ref.points = .Call(computeRIndicator, ref.points, ideal.point, nadir.point, lambda, utility)

ind = aggregator(ind.points, ind.ref.points)

return (ind)
}

determineLambdaByDimension = function(n.obj) {
if (n.obj == 2) {
500L
} else if (n.obj == 3) {
30L
} else if (n.obj == 4) {
12L
} else if (n.obj == 5) {
8L
} else {
3L
}
}

0 comments on commit 12aad49

Please sign in to comment.