# vector of object locations, with potential overlap
x <- c(1, 2, 3, 3.3, 3.8, 5, 6, 7, 8, 9, 10)
# full diagnostic output
z <- electroStatics_1D(x, thresh = 0.65, trace = TRUE, q = 1)
txt <- sprintf("Converged %s (%s iterations)", z$converged, length(z$cost))
plot(
seq_along(z$cost),
z$cost,
las = 1,
xlab = 'Iteration',
ylab = 'Overlap Cost',
type = 'b',
main = txt
)
abline(h = 0, lty = 2, col = 2)
# final configuration only
xnew <- electroStatics_1D(x, thresh = 0.65, q = 1)
# check for convergence
attr(xnew, 'converged')
# compare original vs. modified
data.frame(orig = x, new = round(xnew, 2))
Run the code above in your browser using DataLab