Get a Condorcet certified loser. If there is none = null. You can force a winner choice with alternative supported methods ($substitution)
494989
public function getLoser () : ?int
    {
        // Cache
        if ( $this->_CondorcetLoser !== null ) :
            return $this->_CondorcetLoser;
        endif;

            //////

        // Basic Condorcet calculation
        foreach ( $this->_selfElection->getPairwise(false) as $candidate_key => $candidat_detail ) :
            $loser = true;

            foreach ( $candidat_detail['lose'] as $challenger_key => $lose_count ) :
                if  ( $lose_count <= $candidat_detail['win'][$challenger_key] ) :
                    $loser = false;
                    break;
                endif;
            endforeach;

            if ($loser) :
                $this->_CondorcetLoser = $candidate_key;
                return $this->_CondorcetLoser;
            endif;
        endforeach;

        return null;
    }
145357
function selectWithoutValidation(choices) {
	// Generate a list of options with positive non-zero chances
	let choicesWithNonZeroChances = [];
	let totalWeight = 0.0;
	for(let i = 0; i < choices.length; i++) {
		if(choices[i].chance > 0.0) {
			choicesWithNonZeroChances.push(choices[i]);
			totalWeight += choices[i].chance;
		}
	}

	// Pick a random value from [0,1)
	let value = Math.random() * totalWeight;

	// Iterate over possibilities until we find the selected one
	let chanceCovered = 0.0;
	for(let i = 0; i < choicesWithNonZeroChances.length; i++) {
		chanceCovered += choicesWithNonZeroChances[i].chance;
		if(value < chanceCovered) {
			return choicesWithNonZeroChances[i].result;
		}
	}
}
596968
def evaluate(grid):
    ""
    if is_won(grid): return -1
    succs = successors(grid)
    return -min(map(evaluate, succs)) if succs else 0
692653
def objective(self, params):
        """"""
        val = self._penalty * np.sum(params**2)
        for winner, losers in self._data:
            idx = np.append(winner, losers)
            val += logsumexp(params.take(idx) - params[winner])
        return val
1085344
def coombstoc_winners(self, profile):
        
        ordering = profile.getOrderVectors()
        m = profile.numCands
        prefcounts = profile.getPreferenceCounts()
        rankmaps = profile.getRankMaps()
        if min(ordering[0]) == 0:
            startstate = set(range(m))
        else:
            startstate = set(range(1, m + 1))
        known_winners = set()
        # half = math.floor(n / 2.0)
        # ----------Some statistics--------------
        hashtable2 = set()

        # push the node of start state into the priority queue
        root = Node(value=startstate)
        stackNode = []
        stackNode.append(root)

        while stackNode:
            # ------------pop the current node----------------
            node = stackNode.pop()
            # -------------------------------------------------
            state = node.value.copy()
            # use heuristic to delete all the candidates which satisfy the following condition

            # goal state 1: if the state set contains only 1 candidate, then stop
            if len(state) == 1 and list(state)[0] not in known_winners:
                known_winners.add(list(state)[0])
                continue
            # goal state 2 (pruning): if the state set is subset of the known_winners set, then stop
            if state <= known_winners:
                continue
            # ----------Compute plurality score for the current remaining candidates-------------
            reverse_veto_score = self.get_reverse_veto_scores2(prefcounts, rankmaps, state)
            # print("reverse_veto_score = ",reverse_veto_score)

            # if current state satisfies one of the 3 goal state, continue to the next loop

            # After using heuristics, generate children and push them into priority queue
            # frontier = [val for val in known_winners if val in state] + list(set(state) - set(known_winners))

            maxscore = max(reverse_veto_score.values())
            for to_be_deleted in state:
                if reverse_veto_score[to_be_deleted] == maxscore:
                    child_state = state.copy()
                    child_state.remove(to_be_deleted)
                    tpc = tuple(sorted(child_state))
                    if tpc in hashtable2:
                        continue
                    else:
                        hashtable2.add(tpc)
                        child_node = Node(value=child_state)
                        stackNode.append(child_node)
        return sorted(known_winners)
