Operators and selection¶
These items were open on the DEAP tracker, or were defects inherited from the original sources.
mut_polynomial_boundedclamps each gene into[low, up]before the Deb powers and requireseta > 0, so an out-of-box gene no longer writes NaN or a complex value.cx_simulated_binary_boundeduses the same clamp andetaguard. Out-of-box parents no longer raiseTypeErroron complex arithmetic. The second child uses the opposite sign of \(\beta_q\), matching Deb / DEAP (c2is the upper child, not a second lower child).cx_blend_boundedis the boxed form of blend crossover: the same \(\gamma\) draw ascx_blend, then a clamp on each child gene.cx_partially_matched, uniform PMX, andcx_orderedmap alleles by value. Permutations of named cities or other non-{0..n-1}encodings no longer IndexError or silently write the wrong genes.mut_heterogeneousapplies one mutator per gene, so a mixed encoding (bit + int range + choice) does not need a one-off mutator.cx_heterogeneousis the matching mate dispatcher: one callable per gene, or one existingcx_*per slice.assign_crowding_distcan crowd onwvaluesviause_weights=True. The default, andsel_nsga_2, still use rawvalues.sel_tournament_dcdaccepts any1 ≤ k ≤ len(individuals). Whenkis a multiple of 4 the original paired-shuffle path is used; other counts run pairwise contests untilkwinners are collected.k ≤ 0returns an empty list.sel_rouletteandsel_stochastic_universal_samplingspin the wheel onwvalues[0]. A negative floor is shifted so a minimization weight still has a positive slice. When every slice is zero the draw is uniform instead of an empty list. An empty pool orsel_count ≤ 0returns[].mig_ringevicts by object identity. Two individuals with equal genes are no longer treated as the same slot. Emigrants are cloned when a replacement operator is set, so the source deme is not aliased into the destination. Duplicate draws take the next unused index instead of writing one vacancy twice.cx_messy_one_pointcuts each parent independently, so lengths can change. Equal-length parents no longer degenerate into a shared-interval two-point swap.- Sequence crossovers copy slices before assignment. NumPy views
are not aliased, so a one-point or uniform swap does not destroy
a parent.
cx_es_two_point_copyapplies the same copy to the strategy vector. sel_spea_2uses the full distance row for density, with the self-distance set to infinity, so the \(k\)-th neighbour is not the zero pad of the upper triangle. An empty pool returns[].sel_nsga_3intercepts on the success path are \(1/x + \mathrm{best}\). Association treats a near-zero \(\mathrm{intercepts} - \mathrm{best}\) gap as \(1\) so the niche distance is not NaN. Niching stops when the last front is exhausted, so a \(k\) larger than the pool does not loop forever.cx_one_point,cx_two_point,cx_ordered, andmut_shuffle_indexesno-op when a parent is shorter than two genes, so a length-1 individual no longer hits an emptyrandintinterval or a two-cutsampleon a one-gene permutation.broadcast_paramtreatsnumbers.Integralandnumbers.Realas scalars, so a NumPy integer orfloat32/float16bound no longer raisesTypeErrorfromlen()on a NumPy scalar.sel_lexicaseandsel_epsilon_lexicaseacceptcases=to filter on a per-generation subset of fitness indices. Defaults still use every case.sample_informed_casesbuilds that subset by farthest-first traversal of Hamming distances between case solve vectors, so synonymous cases are not over-sampled.fitness_case_matrixpacksfitness.valuesinto a dense matrix; optionalmatrix=andtrust_matrix=let lexicase and informed down-sampling reuse one pack per generation.sel_sms_emoareduces a pool by non-dominated sorting, then removes the least hypervolume contributor on the critical front until the quota is met. Optionalref_pointfollows the same minimization-space convention ashypervolumeandleast_contrib. Works onparents + offspringor steady-stateparents + [child].sel_moeadandSelMOEADWithMemorypick one winner per decomposition weight fromuniform_reference_points, using Tchebycheff or PBI scalarization with Pareto-rank-aware tie breaks and NSGA-II-style crowding on the fill pass.sel_age_moea_2andSelAGE2WithMemoryadvance front by front: geodesic diversity on partial \(F_1\), inverse Minkowski on later partial fronts, with Newton–Raphson curvature on the first front.mut_gaussian_boundedapplies the same \(N(\mu, \sigma)\) draw asmut_gaussian, then clamps each mutated gene into[low, up]. Bounds may be scalars or per-gene sequences, matchingmut_polynomial_bounded. Empty intervals are skipped.mut_dewrites a DE/rand/1/bin trial in place: \(a_i + F(b_i - c_i)\) on a binomial gene subset (cx_prob, at least one gene). Optionallow/upclamp the written genes. Selection stays on the caller. DEAP only has this loop in examples.constraint_dominatesis Deb's feasibility-first comparison: feasible beats infeasible; two feasibles use ordinary Pareto; two infeasibles prefer the smaller constraint violation.sel_nsga_2accepts optionalfeasible=/violation=callables and ranks with that rule. Defaults stay unconstrained NSGA-II. Fitness values are not rewritten.sel_teamassemblessel_countindividuals by greedy maximum coverage of cases solved at 0. Optionalcases=,matrix=, andtrust_matrix=match lexicase. The team is a sequence of pool members; member fitness is not rewritten. Team scoring stays on the caller.sel_team_archivepools occupied MAP-Elites cells vialist(archive)and delegates tosel_team. DEAP has no team selector.CaseExamandCaseExamPoolstore case subsets as ranges or a 1-D bool mask — the same shapescase_errorsandsel_lexicase(..., cases=)consume — not as a new genome.score_case_examsranks exams on elites by unsolved count or Hamming distance from the all-solved vector (solved ≡ \(0\)).mut_case_ranges/mut_case_maskvary bounds or flip mask runs;guard_case_examsblocks the empty exam and the all-solved collapse.next_lexicase_casesreturns the mutated or guarded winner as the nextcases=list.informed=True(the default) is a guard repair path only — it does not overwrite a healthy exam. Chronological splits stay on the caller.mig_ringpairs source emigrants with dest vacancies by length, and stops claiming slots once a deme is full. Unequal island sizes, orsel_randomwithklarger than a deme, no longerIndexErrororStopIteration. An unreplaced home vacancy clones the leftover emigrant so two demes do not share one object.sel_bestandsel_worstreturn[]whensel_count <= 0. A negative count is no longer a Python slice that drops individuals from the other end of the ranked list.mig_ringclones an emigrant that is already present in the destination, so a selector that returns the same object twice does not write that object into two dest slots.sel_spea_2returns[]whensel_count <= 0. A negative count no longer enters archive truncation andIndexErrors on an empty list. Matchessel_nsga_2andsel_best.cx_partially_matchedno-ops when a parent is shorter than two genes. Empty permutations no longer hitrandint(0, -1).broadcast_paramtreats a 0-dndarrayas a scalar, sonumpy.array(0.0)bounds no longer raiseTypeErrorfromlen()on an unsized object.policy_held_out_fitnessscores policy individuals only on a caller-markedheld_outexam.guard_policy_fitness_examrefuses train exams or a freshly mutated exam as the objective. Train quality stays inpolicy_exam_scores/policy_observe;record_policy_generalization_gaplogs train, held-out, and gap as ageneralization_gapLogbook chapter (Push GP P13).PolicyActionGuardandguard_policy_actionenforce hard caps onapply_policy_action: max promotes per generation, promote cooldown, max innertunegenerations, minimum exam size, and rejection when an action would exceed remainingn_evals. Rejected actions returnPolicyActionResult(rejected=True)without raising — the observation surface forlast_action_rejected. DEAP has no policy action firewall (Push GP P14).sel_noveltyranks a pool by average distance to theknearest archive behavior descriptors viasemantic_distance. Fitness stays onind.fitness; novelty is the selection key. An empty archive falls back tosel_random.mut_iso_lineinterpolates toward a donor elite witht ~ Uniform(-iso, 1 + iso)and adds isotropic noise;iso_line_float,iso_line_int, andiso_line_bitcompose throughmut_heterogeneouson mixed genomes.ea_map_elitesregisters both like any otherselect/mutate;random_elitesstays the parent source. DEAP has no novelty selector or archive-aware iso+line mutator. See the MAP-Elites example.mig_fully_connectedandmig_randomsit next tomig_ring. Fully connected selects emigrants once per source, clones them along each outgoing edge, and claims distinct destination vacancies across incoming edges; random picks one destination per source.island_eval_keyshashes each deme'sCaseExam— catalog subsets via a painted mask so mask and range storage match — and optional matrix identity forstep_islands(..., eval_keys=). Custom graphs staymig_ring(..., mig_indices=). DEAP has no named topologies. See the multiprocessing tutorial.sel_batch_epsilon_lexicaseshuffles active cases into batches of at mostbatch_size, reduces each batch (mean squared error by default), and runs epsilon-lexicase on the shorter matrix. A fresh partition is drawn per selected individual. Optionalreduction=overrides the batch aggregate.matrix=/trust_matrix=/cases=match lexicase.sel_tournament_casesscores individuals on a case subset (column mean by default), then tournaments on those scalars. Informed down-sampling stays onsample_informed_cases;case_count=draws a random subset whencasesis omitted. DEAP has no batch epsilon-lexicase or case-subset tournament. See the columnar GP tutorial.sel_epsilon_lexicaseacceptsmode=on the vectorized filter:epsilon_auto/epsilon_static(population MAD and elite),epsilon_semi(population MAD, pool elite), andepsilon_dynamic(pool MAD and elite).next_downsample_casesreturns the nextcases=list each generation withmode=random,informed,cohort, orheld_out(rotate through a caller-marked held-out exam). Chronological meaning stays on the caller. DEAP has no filter-pool epsilon modes or generation downsample schedule. See the columnar GP tutorial.mut_iso_linetreats NumPy integer genes as integers. Anumpy.int64gene no longer takes the float path and writes a non-integer value.sel_randomreturns[]when the pool is empty. A positivesel_countno longerIndexErrors onrng.choice([]).sel_double_tournamentreturns[]when the pool is empty orrounds <= 0. It no longerValueErrors onmax([])aftersel_randomstarted returning an empty draw.