public void upd() {
    bestNbrIndices.clear();
    for (int i = 0; i < topk.size(); i++) {
      bestNbrIndices.add(i);
    }
    
    boolean run = true;
    while(run) {
      run = false;
      // add neighbor
      //print(baseUserID + " begining: " + upd);
      for (int i = 0; i < topk.size() + topr.size(); i++) {
        if (bestNbrIndices.contains(i)) {
          continue;
        }
        bestNbrIndices.add(i);
        double err = error(bestNbrIndices);
        //print(baseUserID + " i added: " + upd);
        if (err < bestError) {
          bestError = err;
          run = true;
        } else {
          //print("remove i="+i);
          bestNbrIndices.remove(i);
        }
      }
      //print(baseUserID + " after add: " + upd);
      
      // remove neighbor
      for (int i = 0; i < topk.size() + topr.size(); i++) {
        if (bestNbrIndices.contains(i)) {
          bestNbrIndices.remove(i);
          double err = error(bestNbrIndices);
          if (err < bestError) {
            bestError = err;
            run = true;
          } else {
            bestNbrIndices.add(i);
          }
        }
      }
    }
  }