+
+#----------------------------------------------------------------------
+ findbestcoord <- function(classeuce1, classeuce2) {
+ #fillemere1 <- NULL
+ #fillemere2 <- NULL
+
+ #fillemere1 <- unique(classeuce1)
+ #if (classif_mode == 0) {
+ # fillemere2 <- unique(classeuce2)
+ #} else {
+ # fillemere2 <- fillemere1
+ #}
+
+ #
+ listcoordok <- list()
+ maxcl <- 0
+ nb <- 0
+ lf1 <- addallfille(chd1$list_fille)
+ if (classif_mode == 0) {
+ lf2 <- addallfille(chd2$list_fille)
+ } else {
+ lf2 <- lf1
+ }
+ lme1 <- chd1$list_mere
+ if (classif_mode == 0) {
+ lme2 <- chd2$list_mere
+ } else {
+ lme2 <- lme1
+ }
+ for (first in 1:length(listx)) {
+ coordok <- NULL
+ f1 <- NULL
+ f2 <- NULL
+ listxp<-listx
+ listyp<-listy
+
+ #listxp<-listx[first:length(listx)]
+ #listxp<-c(listxp,listx[1:(first-1)])
+ #listyp<-listy[first:length(listy)]
+ #listyp<-c(listyp,listy[1:(first-1)])
+ listxp <- listxp[order(listx, decreasing = TRUE)]
+ listyp <- listyp[order(listx, decreasing = TRUE)]
+ #listxp<-c(listxp[first:length(listx)], listx[1:(first-1)])
+ #listyp<-c(listyp[first:length(listy)], listy[1:(first-1)])
+ for (i in 1:length(listx)) {
+ if( (!(listxp[i]+1) %in% f1) & (!(listyp[i]+1) %in% f2) ) {
+ #print(listyp[i]+1)
+ #print('not in')
+ #print(f2)
+ coordok <- rbind(coordok, c(listyp[i] + 1,listxp[i] + 1))
+ #print(c(listyp[i] + 1,listxp[i] + 1))
+ un1 <- getfillemere(lf2, chd2$list_mere, listxp[i] + 1)
+ f1 <- c(f1, un1)
+ f1 <- c(f1, listxp[i] + 1)
+ un2 <- getfillemere(lf1, chd1$list_mere, listyp[i] + 1)
+ f2 <- c(f2, un2)
+ f2 <- c(f2, listyp[i] + 1)
+ }
+ #print(coordok)
+ }
+ #if (nrow(coordok) > maxcl) {
+ nb <- 1
+ # listcoordok <- list()
+ listcoordok[[nb]] <- coordok
+ # maxcl <- nrow(coordok)
+ #} else if (nrow(coordok) == maxcl) {
+ nb <- nb + 1
+ # listcoordok[[nb]] <- coordok
+ #}
+ }
+ listcoordok <- unique(listcoordok)
+ print(listcoordok)
+ best <- 1
+ if (length(listcoordok) > 1) {
+ maxchi <- 0
+ for (i in 1:length(listcoordok)) {
+ chi <- NULL
+ uce <- NULL
+ for (j in 1:nrow(listcoordok[[i]])) {
+ chi<-c(chi,croise[(listcoordok[[i]][j,1]-1),(listcoordok[[i]][j,2]-1)])
+ uce<-c(uce,chicroiseori[(listcoordok[[i]][j,1]-1),(listcoordok[[i]][j,2]-1)])
+ }
+ if (maxchi < sum(chi)) {
+ maxchi <- sum(chi)
+ suce <- sum(uce)
+ best <- i
+ }
+ }
+ print(suce/nrow(classeuce1))
+ }
+ listcoordok[[best]]
+ }
+#---------------------------------------------------------------------------------