1072336
def get_generator(self, field):
        '''
        
        '''
        if isinstance(field, fields.AutoField):
            return None
        if self.is_inheritance_parent(field):
            return None
        if (
            field.default is not fields.NOT_PROVIDED and
            not self.overwrite_defaults and
            field.name not in self.field_values):
                return None
        kwargs = {}

        if field.name in self.field_values:
            value = self.field_values[field.name]
            if isinstance(value, generators.Generator):
                return value
            elif isinstance(value, AutoFixture):
                return generators.InstanceGenerator(autofixture=value)
            elif callable(value):
                return generators.CallableGenerator(value=value)
            return generators.StaticGenerator(value=value)

        if field.null:
            kwargs['empty_p'] = self.none_p
        if field.choices:
            return generators.ChoicesGenerator(choices=field.choices, **kwargs)
        if isinstance(field, related.ForeignKey):
            # if generate_fk is set, follow_fk is ignored.
            is_self_fk = (get_remote_field_to(field)().__class__ == self.model)
            if field.name in self.generate_fk and not is_self_fk:
                return generators.InstanceGenerator(
                    autofixture.get(
                        get_remote_field_to(field),
                        follow_fk=self.follow_fk.get_deep_links(field.name),
                        generate_fk=self.generate_fk.get_deep_links(field.name)),
                    limit_choices_to=get_remote_field(field).limit_choices_to)
            if field.name in self.follow_fk:
                selected = generators.InstanceSelector(
                    get_remote_field_to(field),
                    limit_choices_to=get_remote_field(field).limit_choices_to)
                if selected.get_value() is not None:
                    return selected
            if field.blank or field.null:
                return generators.NoneGenerator()
            if is_self_fk and not field.null:
                raise CreateInstanceError(
                    u'Cannot resolve self referencing field "%s" to "%s" without null=True' % (
                        field.name,
                        '%s.%s' % (
                            get_remote_field_to(field)._meta.app_label,
                            get_remote_field_to(field)._meta.object_name,
                        )
                ))
            raise CreateInstanceError(
                u'Cannot resolve ForeignKey "%s" to "%s". Provide either '
                u'"follow_fk" or "generate_fk" parameters.' % (
                    field.name,
                    '%s.%s' % (
                        get_remote_field_to(field)._meta.app_label,
                        get_remote_field_to(field)._meta.object_name,
                    )
            ))
        if isinstance(field, related.ManyToManyField):
            if field.name in self.generate_m2m:
                min_count, max_count = self.generate_m2m[field.name]
                return generators.MultipleInstanceGenerator(
                    autofixture.get(get_remote_field_to(field)),
                    limit_choices_to=get_remote_field(field).limit_choices_to,
                    min_count=min_count,
                    max_count=max_count,
                    **kwargs)
            if field.name in self.follow_m2m:
                min_count, max_count = self.follow_m2m[field.name]
                return generators.InstanceSelector(
                    get_remote_field_to(field),
                    limit_choices_to=get_remote_field(field).limit_choices_to,
                    min_count=min_count,
                    max_count=max_count,
                    **kwargs)
            if field.blank or field.null:
                return generators.StaticGenerator([])
            raise CreateInstanceError(
                u'Cannot assign instances of "%s" to ManyToManyField "%s". '
                u'Provide either "follow_m2m" or "generate_m2m" argument.' % (
                    '%s.%s' % (
                        get_remote_field_to(field)._meta.app_label,
                        get_remote_field_to(field)._meta.object_name,
                    ),
                    field.name,
            ))
        if isinstance(field, fields.FilePathField):
            return generators.FilePathGenerator(
                path=field.path, match=field.match, recursive=field.recursive,
                max_length=field.max_length, **kwargs)
        if isinstance(field, fields.CharField):
            if isinstance(field, fields.SlugField):
                generator = generators.SlugGenerator
            elif isinstance(field, fields.EmailField):
                return generators.EmailGenerator(
                    max_length=min(field.max_length, 30))
            elif isinstance(field, fields.URLField):
                return generators.URLGenerator(
                    max_length=min(field.max_length, 25))
            elif field.max_length > 15:
                return generators.LoremSentenceGenerator(
                    common=False,
                    max_length=field.max_length)
            else:
                generator = generators.StringGenerator
            return generator(max_length=field.max_length)
        if isinstance(field, fields.DecimalField):
            return generators.DecimalGenerator(
                decimal_places=field.decimal_places,
                max_digits=field.max_digits)
        if hasattr(fields, 'BigIntegerField'):
            if isinstance(field, fields.BigIntegerField):
                return generators.IntegerGenerator(
                    min_value=-field.MAX_BIGINT - 1,
                    max_value=field.MAX_BIGINT,
                    **kwargs)
        if isinstance(field, ImageField):
            return generators.ImageGenerator(storage=field.storage, **kwargs)
        for field_class, generator in self.field_to_generator.items():
            if isinstance(field, field_class):
                return generator(**kwargs)
        return None
