Skip to content

Commit 8ea17ed

Browse files
committed
18.8
1 parent 809c081 commit 8ea17ed

12 files changed

+134
-15
lines changed

experiment/MyExperiments/comparison/Plots/BoxPlot.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ JMetalBoxplot <- function(algorithms, indicator, problem){
2323
boxplot(data,names=algorithms,
2424
notch = TRUE,
2525
use.cols=TRUE,#use boxplot with matrix
26-
cex.axis=0.5)#,xaxt='n',xlab="")
26+
cex.axis=0.65)#,xaxt='n',xlab="")
2727
#axis(1, at=seq(1, length(algorithms), by=1), labels = FALSE)
2828
#text(seq(1, length(algorithms), by=1), par("usr")[4] - 0.27, labels = algorithms, srt = 45, pos = 1, xpd = TRUE,cex=0.7)
2929

experiment/MyExperiments/comparison/Plots/LinePlot.R

+71
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,74 @@ linePlotEvolution <- function(instance, indicator, algorithmsNames){
8181
# Create a legend
8282
legend("bottomright", algorithmsNames, cex=0.6, col=plot_colors, pch=21:23, lty=1:3);
8383
}
84+
85+
86+
#pt-br version
87+
linePlotEvolutionPT <- function(instance, indicator, algorithmsNames){
88+
# Read data file
89+
algorithms <- c()
90+
xmax <- 100 #default #number of steps in evolution process data
91+
# Define colors to be used
92+
plot_colors <- c("blue","black","orange","green", "brown", "deepskyblue", "gray60","yellow")
93+
94+
zoommin <- 1#40 #plot only from this
95+
zoommax <- 100#99 #at this value
96+
for(i in 1:length(algorithmsNames) ){
97+
algorithm <- read.table(paste("../history/",algorithmsNames[i],"/data_",indicator,"_",instance,".dat",sep=""), header=T, sep="\t")
98+
algorithm <- algorithm[,(-1:-zoommin)]# "zoom"at the line
99+
algorithm <- algorithm[,(-(zoommax-zoommin):-100)]#
100+
xmax <- length(algorithm)
101+
algorithms[[i]] <- algorithm
102+
}
103+
# Compute the max and min y
104+
max_y <- max(unlist(lapply(algorithms,FUN=max)))
105+
min_y <- min(unlist(lapply(algorithms,FUN=min)))
106+
107+
108+
algorithm1mean <- c()
109+
algorithm1Q <- c()
110+
algorithm <- algorithms[[1]]
111+
for(n in 1:xmax){ #calcules mean, 1o quartil and 3 quartil
112+
algorithm1mean<-append(algorithm1mean,mean(algorithm[,n]))
113+
algorithm1Q <-rbind(algorithm1Q,quantile(algorithm[,n], c(0.25,0.75),type=1))#rbind is to merge, or, add new line in data frame
114+
}
115+
116+
#FIRST ALGORITHM
117+
plot(algorithm1mean, type="o", pch='.', lty=1, col=plot_colors[1],
118+
xaxt='n',#this axis will be described later
119+
ylim=c(min_y,max_y), # Make y axis
120+
ann=FALSE)
121+
122+
l = seq(0,zoommax,10)# points where is to plot
123+
lab = l+zoommin # labels
124+
axis(1,at=l,labels=lab)
125+
126+
lines(algorithm1Q[,1], type="o", pch='.', lty=2, col=plot_colors[1])
127+
lines(algorithm1Q[,2], type="o", pch='.', lty=2, col=plot_colors[1])
128+
129+
#OTHER ALGORITHMS
130+
for(i in 2:length(algorithmsNames)){
131+
algorithmMean <- c()
132+
algorithmQ <- c()
133+
algorithm <- algorithms[[i]]
134+
for(n in 1:xmax){ #calcules mean, 1o quartil and 3 quartil
135+
algorithmMean<-append(algorithmMean,mean(algorithm[,n]))
136+
algorithmQ <-rbind(algorithmQ,quantile(algorithm[,n], c(0.25,0.75),type=1))#rbind is to merge, or, add new line in data frame
137+
}
138+
lines(algorithmMean, type="o", pch='.', lty=1, col=plot_colors[i])
139+
lines(algorithmQ[,1], type="o", pch='.', lty=2, col=plot_colors[i])
140+
lines(algorithmQ[,2], type="o", pch='.', lty=2, col=plot_colors[i])
141+
}
142+
143+
grid(col="black")
144+
# Create box around plot
145+
box()
146+
# Create a title bold/italic font
147+
title(main=paste("Evolução do ",indicator," : ",instance,sep=""), font.main=4)
148+
# Label the x and y axes
149+
title(xlab= "% das avaliações")
150+
title(ylab= paste("Valor do indicador de qualidade ",indicator,sep=""))
151+
# Create a legend
152+
legend("bottomright", algorithmsNames, cex=0.6, col=plot_colors, pch=21:23, lty=1:3);
153+
}
154+

experiment/MyExperiments/comparison/examples/PlotEvolutionScatterAndBox.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# see the algorithm in java /ExecuteJMetal/src/org.uma.jmetal.util.experiment.component/GenerateEvolutionChart.java
1313
#
1414
#############################################################
15-
16-
source("../main.R") #load these functions
15+
#the file must be executed in same directory of main.R
16+
source("main.R") #load these functions
1717

