1

I need to build an algorithm which will:

For 116 existing observations of 2 variables x1 and x2 (plotted individually: one single point)

  1. Create new observations by merging extreme points of 2 existing observations (ex: observation 117 will have 2 extreme points, (x1_115, x2_115) and (x1_30, x2_30)). Do this for all combinations. If, for one combination, one pair dominates the other: x1_a < x1_b AND x2_a < x2_b, only select a.
  2. For the new set of 116+n newly created variables, remove the dominated pairs, in the same logic as above.
  3. Continue until we cannot create new non-dominated pairs.

I'm trying to solve this problem by creating independent functions for each operation. So far I have created the ConvexUnion function which merges extreme points (simply the union of 2 observations), but it does not take into account dominance yet.

ConvexUnion <- function(a,b){
   output = NULL
   for (i in 1:ncol(a)) { 
      u = unique(rbind(a[,i],b[,i]), incomparables = FALSE)
      output = cbind(output, u)
   }
   output #the extreme points of the newly created pair
}

a = matrix(c(50,70), ncol = 2)
b = matrix(c(60,85), ncol = 2)

v = ConvexUnion(a,b)
   TRAFO LABOR  DELLV CLIENTS
1     49 15023 180119   11828
2     54  3118 212988   13465
3     31  6016  81597    4787
4     39  8909 127263   10291
5      9  1789  30095    2205
6     59  8327 190405   12045
7     95 11985 288146   16379
8     54 11309 208009   12252
9     13  3844  53631    4426
10   148 26348 459371   39831
11    17  3968  48798    3210
12   157 20131 366409   27050
13    18  4614  60366    4673
14    17  5941  49042    3950
15    77  6449 226815   12584

Here, the result for the new pair, which is the so-called convex union of a and b, would be (50,70) because a dominates b (both x1 and x2 are smaller).

How do I solve the problem?

Simon
  • 349
  • 2
  • 12
  • Could you maybe post some sample data? – Dunois Jul 28 '19 at 22:30
  • @Dunois, I added the data in the main post. First two variables are `x1 x2`, second two variables are `y1 y2`. – Simon Jul 29 '19 at 07:19
  • You write _the result for the new pair… would be (50,70)_, but if I run the code, I get for `v` the `structure(c(50, 60, 70, 85), .Dim = c(2L, 2L))`. – Armali Jul 29 '19 at 11:01
  • (50,70) is the expected result, but indeed not the output of the function I wrote. Do you know how to do it? – Simon Jul 29 '19 at 11:30

0 Answers0