From 23a2265fbea3aec288662c18184098688971f24a Mon Sep 17 00:00:00 2001 From: nrontsis Date: Wed, 11 Oct 2017 16:46:38 +0100 Subject: [PATCH 1/5] Fixing qEI.grad.R to work with 1d data --- R/qEI.grad.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/qEI.grad.R b/R/qEI.grad.R index db193cb..31dc138 100644 --- a/R/qEI.grad.R +++ b/R/qEI.grad.R @@ -123,7 +123,7 @@ krigingDeriv <- function(x, model, type="UK", envir=NULL){ # Compute gradients of the kriging covariance between point k and point l for (l in 1:q) { # Compute gradients of the kernel between point k and point l - ker.grad <- covVector.dx(x=newdata.num[k,], X=newdata[l,], + ker.grad <- covVector.dx(x=newdata.num[k,], X=matrix(newdata[l,], ncol=d), object=covStruct, c=covM[k,l]) kriging.cov.jacob[k,,k,l] <- ker.grad - t(v[,l])%*%W if (type=="UK") { From 10fe2daf2932dde77d20da60c8d44915531316e6 Mon Sep 17 00:00:00 2001 From: nrontsis Date: Wed, 11 Oct 2017 22:21:09 +0100 Subject: [PATCH 2/5] Fix for dim=1, batch_size=2 --- R/qEI.grad.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/qEI.grad.R b/R/qEI.grad.R index 31dc138..4beb3de 100644 --- a/R/qEI.grad.R +++ b/R/qEI.grad.R @@ -119,7 +119,7 @@ krigingDeriv <- function(x, model, type="UK", envir=NULL){ f.deltax <- trend.deltax(x=newdata.num[k,], model=model) # Compute gradients of the kriging mean at point k W <- backsolve(t(T), dc, upper.tri=FALSE) - kriging.mean.jacob[k,,k] <- t(z)%*%W + model@trend.coef%*%f.deltax + kriging.mean.jacob[k,,k] <- t(z)%*%W + model@trend.coef%*%matrix(f.deltax) # Compute gradients of the kriging covariance between point k and point l for (l in 1:q) { # Compute gradients of the kernel between point k and point l From 6bca38ed3d16bf2435afaaaed836730519e37f0b Mon Sep 17 00:00:00 2001 From: nrontsis Date: Wed, 11 Oct 2017 22:22:54 +0100 Subject: [PATCH 3/5] Fix call to EI.grad (fixes the case of batch_size=1) --- R/qEI.grad.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/qEI.grad.R b/R/qEI.grad.R index 4beb3de..d24ba1b 100644 --- a/R/qEI.grad.R +++ b/R/qEI.grad.R @@ -296,7 +296,7 @@ qEI.grad <- function(x, model, plugin=NULL, type="UK", minimization = TRUE, fast if (!minimization) { stop("qEI.grad doesn't work in \'minimization = FALSE\' when dim = 1 (in progress).") } - return(EI.grad(x,model,plugin,type,envir)) + return(EI.grad(x,model,plugin,type,minimization,envir)) } if(!is.null(envir)) { From 62e72c78868bde14e13cb6227bd44207302b84b6 Mon Sep 17 00:00:00 2001 From: nrontsis Date: Wed, 11 Oct 2017 23:08:25 +0100 Subject: [PATCH 4/5] Fixing 1d case for EI.grad --- R/EI.grad.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/EI.grad.R b/R/EI.grad.R index ce91560..f50f2c7 100644 --- a/R/EI.grad.R +++ b/R/EI.grad.R @@ -158,7 +158,7 @@ EI.grad <- function(x, model, plugin=NULL, type="UK", minimization = TRUE, envir } else { # Compute derivatives of the covariance and trend functions dc <- covVector.dx(x=newdata.num, X=X, object=covStruct, c=c) - f.deltax <- trend.deltax(x=newdata.num, model=model) + f.deltax <- matrix(trend.deltax(x=newdata.num, model=model)) # Compute gradients of the kriging mean and variance W <- backsolve(t(T), dc, upper.tri=FALSE) @@ -179,4 +179,4 @@ EI.grad <- function(x, model, plugin=NULL, type="UK", minimization = TRUE, envir } ######################################################################################## return(ei.grad) -} \ No newline at end of file +} From 643c7f66a78f4276239125e8a4f5872bd5c30e67 Mon Sep 17 00:00:00 2001 From: nrontsis Date: Mon, 23 Oct 2017 14:49:32 +0100 Subject: [PATCH 5/5] Fix for dimensions > 1 --- R/EI.grad.R | 2 +- R/qEI.grad.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/EI.grad.R b/R/EI.grad.R index f50f2c7..bc14398 100644 --- a/R/EI.grad.R +++ b/R/EI.grad.R @@ -158,7 +158,7 @@ EI.grad <- function(x, model, plugin=NULL, type="UK", minimization = TRUE, envir } else { # Compute derivatives of the covariance and trend functions dc <- covVector.dx(x=newdata.num, X=X, object=covStruct, c=c) - f.deltax <- matrix(trend.deltax(x=newdata.num, model=model)) + f.deltax <- matrix(trend.deltax(x=newdata.num, model=model), ncol=d) # Compute gradients of the kriging mean and variance W <- backsolve(t(T), dc, upper.tri=FALSE) diff --git a/R/qEI.grad.R b/R/qEI.grad.R index d24ba1b..680d1aa 100644 --- a/R/qEI.grad.R +++ b/R/qEI.grad.R @@ -119,7 +119,7 @@ krigingDeriv <- function(x, model, type="UK", envir=NULL){ f.deltax <- trend.deltax(x=newdata.num[k,], model=model) # Compute gradients of the kriging mean at point k W <- backsolve(t(T), dc, upper.tri=FALSE) - kriging.mean.jacob[k,,k] <- t(z)%*%W + model@trend.coef%*%matrix(f.deltax) + kriging.mean.jacob[k,,k] <- t(z)%*%W + model@trend.coef%*%matrix(f.deltax, ncol=d) # Compute gradients of the kriging covariance between point k and point l for (l in 1:q) { # Compute gradients of the kernel between point k and point l