Return an array of tie break rules and an array of tie break orders (+1 for asc, -1 for desc).
 The first and most important method is always "score", the last and least important is always "name".
436909
def tie_break_data
      # Construct the arrays and hashes to be returned.
      methods, order, data = Array.new, Hash.new, Hash.new

      # Score is always the most important.
      methods << :score
      order[:score] = -1

      # Add the configured methods.
      tie_breaks.each do |m|
        methods << m
        order[m] = m == :name ? 1 : -1
      end

      # Name is included as the last and least important tie breaker unless it's already been added.
      unless methods.include?(:name)
        methods << :name
        order[:name] = 1
      end

      # We'll need the number of rounds.
      rounds = last_round

      # Pre-calculate some scores that are not in themselves tie break scores
      # but are needed in the calculation of some of the actual tie-break scores.
      pre_calculated = Array.new
      pre_calculated << :opp_score  # sum scores where a non-played games counts 0.5
      pre_calculated.each do |m|
        data[m] = Hash.new
        @player.values.each { |p| data[m][p.num] = tie_break_score(data, m, p, rounds) }
      end

      # Now calculate all the other scores.
      methods.each do |m|
        next if pre_calculated.include?(m)
        data[m] = Hash.new
        @player.values.each { |p| data[m][p.num] = tie_break_score(data, m, p, rounds) }
      end

      # Finally, return what we calculated.
      [methods, order, data]
    end
561741
def rank(self, member):
        
        score = self._members.get(member)
        if score is None:
            return None
        return bisect_left(self._scores, (score, member))
1056086
protected function rules() {
        return [
            new Rule('Order ID Exists', function(array $subject) {
                $response   = SubjectReader::readResponse($subject);
                $orderId    = $response['message']['trackId'];
                $order      = $this->orderFactory->create()->loadByIncrementId($orderId);

                return ! $order->isEmpty();
            }, __('Checkout.com track ID is not matching to any orders.') ),
        ];
    }
250088
protected double[] weightedMax(Instance inst) {
		int countFired = 0;
		boolean fired = false;
		double highest = 0.0;
		double[] votes = new double[this.numClass];
		ArrayList<Double> ruleSetVotes = new ArrayList<Double>();
		ArrayList<ArrayList<Double>> majorityProb = new ArrayList<ArrayList<Double>>();
		for (int j = 0; j < this.ruleSet.size(); j++) {
			ArrayList<Double> ruleProb = new ArrayList<Double>();
			if (this.ruleSet.get(j).ruleEvaluate(inst) == true) {
				countFired = countFired+1;
				for (int z = 0; z < this.numClass; z++) {
					ruleSetVotes.add(this.ruleSet.get(j).obserClassDistrib.getValue(z) / this.ruleSet.get(j).obserClassDistrib.sumOfValues());
		    	    ruleProb.add(this.ruleSet.get(j).obserClassDistrib.getValue(z) / this.ruleSet.get(j).obserClassDistrib.sumOfValues());
		    	    }
				majorityProb.add(ruleProb);
				}
			}
		if (countFired > 0) {
			fired = true;
			Collections.sort(ruleSetVotes); 
		    highest = ruleSetVotes.get(ruleSetVotes.size() - 1);
		    for (int t = 0; t < majorityProb.size(); t++) {
				 for(int m = 0; m < majorityProb.get(t).size(); m++) {
					 if (majorityProb.get(t).get(m) == highest) {
						 for (int h = 0; h < majorityProb.get(t).size(); h++) {
							 votes[h] = majorityProb.get(t).get(h);
							 }
						 break;
						 }
					 }
				 }
		    } else {
		    	fired = false;
		    	}
		if (fired == false) {
			votes = oberversDistribProb(inst, this.observedClassDistribution);
			}
		return votes;
		}
316548
def compute_rewards(self, scores):
        
        # get the k + 1 best scores in descending order
        best_scores = sorted(scores, reverse=True)[:self.k + 1]
        velocities = [best_scores[i] - best_scores[i + 1]
                      for i in range(len(best_scores) - 1)]

        # pad the list out with zeros to maintain the length of the list
        zeros = (len(scores) - self.k) * [0]
        return velocities + zeros
1355430
public double[] getAllPairsScores() {
		double[] scores = new double[scorers.size()];
		int n = 0;
		for (PairwiseSequenceScorer<S, C> scorer : scorers) {
			scores[n++] = scorer.getScore();
		}
		return scores;
	}
