[R] integer
Gabor Grothendieck
ggrothendieck at myway.com
Tue Nov 2 18:20:36 CET 2004
Ludovic Tambour ludovic.tambour at cirad.fr
: The problem is :
: " I have a numerical function y = f(x1,x2,x3) where x1...x3 are integers. I
: would like to determine x1,x2,x3 so that "y" has a minimal value. I know
: that
: R can determine a minimal value when x1,x2,x3 are real. Is-it possible to do
: this when x1, x2, x3 are restricted to be integers ? "
Will brute force do?
R> g <- expand.grid(x1 = 0:10, x2 = 0:10, x3 = 0:10)
R> f <- function(x) sum(x*x)
R> g[which.min(apply(g, 1, f)),]
x1 x2 x3
1 0 0 0
More information about the R-help
mailing list