Skip to content

Instantly share code, notes, and snippets.

@alexstorer
Last active December 30, 2015 00:39
Show Gist options
  • Save alexstorer/7751371 to your computer and use it in GitHub Desktop.
Save alexstorer/7751371 to your computer and use it in GitHub Desktop.
h<-c(1,2,10)
j<-c(1,2,9)
foo <- cbind(h,j)
h<-c(1,2,10,9)
j<-c(1,2,9,10)
foo2 <- cbind(h,j)
foo3 <-
cbind(c(-75.51644,-72.13451,-75.98991),c(8.019004,8.061604,7.913280))
h<-c(1,2,9,11)
j<-c(1,2,10,10)
foo4 <- cbind(h,j)
paretosingle <- function(m) {
d1max <- max(m[,1])
d2max <- max(m[,2])
weakcandidates <- m[,1]==d1max | m[,2]==d2max
strongcandidates <- m[,1]==d1max & m[,2]==d2max
s = which(strongcandidates)
w = which(weakcandidates)
if (length(s)>0) {
x = s
}
else {
x = w
}
if (length(x)==1) {return(x)}
else {
return(sample(x,size=1))
}
}
paretosingle(foo)
paretosingle(foo)
paretosingle(foo)
paretosingle(foo2)
paretosingle(foo2)
paretosingle(foo2)
paretosingle(foo3)
paretosingle(foo3)
paretosingle(foo3)
paretosingle(foo4)
paretosingle(foo4)
paretosingle(foo4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment