[R] integer constraint
Petr Savicky
savicky at praha1.ff.cuni.cz
Wed Feb 23 22:56:07 CET 2011
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.
More information about the R-help
mailing list