Description Format Value Methods Public fields Methods Examples
Class providing object with methods for adapt.concept2.sFFLHD.R6
Class providing object with methods for adapt.concept2.sFFLHD.R6
R6Class
object.
Object of R6Class
with methods for running an
adaptive experiment.
For full documentation of each method go to https://github.com/CollinErickson/DOE-Code
new(X, Z, corr="Gauss", verbose=0, separable=T,
useC=F,useGrad=T,
parallel=T, nug.est=T, ...)
This method is used to create object
of this class with X
and Z
as the data.
update(Xnew=NULL, Znew=NULL, Xall=NULL, Zall=NULL,
restarts = 5,
param_update = T, nug.update = self$nug.est)
This method updates the model, adding new data if given, then running optimization again.
X
Design matrix
Z
Responses
b
batch size
func
Actual function to get experiment values from
D
Dimension of data
mod
The GP model from
func_run_together
Whether points should be passed to func separately as vectors or all together as a matrix whose rows are the points.
func_fast
If the function is fast. If TRUE then full plots are made. In practice this is alway FALSE.
new_batches_per_batch
How many batches of candidate points are added for each batch taken.
X_tracker
data.frame tracking the points of X, such as when they were selected.
X0
An initial matrix of points to be used.
Xopts
A matrix of candidate (option) points.
Xopts_tracker
A data.frame tracking the points of Xopts.
batch.tracker
Tracks when points were added to Xopts.
Xopts_removed
A matrix of points removed from Xopts.
s
The design object for generating candidate points.
design
A string saying which design object should be used.
stats
A data.frame giving stats for each iteration.
iteration
The current iteration.
obj
A string saying what the objective is.
obj_func
A function for the objective.
n0
The initial number of points to be selected.
take_until_maxpvar_below
A number, if the proportion of points near the maximum variance of the GP model, then it will take space-filling points.
package
Which GP package should be used by IGP
force_old
A number saying how often the oldest candidate points should be forced into the design.
force_pvar
A number saying how often the points with the highest predictive variance should be forced into the design.
des_func
The desirability function.
des_func_fast
Whether the des_func is fast for candidate points.
alpha_des
The alpha constant for the weight function.
actual_des_func
The true des func used to evaluate the model, not known in practice
weight_const
The weight constant in the weight function, usually 1.
selection_method
What the selection method should be.
parallel
Should new values be calculated in parallel?
verbose
How much detail should be printed to the console. 0 is minimal, 1 is medium, 2 is a lot.
L
Batch size
obj_nu
Objective nu, a weight that shouldn't be used.
stage1batches
Number of batches to use in the first stage where space-filling batches are chosen.
useSMEDtheta
Should theta be used when SMED is used? Theta is the correlation parameter in each dimension. Helps space things properly
nconsider
Number of points to consider when adding each point of the batch. Designed to be reduced as you go. E.g., adding a batch of 3, you could use c(Inf, 50, 20) to reduce computation as you go. It would keep the 50/20 best from the previous iteration in consideration.
nconsider_random
If using nconsider, how many random points should be added back in each iteration?
error_power
Power to put the error to. Either 0, 1, or c(0,1).
actual_werror_func
Function to calculate the actual weighted error.
parallel_cores
Number of parallel cores to use.
parallel_cluster
The parallel cluster object being used.
options
Options.
adapt.concept2.sFFLHD.R6$select_new_points_from_old_or_pvar()
adapt.concept2.sFFLHD.R6$select_new_points_from_max_des_red()
new()
Create a new adapt concept object
adapt.concept2.sFFLHD.R6$new( D, L, b = NULL, package = NULL, obj = NULL, n0 = 0, stage1batches = NULL, force_old = 0, force_pvar = 0, useSMEDtheta = F, func, func_run_together = FALSE, func_fast = TRUE, take_until_maxpvar_below = NULL, design = "sFFLHD", selection_method, X0 = NULL, Xopts = NULL, des_func, des_func_fast = TRUE, alpha_des = 1, new_batches_per_batch = 5, parallel = FALSE, parallel_cores = "detect", nugget = 1e-06, estimate.nugget = TRUE, verbose = 1, design_seed = numeric(0), weight_const = 0, error_power = 1, nconsider = Inf, nconsider_random = 0, ... )
D
Number of input dimensions. Should all be 0 to 1.
L
Batch size
b
Batch size to add each iteration
package
Gaussian process model package to use
obj
Objective type
n0
Number of points to start experiment with
stage1batches
Number of batches to be run in "stage 1," aka nonadaptively, chosen to be space filling
force_old
Proportion of points to be force added from Xopts because they are old.
force_pvar
Proportion of points to be force added from Xopts because they have highest predictive variance
useSMEDtheta
Should theta be used when SMED is used? Theta is the correlation parameter in each dimension. Helps space things properly
func
The true function. Should take a matrix as input with D columns, each row is an X point. Or just each point as a vector, depends on func_run_together
func_run_together
If TRUE, X points will be passed to func as a matrix
func_fast
Is func, the true function, fast to evaluate? If yes, will be run repeatedly to calculate true MSE. Never true in practice.
take_until_maxpvar_below
If given, nonadaptive batches will be taken instead of adaptive until max pvar is below this value.
design
The design to take candidate points from.
selection_method
How should points be selected?
X0
If given, an initial matrix of points that have already been evaluated.
Xopts
If given, the initial set of Xopts, the candidate points from which points can be selected.
des_func
The desirability function
des_func_fast
Same as func_fast but for des_func
alpha_des
Alpha value for the desirability function
new_batches_per_batch
Each time a batch is added, how many batches of points should be added as candidates
parallel
Should points be evaluated in parallel
parallel_cores
Number of parallel cores to be used.
nugget
Value to set the nugget to. To keep it at this value, set estimate.nugget=TRUE.
estimate.nugget
Should the nugget be estimated? Logical.
verbose
Amount of printing to do. 0 is minimal, 1 is some, 2 is a lot.
design_seed
Random seed to set before creating the design.
weight_const
Constant to put in front of weight.
error_power
Power to put the error to. Either 0, 1, or c(0,1).
nconsider
Number of points to consider when adding each point of the batch. Designed to be reduced as you go. E.g., adding a batch of 3, you could use c(Inf, 50, 20) to reduce computation as you go. It would keep the 50/20 best from the previous iteration in consideration.
nconsider_random
If using nconsider, how many random points should be added back in each iteration?
...
You can pass in actual_des_func like this.
run()
Run multiple iterations
adapt.concept2.sFFLHD.R6$run(maxit, plotlastonly = F, noplot = F)
maxit
Number of iterations to run
plotlastonly
Should the plots only be made after the last iteration (when maxit>1)
noplot
Should plots not be made after any iteration?
run1()
Run a single iteration
adapt.concept2.sFFLHD.R6$run1(plotit = TRUE)
plotit
Should the plots be made for this iteration?
add_data()
Add data from Xopts to X
adapt.concept2.sFFLHD.R6$add_data()
update_obj_nu()
Update nu for objective
adapt.concept2.sFFLHD.R6$update_obj_nu(Xnew, Znew)
Xnew
Matrix of X points
Znew
Corresponding function values
update_mod()
Update the GP model on all the data.
adapt.concept2.sFFLHD.R6$update_mod()
update_stats()
Update stats after every iteration
adapt.concept2.sFFLHD.R6$update_stats()
mse_func()
Calculate mean squared error using random sample of points. Only works when func_fast is TRUE and the true function func is given.
adapt.concept2.sFFLHD.R6$mse_func()
plot_mean()
Contour plot of the predicted mean. Only for 2D input.
adapt.concept2.sFFLHD.R6$plot_mean(cex = 1, plot.axes = TRUE)
cex
Size parameter
plot.axes
Should the axes included in the plot.
plot_se()
Contour plot of the predicted standard error. Only for 2D input.
adapt.concept2.sFFLHD.R6$plot_se(cex = 1, plot.axes = TRUE)
cex
Size parameter
plot.axes
Should the axes included in the plot.
plot_abserr()
Contour plot of the absolute error. Only for 2D input.
adapt.concept2.sFFLHD.R6$plot_abserr(cex = 1, plot.axes = TRUE)
cex
Size parameter
plot.axes
Should the axes included in the plot.
plot_mse()
Plot MSE and PVar over iterations
adapt.concept2.sFFLHD.R6$plot_mse(statsdf, cex = 1)
statsdf
DF with stats for points
cex
Size parameter
plot_iwe()
Plot integrate weighted error
adapt.concept2.sFFLHD.R6$plot_iwe(statsdf, cex = 1)
statsdf
DF with stats for each point
cex
Size parameter
plot_ppu()
Plot percentage of points used by iteration
adapt.concept2.sFFLHD.R6$plot_ppu(statsdf, cex)
statsdf
data frame with stats of when points were taken
cex
Size parameter
plot_des_v_acc()
Plot desirability vs prediction accuracy
adapt.concept2.sFFLHD.R6$plot_des_v_acc(cex, cex.axis)
cex
Size parameter
cex.axis
Size parameter for axis
plot_y_acc()
Plot predicted vs actual with error bars
adapt.concept2.sFFLHD.R6$plot_y_acc(residual = FALSE)
residual
Should residuals be plotted?
plot_1D()
Plot for experiments with 1D input
adapt.concept2.sFFLHD.R6$plot_1D()
plot_2D()
Plot for experiments with 2D input
adapt.concept2.sFFLHD.R6$plot_2D(twoplot = FALSE, cex = 1)
twoplot
Should only predicted surface and predicted error be shown, or more plots?
cex
Size parameter
plot1()
Plot at one instance
adapt.concept2.sFFLHD.R6$plot1(twoplot = FALSE, cex = 1)
twoplot
Should only predicted surface and predicted error be shown, or more plots?
cex
Size parameter
add_new_batches_to_Xopts()
Add new batches of points to Xopts matrix
adapt.concept2.sFFLHD.R6$add_new_batches_to_Xopts( num_batches_to_take = self$new_batches_per_batch )
num_batches_to_take
Number of batches of points to add to Xopts from the design $s
Xopts_tracker_add()
Points to add to Xopts_tracker
adapt.concept2.sFFLHD.R6$Xopts_tracker_add(Xnew)
Xnew
Matrix of points to add
Xopts_tracker_remove()
Remove points from Xopts_tracker
adapt.concept2.sFFLHD.R6$Xopts_tracker_remove(newL)
newL
Vector of indices of points to remove
select_new_points_from_old_or_pvar()
Select new points from Xopts that are oldest or have highest predictive variance
adapt.concept2.sFFLHD.R6$select_new_points_from_old_or_pvar()
select_new_points_from_SMED()
Select new points from Xopts using SMED
adapt.concept2.sFFLHD.R6$select_new_points_from_SMED()
select_new_points_from_max_des()
Select new points from Xopts with maximum desirability
adapt.concept2.sFFLHD.R6$select_new_points_from_max_des()
select_new_points_from_max_des_red()
Select new points from Xopts using maximum reduction in desirability
adapt.concept2.sFFLHD.R6$select_new_points_from_max_des_red()
int_werror_after_adding()
Calculate integrated weighted error after adding Xnew
adapt.concept2.sFFLHD.R6$int_werror_after_adding( Xnew = NULL, Znew = NULL, Xnew_Xoptsrow = NULL, n = 10000, int_points = NULL, seed = NULL, ... )
Xnew
New X points
Znew
Z at those new points
Xnew_Xoptsrow
Rows
n
Number of points
int_points
Integration points
seed
Random seed
...
Passed through
add_newL_points_to_design()
Add new L points to design
adapt.concept2.sFFLHD.R6$add_newL_points_to_design( newL = NULL, use_X0 = FALSE, reason )
newL
Which rows of Xopts to add
use_X0
Should X0 be used?
reason
Reason selected, is logged in summary DF
calculate_Z()
Evaluate chosen X points using given function
adapt.concept2.sFFLHD.R6$calculate_Z(X)
X
Matrix whose rows are new points to evaluate
weight_func()
The weight function 1 + alpha * delta()
adapt.concept2.sFFLHD.R6$weight_func( ..., XX, mod = self$mod, des_func = self$des_func, alpha = self$alpha_des, weight_const = self$weight_const )
...
Forces you to name arguments
XX
input points
mod
GP model
des_func
Desirability function or des values for each XX
alpha
alpha
weight_const
The weight constant
werror_func()
The weighted error function sigmahat * (1 + alpha * delta())
adapt.concept2.sFFLHD.R6$werror_func( ..., XX, mod = self$mod, des_func = self$des_func, alpha = self$alpha_des, weight_const = self$weight_const, weight_func = self$weight_func, error_power = self$error_power )
...
Forces you to name arguments
XX
X points
mod
GP model
des_func
Desirability function
alpha
alpha
weight_const
Weight constant
weight_func
Weight function
error_power
Error power
intwerror_func()
Calculate integrated weighted error
adapt.concept2.sFFLHD.R6$intwerror_func( ..., XX = NULL, N = 10000, mod = self$mod, des_func = self$des_func, alpha = self$alpha_des, weight_const = self$weight_const, weight_func = self$weight_func, error_power = self$error_power )
...
Forces you to name arguments
XX
Integration points
N
Number of integration points if XX not given
mod
GP model
des_func
Desirability function
alpha
Alpha
weight_const
Weight constant
weight_func
Weight function
error_power
Error power
int_pvar_red_for_opts()
Calculate integrated predictive variance reduction for candidate points.
adapt.concept2.sFFLHD.R6$int_pvar_red_for_opts( ..., Xopts, XX = NULL, N = 10000, mod = self$mod, des_func = self$des_func, alpha = self$alpha_des, weight_const = self$weight_const, weight_func = self$weight_func, delta_pvar_func = mean )
...
Forces you to name arguments
Xopts
Candidate points
XX
Integration points
N
Number of points
mod
GP model
des_func
Desirability function
alpha
Alpha
weight_const
Weight constant
weight_func
Weight function
delta_pvar_func
Delta pvar func
int_pvar_red_for_one()
Calculate the integrated predictive variance reduction
adapt.concept2.sFFLHD.R6$int_pvar_red_for_one( v, X_, XX, corr_func, Kinv, s2, K_X_XX, delta_pvar_func = mean )
v
Something
X_
Points
XX
Integration points
corr_func
correlation function
Kinv
Inverse of correlation matrix
s2
Variance term
K_X_XX
Correlation between X_ and XX
delta_pvar_func
which function to use
actual_intwerror_func()
Calculate the actual integrated weighted error
adapt.concept2.sFFLHD.R6$actual_intwerror_func( ..., N = 2000, mod = self$mod, f = self$func, error_power = self$error_power, nquantilegroups )
...
Forces you to name arguments
N
Number of integration points
mod
Model to use that predicts the function f
f
True function you are estimating
error_power
What power should the error be to? Either 1, 2, or c(1,2)
nquantilegroups
Number of quantile groups.
print_results()
Print the results so far.
adapt.concept2.sFFLHD.R6$print_results()
delete()
This is run when deleting the object. It'll delete the GP model and stop the parallel cluster.
adapt.concept2.sFFLHD.R6$delete()
clone()
The objects of this class are cloneable with this method.
adapt.concept2.sFFLHD.R6$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | a <- adapt.concept2.sFFLHD.R6$new(D=2,L=3,func=TestFunctions::gaussian1,obj="desirability",
des_func=des_func_relmax, n0=12, take_until_maxpvar_below=.9,
package="GauPro", design='sFFLHD', selection_method="max_des_red",
alpha_des=1)
a$run(2)
# limnonpoly, grad_norm2_mean, laGP_GauPro_kernel
set.seed(1); ContourFunctions::csa(); a <- adapt.concept2.sFFLHD.R6$new(
D=2,L=3,func=TestFunctions::limnonpoly, nugget = 1e-7,estimate.nugget = TRUE,
obj="desirability", des_func=des_func_grad_norm2_mean,
actual_des_func=NULL,#get_num_actual_des_func_grad_norm2_mean(),
stage1batches=2, alpha_des=1, weight_const=0,
package="laGP_GauPro_kernel", design='sFFLHD',
error_power=2,
selection_method="max_des_red_all_best"
# selection_method="ALC_all_best"
); a$run(1)
a$run(2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.