returns the sublist of individuals with valid fitness.
189062
def valid(self,individuals=None,F=None):
        """"""
        if F:
            valid_locs = self.valid_loc(F)
        else:
            valid_locs = self.valid_loc(self.F)

        if individuals:
            return [ind for i,ind in enumerate(individuals) if i in valid_locs]
        else:
            return [ind for i,ind in enumerate(self.pop.individuals) if i in valid_locs]
418112
def matchSubset(**kwargs):
        """"""
        ret = []
        for m in self.matches:
            allMatched = True
            for k,v in iteritems(kwargs):
                mVal = getattr(m, k)
                try:
                    if v == mVal or v in mVal: continue # this check passed
                except Exception: pass # if attempting to check __contains__ and exception is raised, it's assumed to be false
                allMatched = False
                break
            if allMatched: ret.append(m)
        return ret
70924
def lexicase(self,F, num_selections=None, survival = False):
        """"""
        if num_selections is None:
            num_selections = F.shape[0]
        winners = []
        locs = []

        individual_locs = np.arange(F.shape[0])
                
        for i in np.arange(num_selections):
            can_locs = individual_locs
            cases = list(np.arange(F.shape[1]))
            self.random_state.shuffle(cases)
            # pdb.set_trace()
            while len(cases) > 0 and len(can_locs) > 1:
                # get best fitness for case among candidates
                best_val_for_case = np.min(F[can_locs,cases[0]])
                # filter individuals without an elite fitness on this case
                can_locs = [l for l in can_locs if F[l,cases[0]] <= best_val_for_case ]
                cases.pop(0)

            choice = self.random_state.randint(len(can_locs))
            locs.append(can_locs[choice])
            if survival: # filter out winners from remaining selection pool
                individual_locs = [i for i in individual_locs if i != can_locs[choice]]

        while len(locs) < num_selections:
            locs.append(individual_locs[0])

        return locs
688904
def valid_targets(self):
        
        exclude_list = [self.pk]
        for p in self.get_descendants():
            exclude_list.append(p.id)
        return Page.objects.exclude(id__in=exclude_list)
766647
def descendants(self):
        
        return self.members + \
            [submember for member in self.members for submember in member.descendants]
577208
def get_average_cross_validation_fitness(self): # pragma: no cover
        """"""
        avg_cross_validation_fitness = []
        for stats in self.generation_cross_validation_statistics:
            scores = []
            for fitness in stats.values():
                scores.extend(fitness)
            avg_cross_validation_fitness.append(mean(scores))

        return avg_cross_validation_fitness
1078339
def _get_candidates(self):
        
        candidates = np.where(self.dpp_vector == 0)
        return None if len(candidates[0]) == 0 else candidates[0]
650011
def get_fitness(self, chromosome):
        
        fitness = self.fitness_cache.get(chromosome.dna)

        if fitness is None:
            fitness = self.eval_fitness(chromosome)
            self.fitness_cache[chromosome.dna] = fitness

        return fitness
298339
def get_list_subtasks(self, list_id, completed=False):
        '''  '''
        return subtasks_endpoint.get_list_subtasks(self, list_id, completed=completed)
102552
def fitness(self, width, height):
        
        assert(width > 0 and height >0)
        if width > max(self.width, self.height) or\
            height > max(self.height, self.width):
            return None

        # If there is room in wasted space, FREE PACKING!!
        if self._waste_management:
            if self._waste.fitness(width, height) is not None:
                return 0

        # Get best fitness segment, for normal rectangle, and for
        # rotated rectangle if rotation is enabled.
        rect, fitness = self._select_position(width, height)
        return fitness
865845
def _effective_perm_list_from_iter(self, perm_iter):
        """"""
        highest_perm_str = self._highest_perm_from_iter(perm_iter)
        return (
            self._equal_or_lower_perm_list(highest_perm_str)
            if highest_perm_str is not None
            else None
        )
998684
def effective_groups
      ret = [ self ]
      memberships.each do |m|
        unless ret.include?(m)  # prevent infinite recursion
          tmp = m.effective_groups
          tmp.each do |g|
            ret << g unless ret.include?(g)
          end
        end
      end
      ret.sort{|a,b| a.name <=> b.name}
    end
600879
public void fitness(List<S> solutionSet, int pos) {
    double fitness = 0.0;
    double kappa = 0.05;

    for (int i = 0; i < solutionSet.size(); i++) {
      if (i != pos) {
        fitness += Math.exp((-1 * indicatorValues.get(i).get(pos) / maxIndicatorValue) / kappa);
      }
    }
    solutionFitness.setAttribute(solutionSet.get(pos), fitness);
  }
849672
def calc_fitness(self,X,labels,fit_choice,sel):
        

        if 'lexicase' in sel:
            # return list(map(lambda yhat: self.f_vec[fit_choice](labels,yhat),X))
            return np.asarray(
                              [self.proper(self.f_vec[fit_choice](labels,
                                                        yhat)) for yhat in X],
                                                        order='F')
            # return list(Parallel(n_jobs=-1)(delayed(self.f_vec[fit_choice])(labels,yhat) for yhat in X))
        else:
            # return list(map(lambda yhat: self.f[fit_choice](labels,yhat),X))
            return np.asarray([self.f[fit_choice](labels,yhat) for yhat in X],
                            order='F').reshape(-1)
780187
def get_members_in_state(self, state):
        """"""
        members = self.run_command(command='replSetGetStatus', is_eval=False)['members']
        return [member['name'] for member in members if member['state'] == state]
821335
def evaluator(self, candidates, args):
        """"""
        fitness = []
        if self._use_ants:
            for candidate in candidates:
                total = 0
                for c in candidate:
                    total += self.weights[c.element[0]][c.element[1]]
                last = (candidate[-1].element[1], candidate[0].element[0])
                total += self.weights[last[0]][last[1]]
                fitness.append(1 / total)
        else:
            for candidate in candidates:
                total = 0
                for src, dst in zip(candidate, candidate[1:] + [candidate[0]]):
                    total += self.weights[src][dst]
                fitness.append(1 / total)
        return fitness
1216280
def infer_list_subtype(items):
        """"""
        subtype = End

        for item in items:
            item_type = type(item)
            if not issubclass(item_type, Base):
                continue

            if subtype is End:
                subtype = item_type
                if not issubclass(subtype, List):
                    return subtype
            elif subtype is not item_type:
                stype, itype = subtype, item_type
                generic = List
                while issubclass(stype, List) and issubclass(itype, List):
                    stype, itype = stype.subtype, itype.subtype
                    generic = List[generic]

                if stype is End:
                    subtype = item_type
                elif itype is not End:
                    return generic.subtype
        return subtype