Visualize objective as interactive surface
VisualizerSurfaceObj.RdThis class is used to create interactive surface visualizations and animations of optimization traces for 2D objectives using plotly.
Super classes
vistool::Visualizer -> vistool::VisualizerSurface -> VisualizerSurfaceObj
Methods
Inherited methods
vistool::Visualizer$add_annotation()vistool::Visualizer$add_points()vistool::Visualizer$resolve_layer_colors()vistool::Visualizer$save()vistool::Visualizer$set_theme()vistool::Visualizer$theme()vistool::VisualizerSurface$add_contours()vistool::VisualizerSurface$init_layer_contour()vistool::VisualizerSurface$init_layer_surface()vistool::VisualizerSurface$set_layout()vistool::VisualizerSurface$set_scene()
Method new()
Creates a new instance of this R6 class.
Usage
VisualizerSurfaceObj$new(
objective,
x1_limits = NULL,
x2_limits = NULL,
padding = 0,
n_points = 100L
)Arguments
objective(
Objective)
The objective to optimize.x1_limits(
numeric(2))
The x1 limits.x1_limits(
numeric(2))
The x1 limits.x2_limits(
numeric(2))
The x2 limits.x2_limits(
numeric(2))
The x2 limits.padding(
numeric(1))
A margin that is added to x1limits and x2limits. The x1 margin is calculated bymax(x1lmits) - min(x1limits) * padding.padding(
numeric(1))
A margin that is added to x1limits and x2limits. The x1 margin is calculated bymax(x1lmits) - min(x1limits) * padding.n_points(
integer(1))
The number of generated point per dimension. Note that a grid ofnpoints^2values is generated and evaluated byobjective$eval(x)to plot the surface.n_points(
integer(1))
The number of generated point per dimension. Note that a grid ofnpoints^2values is generated and evaluated byobjective$eval(x)to plot the surface.
Method add_optimization_trace()
Add an optimization trace.
Usage
VisualizerSurfaceObj$add_optimization_trace(
opt,
line_color = NULL,
mcolor_out = "black",
line_width = NULL,
npoints = NULL,
npmax = NULL,
name = NULL,
offset = NULL,
add_marker_at = 1,
marker_shape = "circle",
marker_color = NULL,
line_type = NULL,
...
)Arguments
opt(
Optimizer)
The optimizer from which the archive is extracted and used to plot the trace.line_color(
character(1))
The color of the trace.mcolor_out(
character(1))
The outer line color of the marker.line_width(
numeric(1))
Width of the optimization trace line. IfNULL, uses theme$line_width.npoints(
integer(1))
The number of used points from the archive. Default isNULLwhich means that all points are used. If set, a sequence from 1 tonrow(opt$archive)is created.npmax(
integer(1))
The number of points used from the sequenceseq_len(nrow(opt$archive))[seq_len(npmax)]name(
character(1))
The name of the trace in the legend. Default isNULLwhich uses onlyopt$id(optimizer ID).offset(
numeric(3))
Trace shift in direction (x, y, z).add_marker_at(
integer())
Vector of iterations at which a marker is added.marker_shape(
character())
Vector indicating the shape of the markers. Iflength(marker_shape) == 1, all markers get the same shape. The other option is to specify all markers individually by passing a vector oflength(add_marker_at). For a list of all shapes seeschema(F)$traces$XXX$attributes$marker$symbol$valueswithXXXone ofscatterorscatter3d. Ifmarker_shape = NA, no marker are added.marker_color(
character())
The colors for the markers.line_type(
character(1)) Line type for the optimization trace (e.g., "solid", "dashed", "dotted", "dash", "dot", "dashdot"). Mapped to Plotly'sline$dash. IfNULL, defaults to solid....Further arguments passed to
add_trace(...).
Method plot()
Renders the surface plot with all added layers.
Method add_taylor()
Add a Taylor approximation (for 1 and 2 degrees).
Usage
VisualizerSurfaceObj$add_taylor(
x0,
degree = 2,
x1margin = 0,
x2margin = 0,
npoints_per_dim = 20L,
zlim = NULL,
...
)Arguments
x0(
numeric())
The point around which the approximation is done.degree(
integer(1))
The degree of the approximation (only 1 and 2 is implemented).x1margin(
numeric(1))
The "length" of the hyperplane in direction x1.x2margin(
numeric(1))
The "length" of the hyperplane in direction x2.npoints_per_dim(
integer(1))
Number of points per dimension for the plotting grid.zlim(
numeric(2))
The limits for z. Can be helpful if the hyperplane as a huge z range and therefore the plot looks ugly....(
any)
Additional parameter passed toadd_surface().
Method animate()
Create an animation of $plot().
Arguments
dir(
character(1))
The directory in which all the images are saved.nframes(
integer(1))
The number of frames.view_start(
list())
The start view of the animation.view_end(
list())
The end view of the animation.fext(
character(1))
The file extension (default ispng).stops(
integer())
The step / iteration in the archives of the optimizers added by$add_optimization_trace()at which a frame is taken. Must have exact the same length as defined innframes. By default, a sequence with equidistant points is generated forstops....(
any)
Additional arguments passed to$save(...).