265807
def compute_rewards(self, scores):
        """"""
        if len(scores) > self.k:
            scores = np.copy(scores)
            inds = np.argsort(scores)[:-self.k]
            scores[inds] = np.nan

        return list(scores)
1861
function TieBreaker(oldRes, posAry, limit, opts) {
  if (!(this instanceof TieBreaker)) {
    return new TieBreaker(oldRes, posAry, limit, opts);
  }
  this._opts = TieBreaker.defaults(opts);
  var invReason = TieBreaker.invalid(oldRes, posAry, this._opts, limit);
  if (invReason !== null) {
    this._opts.log.error('Invalid %d player TieBreaker with oldRes=%j rejected, opts=%j',
      limit, oldRes, this._opts
    );
    throw new Error('Cannot construct TieBreaker: ' + invReason);
  }

  var xs = createMatches(posAry, limit, this._opts);
  var ms = [];
  if (this._opts.grouped) {
    for (var i = 0; i < xs.length; i += 1) {
      for (var j = 0; j < xs[i].matches.length; j += 1) {
        var m = xs[i].matches[j];
        // NB: modifying the matches here so that outside world sees the section
        // corr. to the section they came from - whereas gs inst needs s === 1
        ms.push({
          id: new Id(xs[i].tbSection, m.id.r, m.id.m),
          p: m.p.slice()
        });
      }
    }
    this.groupStages = xs;
  }
  else {
    ms = xs;
  }

  Base.call(this, oldRes.length, ms);
  this.name = 'TieBreaker';
  this.grouped = this._opts.grouped;
  this.strict = this._opts.strict;
  this.posAry = posAry;
  this.limit = limit;
  this.oldRes = oldRes;
  this.numSections = posAry.length;
  this.sectionSize = $.flatten(posAry[0]).length;
  this.betweenPosition = Math.ceil(this.limit / this.numSections);

  // Demote player positions until we are done

  // Demotion must unfortunately happen here, and not in previous tourneys results.
  // This is because demotion will change depending on what limits we choose.
  // While this means if we bypass TB we may end up forwarding unfairly (perhaps
  // more players from one group than another), TB is here to fix it, so use it.
  var pls = this.players(); // the players that are actually in matches here
  this.numPlayers = pls.length; // override this.numPlayers set via Base.call(this)
  var playersGuaranteed = oldRes.filter(function (r) {
    return pls.indexOf(r.seed) < 0 && r.pos <= limit;
  }).length;
  oldRes.forEach(function (r) {
    if (pls.indexOf(r.seed) >= 0) {
      r.pos = pls.length + playersGuaranteed;
    }
  });
}
93362
def cliques(self, reordered = True):
        
        if reordered:
            return [list(self.snrowidx[self.sncolptr[k]:self.sncolptr[k+1]]) for k in range(self.Nsn)]
        else:
            return [list(self.__p[self.snrowidx[self.sncolptr[k]:self.sncolptr[k+1]]]) for k in range(self.Nsn)]
1115224
protected int[] score_decide(Chunk chks[], int nnids[]) {
    int [] res = nnids.clone();
    for( int row=0; row<nnids.length; row++ ) { // Over all rows
      int nid = nnids[row];          // Get Node to decide from
      if( isDecidedRow(nid)) {               // already done
        res[row] -= _leaf;
        continue;
      }
      // Score row against current decisions & assign new split
      boolean oob = isOOBRow(nid);
      if( oob ) nid = oob2Nid(nid); // sampled away - we track the position in the tree
      DTree.DecidedNode dn = _tree.decided(nid);
      if( dn._split == null ) { // Might have a leftover non-split
        if( DTree.isRootNode(dn) ) { res[row] = nid - _leaf; continue; }
        nid = dn._pid;             // Use the parent split decision then
        int xnid = oob ? nid2Oob(nid) : nid;
        nnids[row] = xnid;
        res[row] = xnid - _leaf;
        dn = _tree.decided(nid); // Parent steers us
      }
      assert !isDecidedRow(nid);
      nid = dn.getChildNodeID(chks,row); // Move down the tree 1 level
      if( !isDecidedRow(nid) ) {
        if( oob ) nid = nid2Oob(nid); // Re-apply OOB encoding
        nnids[row] = nid;
      }
      res[row] = nid-_leaf;
    }
    return res;
  }
