[R] integer
Spencer Graves
spencer.graves at pdf.com
Tue Nov 2 19:22:02 CET 2004
I just went to www.r-project.org -> search -> "R site search" ->
"integer programming". This brought 99 hits, the 23rd of which referred
to function "lp" in package "lpSolve". This may solve the problem if
"f" in linear.
Otherwise, if f is defined and reasonably well behaved for non
integer values, one could find the minimum over non integers then search
all combinations of integers near the non integer minimum.
hope this helps.
spencer graves
Ludovic Tambour wrote:
>Sorry, the formulation of my question is bad. I hope that you have not lost
>your time. The problem is not a problem of integer identification.
>
>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 ? "
>
>Ludo
>
>
>
>
>----- Original Message -----
>From: "Uwe Ligges" <ligges at statistik.uni-dortmund.de>
>To: "Göran Broström" <gb at stat.umu.se>
>Cc: <r-help at stat.math.ethz.ch>
>Sent: Tuesday, November 02, 2004 3:44 PM
>Subject: Re: [R] integer
>
>
>
>
>>Göran Broström wrote:
>>
>>
>>
>>>On Tue, Nov 02, 2004 at 11:36:27AM +0100, Uwe Ligges wrote:
>>>
>>>
>>>
>>>>Ludovic Tambour wrote:
>>>>
>>>>
>>>>
>>>>
>>>>>Hello,
>>>>>
>>>>>I need to use "R" to determine parameters which are integers. How I can
>>>>>
>>>>>
>do
>
>
>>>>>this, please ?
>>>>>
>>>>>
>>>>What so you mean with "parameters"? In which context?
>>>>
>>>>To check whether a numeric vector "x" contains only integers, you can
>>>>
>>>>
>try
>
>
>>>>all.equal(as.integer(x), x)
>>>>
>>>>
>>>I don't think so:
>>>
>>>
>>>
>>>
>>>>x <- as.double(c(1, 2))
>>>>y <- as.integer(c(1, 2))
>>>>all.equal(x, y)
>>>>
>>>>
>>>[1] TRUE
>>>
>>>But,
>>>
>>>
>>>
>>>
>>>>identical(x, y)
>>>>
>>>>
>>>[1] FALSE
>>>
>>>
>>[The story was completely different from the stuff I guessed, so all
>>further communication related to this thread is "academic".]
>>
>>Göran,
>>
>>yes, as expected.
>>
>>
>>
>>
>>>On the other hand, why not use
>>>
>>>
>>>
>>>
>>>>is.integer(x)
>>>>
>>>>
>>>[1] FALSE
>>>
>>>
>>>
>>>>is.integer(y)
>>>>
>>>>
>>>[1] TRUE
>>>
>>>because I think that a numeric vector can't have a mix of integer and
>>>non-integer elements. With a list it's a different story.
>>>
>>>
>>Yes.
>>
>>My guees was that the asker tried to identify integers such as 2, 3 in
>>contrast to 2.1, 3.1, ...and you won't know it by looking at R's storage
>>mode (my guess was that the asker was not interested in the storage
>>mode, but in the nature of the numbers!).
>>Note that is.integer(1) is FALSE!!!
>>
>>The given usage of all.equal() helps to identify 1 as an integer, but
>>not 1.1...
>>
>>Uwe
>>
>>
>>
>>>Göran
>>>
>>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide!
>>
>>
>http://www.R-project.org/posting-guide.html
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
--
Spencer Graves, PhD, Senior Development Engineer
O: (408)938-4420; mobile: (408)655-4567
More information about the R-help
mailing list