44# ' attainment surfaces for certain percentiles or as points.
55# '
66# ' This function can be used to plot random sets of points like those obtained
7- # ' by different runs of biobjective stochastic optimisation algorithms. An EAF
7+ # ' by different runs of biobjective stochastic optimisation algorithms \citep{LopPaqStu09emaa} . An EAF
88# ' curve represents the boundary separating points that are known to be
99# ' attainable (that is, dominated in Pareto sense) in at least a fraction
10- # ' (quantile) of the runs from those that are not. The median EAF represents
10+ # ' (quantile) of the runs from those that are not \citep{Grunert01} . The median EAF represents
1111# ' the curve where the fraction of attainable points is 50%. In single
1212# ' objective optimisation the function can be used to plot the profile of
13- # ' solution quality over time of a collection of runs of a stochastic optimizer.
13+ # ' solution quality over time of a collection of runs of a stochastic optimizer. \citep{LopVerDreDoe2025}.
1414# '
1515# ' @param x Either a matrix of data values, or a data frame, or a list of
1616# ' data frames of exactly three columns.
@@ -20,18 +20,29 @@ eafplot <- function(x, ...) UseMethod("eafplot")
2020
2121# ' @describeIn eafplot Main function
2222# '
23- # ' @param groups This may be used to plot profiles of different algorithms on the same plot.
24- # ' @param sets (`numeric()`)\cr Vector indicating which set each point belongs to.
25- # ' @param percentiles (`numeric()`) Vector indicating which percentile should be plot. The
26- # ' default is to plot only the median attainment curve.
27- # ' @param attsurfs TODO
28- # ' @param type (`character(1)`)\cr string giving the type of plot desired. The following values
29- # ' are possible, \samp{points} and \samp{area}.
23+ # ' @param sets Vector indicating which set each point belongs to. Will be coerced to a factor.
24+ # '
25+ # ' @param groups This may be used to plot data for different algorithms on
26+ # ' the same plot. Will be coerced to a factor.
27+ # '
28+ # ' @param percentiles (`numeric()`)\cr Vector indicating which percentile
29+ # ' should be plot. The default is to plot only the median attainment curve.
30+ # '
31+ # ' @param attsurfs TODO
32+ # '
33+ # ' @param type (`"point"`|`"area"`)\cr Type of plot.
34+ # '
3035# ' @param xlab,ylab,xlim,ylim,log,col,lty,lwd,pch,cex.pch,las Graphical
3136# ' parameters, see [plot.default()].
32- # ' @param legend.pos the position of the legend, see [legend()]. A value of `"none"` hides the legend.
33- # ' @param legend.txt a character or expression vector to appear in the
34- # ' legend. If `NULL`, appropriate labels will be generated.
37+ # '
38+ # ' @param legend.pos (`character(1)`|`list()`|`data.frame()`)\cr Position of
39+ # ' the legend. This may be xy coordinates or a keyword ("bottomright",
40+ # ' "bottom", "bottomleft", "left", "topleft", "top", "topright", "right",
41+ # ' "center"). See Details in [legend()]. A value of "none" hides the legend.
42+ # '
43+ # ' @param legend.txt (`expression()`|`character()`)\cr Character or expression
44+ # ' vector to appear in the legend. If `NULL`, appropriate labels will be
45+ # ' generated.
3546# '
3647# ' @param extra.points A list of matrices or data.frames with
3748# ' two-columns. Each element of the list defines a set of points, or
@@ -43,18 +54,16 @@ eafplot <- function(x, ...) UseMethod("eafplot")
4354# ' @param extra.legend A character vector providing labels for the
4455# ' groups of points.
4556# '
46- # ' @param maximise `logical()`|`logical(1)`\cr Whether the objectives must be
57+ # ' @param maximise ( `logical()`|`logical(1)`) \cr Whether the objectives must be
4758# ' maximised instead of minimised. Either a single logical value that applies
4859# ' to all objectives or a vector of logical values, with one value per
4960# ' objective.
5061# '
51- # ' @param xaxis.side On which side the x-axis is drawn. Valid values are
52- # ' `"below"` and `"above"`. See [axis()].
62+ # ' @param xaxis.side (`"below"`|`"above"`)\cr On which side the x-axis is drawn. See [axis()].
5363# '
54- # ' @param yaxis.side On which side the y-axis is drawn. Valid values are
55- # ' `"left"` and `"right"`. See [axis()].
64+ # ' @param yaxis.side (`"left"`|`"right"`)\cr On which side the y-axis is drawn. See [axis()].
5665# '
57- # ' @param axes A logical value indicating whether both axes should be drawn
66+ # ' @param axes (`logical(1)`)\cr A logical value indicating whether both axes should be drawn
5867# ' on the plot.
5968# '
6069# ' @param sci.notation Generate prettier labels
@@ -106,11 +115,13 @@ eafplot <- function(x, ...) UseMethod("eafplot")
106115# ' ylab = "Minimum idle time (minutes)", maximise = c(FALSE, TRUE),
107116# ' las = 1, log = "y", main = "SPEA2 (Richmond)",
108117# ' legend.pos = "bottomright")
118+ # '
119+ # ' data(tpls50x20_1_MWT, package="moocore")
120+ # ' eafplot(tpls50x20_1_MWT[, c(2,3)], sets = tpls50x20_1_MWT[,4L],
121+ # ' groups = tpls50x20_1_MWT[["algorithm"]])
109122# ' }
110123# ' @references
111- # ' \insertRef{Grunert01}{moocore}
112- # '
113- # ' \insertRef{LopPaqStu09emaa}{moocore}
124+ # ' \insertAllCited{}
114125# ' @concept eaf
115126# ' @export
116127eafplot.default <-
@@ -165,13 +176,13 @@ eafplot.default <-
165176 if (is.null(ylab ))
166177 ylab <- if (! is.null(colnames(x )[2L ])) colnames(x )[2L ] else " objective 2"
167178
168- if (! is.null (attsurfs )) {
169- # Don't we need to apply maximise?
170- attsurfs <- lapply(attsurfs , function (x ) as.matrix(x [, c(1L ,2L ), drop = FALSE ]))
171- } else {
179+ if (is.null (attsurfs )) {
172180 attsurfs <- eaf(x , sets , percentiles = percentiles , maximise = maximise , groups = groups )
173181 attsurfs <- eaf_as_list(attsurfs )
174182 # attsurfs <- lapply(attsurfs, matrix_maximise, maximise = maximise)
183+ } else {
184+ # Don't we need to apply maximise?
185+ attsurfs <- lapply(attsurfs , function (x ) as.matrix(x [, c(1L ,2L ), drop = FALSE ]))
175186 }
176187
177188 # FIXME: We should take the range from the attsurfs to not make x mandatory.
@@ -415,17 +426,17 @@ plot_eaf_full_area <- function(attsurfs, extreme, maximise, col)
415426# seq_intervals_labels(seq(0,1, length.out=5), digits = 1)
416427# "[0.0, 0.2)" "[0.2, 0.4)" "[0.4, 0.6)" "[0.6, 0.8)" "[0.8, 1.0]"
417428# FIXME: Add examples and tests
418- seq_intervals_labels <- function (s , first.open = FALSE , last.open = FALSE ,
429+ seq_intervals_labels <- function (s , first_open = FALSE , last_open = FALSE ,
419430 digits = NULL )
420431{
421432 # FIXME: This should use:
422433 # levels(cut(0, s, dig.lab=digits, include.lowest=TRUE, right=FALSE))
423434 s <- formatC(s , digits = digits , format = if (is.null(digits )) " g" else " f" )
424435 if (length(s ) < 2 ) stop (" sequence must have at least 2 values" )
425436 intervals <- paste0(" [" , s [- length(s )], " , " , s [- 1 ], " )" )
426- if (first.open )
437+ if (first_open )
427438 substr(intervals [1 ], 0 , 1 ) <- " ("
428- if (! last.open ) {
439+ if (! last_open ) {
429440 len <- nchar(intervals [length(intervals )])
430441 substr(intervals [length(intervals )], len , len + 1 ) <- " ]"
431442 }
0 commit comments