Search in sources :

Example 1 with DBIDArrayMIter

use of de.lmu.ifi.dbs.elki.database.ids.DBIDArrayMIter in project elki by elki-project.

the class PROCLUS method computeM_current.

/**
 * Computes the set of medoids in current iteration.
 *
 * @param m the medoids
 * @param m_best the best set of medoids found so far
 * @param m_bad the bad medoids
 * @param random random number generator
 * @return m_current, the set of medoids in current iteration
 */
private ArrayDBIDs computeM_current(DBIDs m, DBIDs m_best, DBIDs m_bad, Random random) {
    ArrayModifiableDBIDs m_list = DBIDUtil.newArray(m);
    m_list.removeDBIDs(m_best);
    DBIDArrayMIter it = m_list.iter();
    ArrayModifiableDBIDs m_current = DBIDUtil.newArray();
    for (DBIDIter iter = m_best.iter(); iter.valid(); iter.advance()) {
        if (m_bad.contains(iter)) {
            int currentSize = m_current.size();
            while (m_current.size() == currentSize) {
                m_current.add(it.seek(random.nextInt(m_list.size())));
                it.remove();
            }
        } else {
            m_current.add(iter);
        }
    }
    return m_current;
}
Also used : DBIDArrayMIter(de.lmu.ifi.dbs.elki.database.ids.DBIDArrayMIter) ArrayModifiableDBIDs(de.lmu.ifi.dbs.elki.database.ids.ArrayModifiableDBIDs) DBIDIter(de.lmu.ifi.dbs.elki.database.ids.DBIDIter)

Aggregations

ArrayModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ArrayModifiableDBIDs)1 DBIDArrayMIter (de.lmu.ifi.dbs.elki.database.ids.DBIDArrayMIter)1 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)1