2020-11-09 08:33:02 +01:00
|
|
|
|
findEmptyPop <- function(npops) {
|
2021-11-10 14:02:35 +01:00
|
|
|
|
# % Palauttaa ensimm<6D>isen tyhj<68>n populaation indeksin. Jos tyhji<6A>
|
|
|
|
|
|
# % populaatioita ei ole, palauttaa -1:n.
|
2024-04-10 16:04:07 +02:00
|
|
|
|
pops <- t(unique(globals$PARTITION))
|
2021-11-10 14:02:35 +01:00
|
|
|
|
if (length(pops) == npops) {
|
|
|
|
|
|
emptyPop <- -1
|
|
|
|
|
|
} else {
|
|
|
|
|
|
popDiff <- diff(c(0, pops, npops + 1))
|
2022-02-03 10:43:34 +01:00
|
|
|
|
emptyPop <- base::min(matlab2r::find(popDiff > 1))
|
2021-11-10 14:02:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
return(list(emptyPop = emptyPop, pops = pops))
|
2020-11-09 08:33:02 +01:00
|
|
|
|
}
|