# clojush.pushgp.selection.novelty

### assign-novelty-to-individual

`(assign-novelty-to-individual individual behavior-sparseness)`

Calculates the novelty of the individual based on the behaviors in the population and in the novelty-archive. Returns the individual with the :novelty key set, and if :novelty is a meta-error-category, also sets that.

### behavioral-distance

`(behavioral-distance behavior1 behavior2 {:keys [novelty-distance-metric], :as argmap})`

Takes two behavior vectors and finds the distance between them. Differences in vectors are based on the data type(s) they contain. Distance metric is based on the arg :novelty-distance-metric. Note that there is no limit on behavior differences, which will only be limited by their max bounds based on things like maximum integer size.

### calculate-behavior-distance-map

`(calculate-behavior-distance-map distinct-pop-behaviors distinct-pop-and-archive-behaviors argmap)`

Calculates a map storing the distances between any two behaviors, of the form: {behavior1 {behavior1 dist11 behavior2 dist12 behavior3 dist13 …} behavior2 {behavior1 dist21 behavior22 dist2 behavior3 dist23 …} …} Note: Only has outer-level keys for population behaviors, not archive behaviors. But, has inner-level keys for both population and archive behaviors.

### calculate-behavior-sparseness

`(calculate-behavior-sparseness pop-and-archive-behaviors behavior-distance-map {:keys [novelty-number-of-neighbors-k]})`

Calculates the sparseness/novelty of an individual by averaging together the distances between it and its k nearest neighbors. First, it must look up those distances using the behavior-distance-map.

### calculate-novelty

`(calculate-novelty pop-agents novelty-archive {:keys [use-single-thread], :as argmap})`

Calculates novelty for each individual in the population with respect to the rest of the population and the novelty-archive. Sets novelty to meta-error if necessary.

### novelty-tournament-selection

`(novelty-tournament-selection pop {:keys [tournament-size], :as argmap})`

Returns an individual that does the best out of a tournament based on novelty.

### select-individuals-for-novelty-archive

`(select-individuals-for-novelty-archive population argmap)`

Returns a number of individuals to be added to the novelty archive. Number of indviduals are :individuals-for-novelty-archive-per-generation.