adapt.concept2.sFFLHD.R6: Class providing object with methods for...

Description Format Value Methods Public fields Methods Examples

Description

Class providing object with methods for adapt.concept2.sFFLHD.R6

Class providing object with methods for adapt.concept2.sFFLHD.R6

Format

R6Class object.

Value

Object of R6Class with methods for running an adaptive experiment.

Methods

Documentation

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.

Public fields

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.

Methods

Public methods


Method new()

Create a new adapt concept object

Usage
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,
  ...
)
Arguments
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.


Method run()

Run multiple iterations

Usage
adapt.concept2.sFFLHD.R6$run(maxit, plotlastonly = F, noplot = F)
Arguments
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?


Method run1()

Run a single iteration

Usage
adapt.concept2.sFFLHD.R6$run1(plotit = TRUE)
Arguments
plotit

Should the plots be made for this iteration?


Method add_data()

Add data from Xopts to X

Usage
adapt.concept2.sFFLHD.R6$add_data()

Method update_obj_nu()

Update nu for objective

Usage
adapt.concept2.sFFLHD.R6$update_obj_nu(Xnew, Znew)
Arguments
Xnew

Matrix of X points

Znew

Corresponding function values


Method update_mod()

Update the GP model on all the data.

Usage
adapt.concept2.sFFLHD.R6$update_mod()

Method update_stats()

Update stats after every iteration

Usage
adapt.concept2.sFFLHD.R6$update_stats()

Method 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.

Usage
adapt.concept2.sFFLHD.R6$mse_func()

Method plot_mean()

Contour plot of the predicted mean. Only for 2D input.

Usage
adapt.concept2.sFFLHD.R6$plot_mean(cex = 1, plot.axes = TRUE)
Arguments
cex

Size parameter

plot.axes

Should the axes included in the plot.


Method plot_se()

Contour plot of the predicted standard error. Only for 2D input.

Usage
adapt.concept2.sFFLHD.R6$plot_se(cex = 1, plot.axes = TRUE)
Arguments
cex

Size parameter

plot.axes

Should the axes included in the plot.


Method plot_abserr()

Contour plot of the absolute error. Only for 2D input.

Usage
adapt.concept2.sFFLHD.R6$plot_abserr(cex = 1, plot.axes = TRUE)
Arguments
cex

Size parameter

plot.axes

Should the axes included in the plot.


Method plot_mse()

Plot MSE and PVar over iterations

Usage
adapt.concept2.sFFLHD.R6$plot_mse(statsdf, cex = 1)
Arguments
statsdf

DF with stats for points

cex

Size parameter


Method plot_iwe()

Plot integrate weighted error

Usage
adapt.concept2.sFFLHD.R6$plot_iwe(statsdf, cex = 1)
Arguments
statsdf

DF with stats for each point

cex

Size parameter


Method plot_ppu()

Plot percentage of points used by iteration

Usage
adapt.concept2.sFFLHD.R6$plot_ppu(statsdf, cex)
Arguments
statsdf

data frame with stats of when points were taken

cex

Size parameter


Method plot_des_v_acc()

Plot desirability vs prediction accuracy

Usage
adapt.concept2.sFFLHD.R6$plot_des_v_acc(cex, cex.axis)
Arguments
cex

Size parameter

cex.axis

Size parameter for axis


Method plot_y_acc()

Plot predicted vs actual with error bars

Usage
adapt.concept2.sFFLHD.R6$plot_y_acc(residual = FALSE)
Arguments
residual

Should residuals be plotted?


Method plot_1D()

Plot for experiments with 1D input

Usage
adapt.concept2.sFFLHD.R6$plot_1D()

Method plot_2D()

Plot for experiments with 2D input

Usage
adapt.concept2.sFFLHD.R6$plot_2D(twoplot = FALSE, cex = 1)
Arguments
twoplot

Should only predicted surface and predicted error be shown, or more plots?

cex

Size parameter


Method plot1()

Plot at one instance

Usage
adapt.concept2.sFFLHD.R6$plot1(twoplot = FALSE, cex = 1)
Arguments
twoplot

Should only predicted surface and predicted error be shown, or more plots?

cex

Size parameter


