Skip to content

Commit

Permalink
18.8
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasLP committed Feb 1, 2018
1 parent 809c081 commit 8ea17ed
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 15 deletions.
2 changes: 1 addition & 1 deletion experiment/MyExperiments/comparison/Plots/BoxPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ JMetalBoxplot <- function(algorithms, indicator, problem){
boxplot(data,names=algorithms,
notch = TRUE,
use.cols=TRUE,#use boxplot with matrix
cex.axis=0.5)#,xaxt='n',xlab="")
cex.axis=0.65)#,xaxt='n',xlab="")
#axis(1, at=seq(1, length(algorithms), by=1), labels = FALSE)
#text(seq(1, length(algorithms), by=1), par("usr")[4] - 0.27, labels = algorithms, srt = 45, pos = 1, xpd = TRUE,cex=0.7)

Expand Down
71 changes: 71 additions & 0 deletions experiment/MyExperiments/comparison/Plots/LinePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,74 @@ linePlotEvolution <- function(instance, indicator, algorithmsNames){
# Create a legend
legend("bottomright", algorithmsNames, cex=0.6, col=plot_colors, pch=21:23, lty=1:3);
}


#pt-br version
linePlotEvolutionPT <- function(instance, indicator, algorithmsNames){
# Read data file
algorithms <- c()
xmax <- 100 #default #number of steps in evolution process data
# Define colors to be used
plot_colors <- c("blue","black","orange","green", "brown", "deepskyblue", "gray60","yellow")

zoommin <- 1#40 #plot only from this
zoommax <- 100#99 #at this value
for(i in 1:length(algorithmsNames) ){
algorithm <- read.table(paste("../history/",algorithmsNames[i],"/data_",indicator,"_",instance,".dat",sep=""), header=T, sep="\t")
algorithm <- algorithm[,(-1:-zoommin)]# "zoom"at the line
algorithm <- algorithm[,(-(zoommax-zoommin):-100)]#
xmax <- length(algorithm)
algorithms[[i]] <- algorithm
}
# Compute the max and min y
max_y <- max(unlist(lapply(algorithms,FUN=max)))
min_y <- min(unlist(lapply(algorithms,FUN=min)))


algorithm1mean <- c()
algorithm1Q <- c()
algorithm <- algorithms[[1]]
for(n in 1:xmax){ #calcules mean, 1o quartil and 3 quartil
algorithm1mean<-append(algorithm1mean,mean(algorithm[,n]))
algorithm1Q <-rbind(algorithm1Q,quantile(algorithm[,n], c(0.25,0.75),type=1))#rbind is to merge, or, add new line in data frame
}

#FIRST ALGORITHM
plot(algorithm1mean, type="o", pch='.', lty=1, col=plot_colors[1],
xaxt='n',#this axis will be described later
ylim=c(min_y,max_y), # Make y axis
ann=FALSE)

l = seq(0,zoommax,10)# points where is to plot
lab = l+zoommin # labels
axis(1,at=l,labels=lab)

lines(algorithm1Q[,1], type="o", pch='.', lty=2, col=plot_colors[1])
lines(algorithm1Q[,2], type="o", pch='.', lty=2, col=plot_colors[1])

#OTHER ALGORITHMS
for(i in 2:length(algorithmsNames)){
algorithmMean <- c()
algorithmQ <- c()
algorithm <- algorithms[[i]]
for(n in 1:xmax){ #calcules mean, 1o quartil and 3 quartil
algorithmMean<-append(algorithmMean,mean(algorithm[,n]))
algorithmQ <-rbind(algorithmQ,quantile(algorithm[,n], c(0.25,0.75),type=1))#rbind is to merge, or, add new line in data frame
}
lines(algorithmMean, type="o", pch='.', lty=1, col=plot_colors[i])
lines(algorithmQ[,1], type="o", pch='.', lty=2, col=plot_colors[i])
lines(algorithmQ[,2], type="o", pch='.', lty=2, col=plot_colors[i])
}

grid(col="black")
# Create box around plot
box()
# Create a title bold/italic font
title(main=paste("Evolução do ",indicator," : ",instance,sep=""), font.main=4)
# Label the x and y axes
title(xlab= "% das avaliações")
title(ylab= paste("Valor do indicador de qualidade ",indicator,sep=""))
# Create a legend
legend("bottomright", algorithmsNames, cex=0.6, col=plot_colors, pch=21:23, lty=1:3);
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# see the algorithm in java /ExecuteJMetal/src/org.uma.jmetal.util.experiment.component/GenerateEvolutionChart.java
#
#############################################################

source("../main.R") #load these functions
#the file must be executed in same directory of main.R
source("main.R") #load these functions

par(mfrow=c(2,4)) #set number of plot/page
#pdf("Rplot.pdf", width=15,height=11)#paper="A4")
Expand Down
35 changes: 35 additions & 0 deletions experiment/MyExperiments/comparison/examples/PlotInPNGFile.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#############################################################
# ExecuteJMetal ::R functions::
#
# Author: Lucas Prestes [email protected]
#
#############################################################
# SCRIPT START HERE
#
# These are examples of how to call the methods
#
# ATTENTION! The function "linePlotEvolution" only can by plotter with the data files,
# see the algorithm in java /ExecuteJMetal/src/org.uma.jmetal.util.experiment.component/GenerateEvolutionChart.java
#
#############################################################
#the file must be executed in same directory of main.R
source("main.R") #load these functions

par(mfrow=c(1, 3)) #set number of plot/page #c(lines, columns)

algorithms <- c("MOEADDRA","NSGAII","IBEA")

instances3obj <- c("DTLZ1","DTLZ2","DTLZ3","DTLZ4","DTLZ7")


for(instance in instances3obj){
png(paste("./PlotInPNGFile/PlotInPNGFile_",instance,".png",sep=""), height=800, width=1650, pointsize=11, res=230)

par(mfrow=c(1, 3))

linePlotEvolution(instance,"HV",algorithms)

JMetalBoxplot(algorithms, "HV", instance)

objectivePoints3D(instance, algorithms)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Author: Lucas Prestes [email protected]
#
#############################################################

#the file must be executed in same directory of main.R

source("main.R")

Expand Down
4 changes: 3 additions & 1 deletion experiment/MyExperiments/comparison/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
#
# https://github.com/LucasLP/ExecuteJMetal
#
# #### Functions avaible in this file: ####
#### Functions avaible ####
#
# loadData(algorithm, instance) #Return the data file from instance ant indicator
# setBenchmark(benchmark)
# bestHV(algorithm, instance)
# bestIGD(algorithm, instance)
# bestEP(algorithm, instance)
# bestIndicators(algorithm, instance)
# setBenchmark(benchmark) #example, send "UF" and it will return a array with all of instances in this benchmark
#
source("./Statistics/Counter.R")
# countWinners(algorithms, instances)
# countAll(algorithm, instance)
Expand Down
31 changes: 21 additions & 10 deletions experiment/MyExperiments/comparison/scriptExample.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,42 @@

source("main.R") #load these functions

par(mfrow=c(2,4)) #set number of plot/page
par(mfrow=c(1, 3)) #set number of plot/page #c(lines, columns)
#pdf("Rplot.pdf", width=15,height=11)#paper="A4")

algorithms <- c("MOEADDRA","NSGAII","IBEA")#,"UCBHybrid")
#png("name.png", height=1800, width=1650, pointsize=11, res=230)

algorithms <- c("MOEADDRA","NSGAII","IBEA","UCBHybrid")
algorithms2 <- c("MOEADDRA","NSGAII","UCBHybrid")
instances2obj <- c("WFG1","WFG2","WFG4","WFG7","ZDT1","ZDT2","ZDT3","ZDT6")#setBenchmark("DTLZ")
instances3obj <- c("DTLZ1","DTLZ2","DTLZ3","DTLZ4","DTLZ7")#setBenchmark("DTLZ")

latexMain(algorithms, "UF")
#latexMain(algorithms, "UF")


if(FALSE){

for(instance in instances2obj){
linePlotEvolution(instance,"HV",algorithms)
linePlotEvolution(instance,"Spread",algorithms)
objectivePoints(instance, algorithms)
png(paste(instance,".png",sep=""), height=800, width=1650, pointsize=11, res=230)
par(mfrow=c(1, 3))

linePlotEvolutionPT(instance,"HV",algorithms)
#linePlotEvolution(instance,"Spread",algorithms)
#objectivePoints(instance, algorithms)
JMetalBoxplot(algorithms, "HV", instance)
JMetalBoxplot(algorithms2, "HV", instance)
}



for(instance in instances3obj){
linePlotEvolution(instance,"HV",algorithms)
linePlotEvolution(instance,"Spread",algorithms)
objectivePoints3D(instance, algorithms)
png(paste(instance,".png",sep=""), height=800, width=1650, pointsize=11, res=230)
par(mfrow=c(1, 3))

linePlotEvolutionPT(instance,"HV",algorithms)
#linePlotEvolution(instance,"Spread",algorithms)
#objectivePoints3D(instance, algorithms)
JMetalBoxplot(algorithms, "HV", instance)
JMetalBoxplot(algorithms2, "HV", instance)
}


Expand Down

0 comments on commit 8ea17ed

Please sign in to comment.