public QryResult evaluateBM25 (RetrievalModel r) throws IOException {

    //  Initialization
	double k3 = r.k_3;
	int qtf = 1; // hardcoding to one for now.
	double USERweight = ((k3 + 1)*qtf)/(k3 + qtf);
	
    allocDaaTPtrs (r);
    QryResult result = new QryResult ();

    //  Sort the arguments so that the shortest lists are first.  This
    //  improves the efficiency of exact-match OR without changing
    //  the result.
    int max = this.daatPtrs.get(0).scoreList.scores.size();
    int maxindex = 0;
    
    for (int i=1; i< this.daatPtrs.size(); i++) {
    	if (max < this.daatPtrs.get(i).scoreList.scores.size() )
    	{
    		max = this.daatPtrs.get(i).scoreList.scores.size();
    		maxindex = i;
    	}
    }
    	
	ScoreList tmpScoreList = this.daatPtrs.get(0).scoreList;
    this.daatPtrs.get(0).scoreList = this.daatPtrs.get(maxindex).scoreList;
    this.daatPtrs.get(maxindex).scoreList = tmpScoreList;
    

    // take the longest list  i.e. the last one in the array.
    DaaTPtr ptr0 = this.daatPtrs.get(0);
    
    // Hashmap will store the doc id and corresponding score. 
    HashMap<Integer, Double> hm = new HashMap<Integer, Double>();
    double currScore = 0;
    
    for ( ; ptr0.nextDoc < ptr0.scoreList.scores.size(); ptr0.nextDoc ++) {

      int ptr0Docid = ptr0.scoreList.getDocid (ptr0.nextDoc);
   
      //  If docid already not present, then add the doc id.
      if (!hm.containsKey(ptr0Docid))
      {
    	  hm.put(ptr0Docid, ptr0.scoreList.getDocidScore(ptr0.nextDoc)*USERweight);
      }
      else   // get the score of existing doc id and put the maximum score in it.  
      {   
    	  currScore = hm.get(ptr0.scoreList.getDocid (ptr0.nextDoc));
    	  hm.put(ptr0.scoreList.getDocid (ptr0.nextDoc), currScore + ptr0.scoreList.getDocidScore(ptr0.nextDoc)*USERweight);
      }
      
      for (int j=1; j < this.daatPtrs.size(); j++) {

    	  DaaTPtr ptrj = this.daatPtrs.get(j);
    	  
    	  //  If docid already not present, then add the doc id.
    	  if (ptrj.nextDoc < ptr0.scoreList.scores.size() && ptrj.nextDoc <  ptrj.scoreList.scores.size() )
    	  {
    		  if (!hm.containsKey(ptrj.scoreList.getDocid (ptrj.nextDoc)))
    	      {
    	    	  hm.put(ptrj.scoreList.getDocid (ptrj.nextDoc), ptrj.scoreList.getDocidScore (ptrj.nextDoc)*USERweight);
    	      }
    		  else   // get the score of existing doc id and put the maximum score in it.
    		  {  
    			  currScore = hm.get(ptrj.scoreList.getDocid (ptrj.nextDoc));
    			  hm.put(ptrj.scoreList.getDocid (ptrj.nextDoc), currScore + ptrj.scoreList.getDocidScore(ptrj.nextDoc)*USERweight);
    		  }
    		  
    		  ptrj.nextDoc++;	 
    	  }  			
      }
      
    }

    // Put the docid and score into docScores. Sorting is handled in the QryEval function.
    for (Integer docids : hm.keySet())
    {
    	result.docScores.add (docids.intValue(), hm.get(docids));
    }
    
    freeDaaTPtrs ();

    return result;
  }