Method add_new_batches_to_Xopts()

Add new batches of points to Xopts matrix

Usage
adapt.concept2.sFFLHD.R6$add_new_batches_to_Xopts(
  num_batches_to_take = self$new_batches_per_batch
)
Arguments
num_batches_to_take

Number of batches of points to add to Xopts from the design $s


Method Xopts_tracker_add()

Points to add to Xopts_tracker

Usage
adapt.concept2.sFFLHD.R6$Xopts_tracker_add(Xnew)
Arguments
Xnew

Matrix of points to add


Method Xopts_tracker_remove()

Remove points from Xopts_tracker

Usage
adapt.concept2.sFFLHD.R6$Xopts_tracker_remove(newL)
Arguments
newL

Vector of indices of points to remove


Method select_new_points_from_old_or_pvar()

Select new points from Xopts that are oldest or have highest predictive variance

Usage
adapt.concept2.sFFLHD.R6$select_new_points_from_old_or_pvar()

Method select_new_points_from_SMED()

Select new points from Xopts using SMED

Usage
adapt.concept2.sFFLHD.R6$select_new_points_from_SMED()

Method select_new_points_from_max_des()

Select new points from Xopts with maximum desirability

Usage
adapt.concept2.sFFLHD.R6$select_new_points_from_max_des()

Method select_new_points_from_max_des_red()

Select new points from Xopts using maximum reduction in desirability

Usage
adapt.concept2.sFFLHD.R6$select_new_points_from_max_des_red()

Method int_werror_after_adding()

Calculate integrated weighted error after adding Xnew

Usage
adapt.concept2.sFFLHD.R6$int_werror_after_adding(
  Xnew = NULL,
  Znew = NULL,
  Xnew_Xoptsrow = NULL,
  n = 10000,
  int_points = NULL,
  seed = NULL,
  ...
)
Arguments
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


Method add_newL_points_to_design()

Add new L points to design

Usage
adapt.concept2.sFFLHD.R6$add_newL_points_to_design(
  newL = NULL,
  use_X0 = FALSE,
  reason
)
Arguments
newL

Which rows of Xopts to add

use_X0

Should X0 be used?

reason

Reason selected, is logged in summary DF


Method calculate_Z()

Evaluate chosen X points using given function

Usage
adapt.concept2.sFFLHD.R6$calculate_Z(X)
Arguments
X

Matrix whose rows are new points to evaluate


Method weight_func()

The weight function 1 + alpha * delta()

Usage
adapt.concept2.sFFLHD.R6$weight_func(
  ...,
  XX,
  mod = self$mod,
  des_func = self$des_func,
  alpha = self$alpha_des,
  weight_const = self$weight_const
)
Arguments
...

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


Method werror_func()

The weighted error function sigmahat * (1 + alpha * delta())

Usage
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
)
Arguments
...

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


Method intwerror_func()

Calculate integrated weighted error

Usage
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
)
Arguments
...

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


Method int_pvar_red_for_opts()

Calculate integrated predictive variance reduction for candidate points.

Usage
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
)
Arguments
...

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


Method int_pvar_red_for_one()

Calculate the integrated predictive variance reduction

Usage
adapt.concept2.sFFLHD.R6$int_pvar_red_for_one(
  v,
  X_,
  XX,
  corr_func,
  Kinv,
  s2,
  K_X_XX,
  delta_pvar_func = mean
)
Arguments
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


Method actual_intwerror_func()

Calculate the actual integrated weighted error

Usage
adapt.concept2.sFFLHD.R6$actual_intwerror_func(
  ...,
  N = 2000,
  mod = self$mod,
  f = self$func,
  error_power = self$error_power,
  nquantilegroups
)
Arguments
...

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.


Method print_results()

Print the results so far.

Usage
adapt.concept2.sFFLHD.R6$print_results()

Method delete()

This is run when deleting the object. It'll delete the GP model and stop the parallel cluster.

Usage
adapt.concept2.sFFLHD.R6$delete()

Method clone()

The objects of this class are cloneable with this method.

Usage
adapt.concept2.sFFLHD.R6$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 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)

CollinErickson/AdaptCompExp documentation built on April 13, 2020, 4:53 p.m.