1818
par(mfrow=c(2,4)) #set number of plot/page
1919
#pdf("Rplot.pdf", width=15,height=11)#paper="A4")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#############################################################
2+
# ExecuteJMetal ::R functions::
3+
#
4+
# Author: Lucas Prestes lucas.prestes.lp@gmail.com
5+
#
6+
#############################################################
7+
# SCRIPT START HERE
8+
#
9+
# These are examples of how to call the methods
10+
#
11+
# ATTENTION! The function "linePlotEvolution" only can by plotter with the data files,
12+
# see the algorithm in java /ExecuteJMetal/src/org.uma.jmetal.util.experiment.component/GenerateEvolutionChart.java
13+
#
14+
#############################################################
15+
#the file must be executed in same directory of main.R
16+
source("main.R") #load these functions
17+
18+
par(mfrow=c(1, 3)) #set number of plot/page #c(lines, columns)
19+
20+
algorithms <- c("MOEADDRA","NSGAII","IBEA")
21+
22+
instances3obj <- c("DTLZ1","DTLZ2","DTLZ3","DTLZ4","DTLZ7")
23+
24+
25+
for(instance in instances3obj){
26+
png(paste("./PlotInPNGFile/PlotInPNGFile_",instance,".png",sep=""), height=800, width=1650, pointsize=11, res=230)
27+
28+
par(mfrow=c(1, 3))
29+
30+
linePlotEvolution(instance,"HV",algorithms)
31+
32+
JMetalBoxplot(algorithms, "HV", instance)
33+
34+
objectivePoints3D(instance, algorithms)
35+
}
Loading
Loading
Loading
Loading
Loading

experiment/MyExperiments/comparison/examples/StatisticalComparison.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Author: Lucas Prestes lucas.prestes.lp@gmail.com
55
#
66
#############################################################
7-
7+
#the file must be executed in same directory of main.R
88

99
source("main.R")
1010

experiment/MyExperiments/comparison/main.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
#
66
# https://github.com/LucasLP/ExecuteJMetal
77
#
8-
# #### Functions avaible in this file: ####
8+
#### Functions avaible ####
99
#
1010
# loadData(algorithm, instance) #Return the data file from instance ant indicator
1111
# setBenchmark(benchmark)
1212
# bestHV(algorithm, instance)
1313
# bestIGD(algorithm, instance)
1414
# bestEP(algorithm, instance)
1515
# bestIndicators(algorithm, instance)
16+
# setBenchmark(benchmark) #example, send "UF" and it will return a array with all of instances in this benchmark
17+
#
1618
source("./Statistics/Counter.R")
1719
# countWinners(algorithms, instances)
1820
# countAll(algorithm, instance)

experiment/MyExperiments/comparison/scriptExample.R

+21-10
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,42 @@
99

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

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

15-
algorithms <- c("MOEADDRA","NSGAII","IBEA")#,"UCBHybrid")
15+
#png("name.png", height=1800, width=1650, pointsize=11, res=230)
16+
17+
algorithms <- c("MOEADDRA","NSGAII","IBEA","UCBHybrid")
18+
algorithms2 <- c("MOEADDRA","NSGAII","UCBHybrid")
1619
instances2obj <- c("WFG1","WFG2","WFG4","WFG7","ZDT1","ZDT2","ZDT3","ZDT6")#setBenchmark("DTLZ")
1720
instances3obj <- c("DTLZ1","DTLZ2","DTLZ3","DTLZ4","DTLZ7")#setBenchmark("DTLZ")
1821

19-
latexMain(algorithms, "UF")
22+
#latexMain(algorithms, "UF")
23+
2024

21-
if(FALSE){
2225

2326
for(instance in instances2obj){
24-
linePlotEvolution(instance,"HV",algorithms)
25-
linePlotEvolution(instance,"Spread",algorithms)
26-
objectivePoints(instance, algorithms)
27+
png(paste(instance,".png",sep=""), height=800, width=1650, pointsize=11, res=230)
28+
par(mfrow=c(1, 3))
29+
30+
linePlotEvolutionPT(instance,"HV",algorithms)
31+
#linePlotEvolution(instance,"Spread",algorithms)
32+
#objectivePoints(instance, algorithms)
2733
JMetalBoxplot(algorithms, "HV", instance)
34+
JMetalBoxplot(algorithms2, "HV", instance)
2835
}
2936

3037

3138

3239
for(instance in instances3obj){
33-
linePlotEvolution(instance,"HV",algorithms)
34-
linePlotEvolution(instance,"Spread",algorithms)
35-
objectivePoints3D(instance, algorithms)
40+
png(paste(instance,".png",sep=""), height=800, width=1650, pointsize=11, res=230)
41+
par(mfrow=c(1, 3))
42+
43+
linePlotEvolutionPT(instance,"HV",algorithms)
44+
#linePlotEvolution(instance,"Spread",algorithms)
45+
#objectivePoints3D(instance, algorithms)
3646
JMetalBoxplot(algorithms, "HV", instance)
47+
JMetalBoxplot(algorithms2, "HV", instance)
3748
}
3849

3950

0 commit comments

Comments
 (0)