From aaa7ae9a092247daa902a455d26cc2dc59845622 Mon Sep 17 00:00:00 2001 From: Kaustubh Patil Date: Mon, 5 Apr 2021 22:41:56 +0200 Subject: [PATCH 1/6] plot front only if available --- R/miscfun.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/R/miscfun.R b/R/miscfun.R index 3b05b45..3779008 100644 --- a/R/miscfun.R +++ b/R/miscfun.R @@ -33,12 +33,14 @@ nsgaMonitor <- function(object, number_objectives, ...) { "Iter: ", iter), xlim = range(fitness[, 1]), ylim = range(fitness[, 2]), xlab = "f_1", ylab = "f_2") - lines(first_front[, 1][order(first_front[, 1])], - first_front[, 2][order(first_front[, 1])], - xlim = range(first_front[, 1]), - ylim = range(first_front[, 2]), - xlab = "f_1", ylab = "f_2", - col = "red", type = "l", pch = 12, main = "Pareto Front") + if(nrow(first_front) > 2) { + lines(first_front[, 1][order(first_front[, 1])], + first_front[, 2][order(first_front[, 1])], + xlim = range(first_front[, 1]), + ylim = range(first_front[, 2]), + xlab = "f_1", ylab = "f_2", + col = "red", type = "l", pch = 12, main = "Pareto Front") + } legend("topright", inset = c(-0.8, 0), legend = c("Population", "Pareto Optimal"), pch = c(19, NA), title = "Values", lwd = c(NA, 2), From cc92d4261452cb46660b4461dd91cc394f694ba4 Mon Sep 17 00:00:00 2001 From: Kaustubh Patil Date: Tue, 6 Apr 2021 09:44:11 +0200 Subject: [PATCH 2/6] front plot fix 2 --- R/miscfun.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/miscfun.R b/R/miscfun.R index 3779008..fea57d4 100644 --- a/R/miscfun.R +++ b/R/miscfun.R @@ -33,7 +33,7 @@ nsgaMonitor <- function(object, number_objectives, ...) { "Iter: ", iter), xlim = range(fitness[, 1]), ylim = range(fitness[, 2]), xlab = "f_1", ylab = "f_2") - if(nrow(first_front) > 2) { + if(length(first_front) > 0 && nrow(first_front) > 2) { lines(first_front[, 1][order(first_front[, 1])], first_front[, 2][order(first_front[, 1])], xlim = range(first_front[, 1]), From 1a2c9ef691560fe2cd53f12acaac923057698edd Mon Sep 17 00:00:00 2001 From: Kaustubh Patil Date: Tue, 6 Apr 2021 09:56:08 +0200 Subject: [PATCH 3/6] front plot fix show front for debug --- R/miscfun.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/miscfun.R b/R/miscfun.R index fea57d4..6cdfea4 100644 --- a/R/miscfun.R +++ b/R/miscfun.R @@ -25,6 +25,7 @@ nsgaMonitor <- function(object, number_objectives, ...) { } else if (number_objectives == 2) { first_front <- fitness[object@f[[1]], ] + show(first_front) opar <- par('mar','xpd') on.exit(par(opar)) par(mar = c(5.1, 4.1, 4.1, 8.1), xpd = TRUE) From 0675601da7aaf19f48d3662a0ed4a5c778f95a64 Mon Sep 17 00:00:00 2001 From: Kaustubh Patil Date: Tue, 6 Apr 2021 11:56:50 +0200 Subject: [PATCH 4/6] front plot fix try 3 --- R/miscfun.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/miscfun.R b/R/miscfun.R index 6cdfea4..aea4703 100644 --- a/R/miscfun.R +++ b/R/miscfun.R @@ -34,7 +34,7 @@ nsgaMonitor <- function(object, number_objectives, ...) { "Iter: ", iter), xlim = range(fitness[, 1]), ylim = range(fitness[, 2]), xlab = "f_1", ylab = "f_2") - if(length(first_front) > 0 && nrow(first_front) > 2) { + if(!is.null(nrow(first_front)) > 0 && nrow(first_front) > 1) { lines(first_front[, 1][order(first_front[, 1])], first_front[, 2][order(first_front[, 1])], xlim = range(first_front[, 1]), From c1c0e2e4c41ae517cdbfc13ee40b6ed8c4365605 Mon Sep 17 00:00:00 2001 From: Kaustubh Patil Date: Tue, 6 Apr 2021 12:05:06 +0200 Subject: [PATCH 5/6] front plot fix try 4 --- R/miscfun.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/miscfun.R b/R/miscfun.R index aea4703..1f10569 100644 --- a/R/miscfun.R +++ b/R/miscfun.R @@ -34,7 +34,7 @@ nsgaMonitor <- function(object, number_objectives, ...) { "Iter: ", iter), xlim = range(fitness[, 1]), ylim = range(fitness[, 2]), xlab = "f_1", ylab = "f_2") - if(!is.null(nrow(first_front)) > 0 && nrow(first_front) > 1) { + if(!is.null(nrow(first_front)) && nrow(first_front) > 1) { lines(first_front[, 1][order(first_front[, 1])], first_front[, 2][order(first_front[, 1])], xlim = range(first_front[, 1]), From c9abf16c754227b56512688a6c8709e335c1f107 Mon Sep 17 00:00:00 2001 From: Kaustubh Patil Date: Tue, 6 Apr 2021 12:44:06 +0200 Subject: [PATCH 6/6] front plot fix removing show first_Front --- R/miscfun.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/miscfun.R b/R/miscfun.R index 1f10569..d45ef28 100644 --- a/R/miscfun.R +++ b/R/miscfun.R @@ -25,7 +25,6 @@ nsgaMonitor <- function(object, number_objectives, ...) { } else if (number_objectives == 2) { first_front <- fitness[object@f[[1]], ] - show(first_front) opar <- par('mar','xpd') on.exit(par(opar)) par(mar = c(5.1, 4.1, 4.1, 8.1), xpd = TRUE)