-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathplot_pairs.oms
More file actions
82 lines (67 loc) · 3.14 KB
/
plot_pairs.oms
File metadata and controls
82 lines (67 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// this variable will transmit the path where the CSV files to graph will be found
val directoryWithResults = Val[File]
// variables used to parameter the graphing function
val filesHaveHeaders = Val[Int]
val countInputs = Val[Int]
// this variable will contain the file with the graphical rendering of the last PAreto front
val pngForPairs = Val[File]
val taskPlotEvereyIteration = RTask("""
library(ggplot2)
library(GGally)
colnames <- if (countInputs == 2) c("iteration", "x", "y", "f1", "f2") else c("iteration", "x", "f1", "f2")
coltypes <- if (countInputs == 2) c("integer", "numeric", "numeric", "numeric", "numeric") else c("integer", "numeric", "numeric", "numeric")
names(coltypes) <- colnames
directoryWithResultsName <- "mydirectory"
pop <- NULL
i <- 1
while (TRUE) {
# TODO check creation time of the file
filename <- paste(directoryWithResultsName,"/population",i,".csv", sep="");
if (!file.exists(filename)) {
break
}
#print(filename)
popraw <- read.csv(header = FALSE, col.names=colnames, colClasses=coltypes, file=filename)
#print(head(popraw))
pop <- if (is.null(pop)) popraw else rbind(pop, popraw)
i <- i + 1
}
# the ggplot
n <- ncol(pop)
ggsave(filename="/tmp/pairs.png", ggpairs(pop), width=n*6, height=n*6, dpi = 150, units="cm", limitsize=F)
""",
install = Seq(
// update the list of available packages
"fakeroot apt-get update ",
// required; attempts to update dbus to a newer version would require permissions we do not have
"DEBIAN_FRONTEND=noninteractive fakeroot apt-mark hold dbus",
"""echo "dbus hold" | fakeroot dpkg --set-selections""",
// install the libs required for the compilation of R packages
"DEBIAN_FRONTEND=noninteractive fakeroot apt-get install -y libssl-dev libcurl4-openssl-dev libudunits2-dev",
// install required R packages in their binary version (quicker, much stable!)
"DEBIAN_FRONTEND=noninteractive fakeroot apt-get install -y r-cran-ggplot2 r-cran-gganimate r-cran-ggally r-cran-plotly r-cran-zip",
// install external tools in the VM for rendering
"DEBIAN_FRONTEND=noninteractive fakeroot apt-get install -y ffmpeg",
), //
libraries = Seq() // were installed with the binary version earlier
) set (
inputFiles += (directoryWithResults, "mydirectory"),
outputFiles += ("/tmp/pairs.png", pngForPairs),
inputs += filesHaveHeaders.mapped,
inputs += countInputs.mapped,
filesHaveHeaders := 1,
countInputs := 2
)
// import from the other file an example of optimization
import _file_.example_of_optimization._
// run the optimization
( evolutionSchafferN2 on envMultiThread hook (workDirectory/relativePath, keepAll=false)
) -- (
// then run the plotting function
taskPlotEvereyIteration set (
// ... which will read all the results from this file
directoryWithResults := workDirectory / relativePath,
// ... analyze them knowing there is only one input in the files
countInputs := 1
) hook CopyFileHook(pngForPairs, workDirectory/"pairs.png" )
)