1183731
def get_alternatives(self, rank):
        
        if self.ranks_to_alts is None:
            raise ValueError("Aggregate ranking must be created first")
        try:
            alts = self.ranks_to_alts[rank]
            return alts
        except KeyError:
            raise KeyError("No ranking \"{}\" found in ".format(str(rank)) +
                           "the aggregate ranking")
612126
def get_choice(value):
    """"""
    if value is None:
        return 'null'
    for attr in ['__name__', 'name']:
        if hasattr(value, attr):
            return getattr(value, attr)
    return str(value)
1198456
protected function rejectInvalidBallots(): int
    {
        foreach ($this->ballots as $i => $ballot) {
            if (!$this->checkBallotValidity($ballot)) {
                $this->rejectedBallots[] = clone $ballot;
                unset($this->ballots[$i]);
            }
        }

        $count = count($this->rejectedBallots);

        $this->logger->notice("Found $count rejected ballots");

        $this->validBallots = $this->validBallots - $count;

        return $count;
    }
143517
def get_market_losers(*args, **kwargs):
    
    import warnings
    warnings.warn(WNG_MSG, ("get_market_losers", "stocks.get_market_losers"))
    return stocks.get_market_losers(*args, **kwargs)
473083
def set_experiment_winner(experiment):
    """"""
    redis = _get_redis_connection()
    experiment = Experiment.find(redis, experiment)
    if experiment:
        alternative_name = request.form.get('alternative')
        alternative = Alternative(redis, alternative_name, experiment.name)
        if alternative.name in experiment.alternative_names:
            experiment.winner = alternative.name
    return redirect(url_for('.index'))
123699
private function getQualityFactor($locale, $option)
    {
        if (isset($option[1]))
            return (float) str_replace('q=', '', $option[1]);

        // Assign default low weight for generic values
        if ($locale === '*/*')
            return 0.01;

        if (substr($locale, -1) === '*')
            return 0.02;

        return null;
    }
223817
private function getTrimMode()
    {
        if ($this->leading) {
            return AbstractPlatform::TRIM_LEADING;
        }

        if ($this->trailing) {
            return AbstractPlatform::TRIM_TRAILING;
        }

        if ($this->both) {
            return AbstractPlatform::TRIM_BOTH;
        }

        return AbstractPlatform::TRIM_UNSPECIFIED;
    }
950782
public T getDown() {
        if (navigator < 0) {// This is true when there are no elements.
            return null;
        }
        if ((wasFullAtleastOnce && navigator == size - 1) || 
                (!wasFullAtleastOnce && navigator == emptyItemIndex - 1)) {
            try {
                return (T)(items[navigator]);
            } finally {
                navigator = 0;
            }
        }
        return (T)(items[navigator++]);
    }
1082434
def get(self, robj, r=None, pr=None, timeout=None, basic_quorum=None,
            notfound_ok=None, head_only=False):
        
        raise NotImplementedError
259229
def optional(e, default=Ignore):
    
    def match_optional(s, grm=None, pos=0):
        try:
            return e(s, grm, pos)
        except PegreError:
            return PegreResult(s, default, (pos, pos))
    return match_optional
660621
public function getWinner()
    {
        if (!$this->isGameOver()) {
            return null;
        }

        if ($this->getScore(self::PLAYER_0) === $this->getScore(self::PLAYER_1)) {
            return self::DRAW;
        } elseif ($this->getScore(self::PLAYER_0) > $this->getScore(self::PLAYER_1)) {
            return self::PLAYER_0;
        } else {
            return self::PLAYER_1;
        }
    }