On Wed, Feb 23, 2011 at 08:02:16PM +0100, Chun Wang wrote: > Dear R users, > > I have a question about optimization. Is that possible set a constraint that > only integer values are allowed for the optim in the R base and some other > optimizers such as psoptim in the package pso? For instance, my lower bound > is 0 and upper bound is 100 and I only want integer from 0 to 100. Is this > possible? Thank you very much for any help in advance.
Hi. How many variables are in your function? This is important, since imposing the integer constraint to a larger number of variables can change an efficiently solvable problem into an NP-complete one. See http://en.wikipedia.org/wiki/Integer_linear_programming#Integer_unknowns for linear programming with integer constraints. On the other hand, if the number of variables is small, then an exhaustive search may be an efficient solution, which is not possible for problems in continuous domain. Also, try searching CRAN task view Optimization http://cran.at.r-project.org/web/views/Optimization.html for the word "integer". Hope this helps for a start. Petr Savicky. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.