Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/EI.grad.R
Original file line number Diff line number Diff line change
Expand Up @@ -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), ncol=d)

# Compute gradients of the kriging mean and variance
W <- backsolve(t(T), dc, upper.tri=FALSE)
Expand All @@ -179,4 +179,4 @@ EI.grad <- function(x, model, plugin=NULL, type="UK", minimization = TRUE, envir
}
########################################################################################
return(ei.grad)
}
}
6 changes: 3 additions & 3 deletions R/qEI.grad.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ 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, 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
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") {
Expand Down Expand Up @@ -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)) {
Expand Down