1016272
def tie_breaks=(tie_breaks)
      raise "argument error - always set tie breaks to an array" unless tie_breaks.class == Array
      @tie_breaks = tie_breaks.map do |str|
        tb = ICU::TieBreak.identify(str)
        raise "invalid tie break method '#{str}'" unless tb
        tb.id
      end
    end
1031984
private void breakTies(List<InvPair> v) {
        Iterator<InvPair> it = v.iterator();
        InvPair curr;
        InvPair last = null;
        int tie = 0;
        boolean found = false;
        for (int x = 0; it.hasNext(); x++) {
            curr = it.next();
            curr.setCurr(curr.getCurr() * 2);
            curr.setPrime();
            if (x != 0 && !found && curr.getCurr() == last.getCurr()) {
                tie = x - 1;
                found = true;
            }
            last = curr;
        }
        curr = (InvPair) v.get(tie);
        curr.setCurr(curr.getCurr() - 1);
        curr.setPrime();
    }
983438
def get_sort_order(molecules):
    

    neg_count = 0
    pos_count = 0

    for index in range(len(molecules)):

        scoreList = molecules[index].GetProp('scores')
        for element in scoreList:
            if float(element) > 0:
                pos_count += 1
            elif float(element) < 0:
                neg_count += 1

    if pos_count > neg_count:
        sort_order = 'dsc'
    else:
        sort_order = 'asc'

    return sort_order
690017
def _argsort_and_resolve_ties(time, random_state):
        """"""
        n_samples = len(time)
        order = numpy.argsort(time, kind="mergesort")

        i = 0
        while i < n_samples - 1:
            inext = i + 1
            while inext < n_samples and time[order[i]] == time[order[inext]]:
                inext += 1

            if i + 1 != inext:
                # resolve ties randomly
                random_state.shuffle(order[i:inext])
            i = inext
        return order
282523
public static final <T extends Comparable<T>> Ordering<Scored<T>> ByScoreThenByItem() {
    final Ordering<Scored<T>> byItem = Scoreds.<T>ByItemOnly();
    final Ordering<Scored<T>> byScore = Scoreds.<T>ByScoreOnly();

    return Ordering.compound(ImmutableList.of(byScore, byItem));
  }
585974
protected function makeResult () : array
    {
        $result = [];
        $alreadyDone = [];

        $rang = 1;
        while (count($alreadyDone) < $this->_selfElection->countCandidates()) :
            $winners = $this->getWinners($alreadyDone);

            foreach ($this->_Arcs as $ArcKey => $Arcvalue) :
                foreach ($winners as $oneWinner) :
                    if ($Arcvalue['from'] === $oneWinner || $Arcvalue['to'] === $oneWinner ) :
                        unset($this->_Arcs[$ArcKey]);
                    endif;
                endforeach;
            endforeach;

            $result[$rang++] = $winners;
            $alreadyDone = array_merge($alreadyDone,$winners);
        endwhile;

        return $result;
    }
1330436
def rank_queries(molecules, ensemble, sort_order, options):
    

    # generate query list
    query_list = [x for x in list(molecules[0].scores.keys()) if x not in ensemble]

    results = {}

    for query in query_list:
        es = EnsembleStorage() # an ensemble storage project

        # generate test_ensemble
        test_ensemble = ensemble[0:]
        test_ensemble.append(query)
        test_ensemble = tuple(test_ensemble)
        es.set_prop('ensemble', test_ensemble)

        # calculate its performance
        score_structure = classification.make_score_structure(molecules, test_ensemble)

        # determine auc value
        auc_structure = classification.make_auc_structure(score_structure)
        auc = classification.calculate_auc(auc_structure, sort_order, 'no stats')
        es.set_prop('auc', auc)

        # if the enrichment factor was set to anything other than 1, then we're training to maximize the corresponding
        # enrichment factor
        for fpf in classification.make_fpfList(options, score_structure):
            fpf = float(fpf)
            ef_structure = classification.make_ef_structure(score_structure, fpf, sort_order)
            if ef_structure:
                ef = classification.calculate_ef(ef_structure, fpf)
                es.set_prop(ef[0], ef[1], 'ef')

        # append results to metric list
        results[test_ensemble] = es

    # peel away the best performing ensemble
    best_ensemble = screener.find_best_ensemble(results, options)

    return list(best_ensemble)