Skip to content

Commit

Permalink
Implement complementary mate selection for :bmx and :bmx-umad, activa…
Browse files Browse the repository at this point in the history
…ted via ':bmx-complementary true'
  • Loading branch information
lspector committed Dec 3, 2023
1 parent a0bd993 commit 2970632
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/propeller/variation.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,16 @@ The function `new-individual` returns a new individual produced by selection and
(:plushy (selection/select-parent pop argmap)))
;
:bmx ;; best match crossover
(let [plushy1 (:plushy (selection/select-parent pop argmap))
plushy2 (:plushy (selection/select-parent pop argmap))
(let [parent1 (selection/select-parent pop argmap)
parent2 (if (:bmx-complementary argmap)
(selection/select-parent
pop
(assoc argmap
:initial-cases
(reverse (:selection-cases parent1))))
(selection/select-parent pop argmap))
plushy1 (:plushy parent1)
plushy2 (:plushy parent2)
rate (utils/onenum (or (:bmx-rate argmap) 0.5))]
(bmx plushy1 plushy2 rate))
;
Expand All @@ -187,8 +195,16 @@ The function `new-individual` returns a new individual produced by selection and
;
:bmx-umad ;; applies umad to the results of bmx
(let [umad-rate (utils/onenum (:umad-rate argmap))]
(-> (let [plushy1 (:plushy (selection/select-parent pop argmap))
plushy2 (:plushy (selection/select-parent pop argmap))
(-> (let [parent1 (selection/select-parent pop argmap)
parent2 (if (:bmx-complementary argmap)
(selection/select-parent
pop
(assoc argmap
:initial-cases
(reverse (:selection-cases parent1))))
(selection/select-parent pop argmap))
plushy1 (:plushy parent1)
plushy2 (:plushy parent2)
bmx-rate (utils/onenum (or (:bmx-rate argmap) 0.5))]
(bmx plushy1 plushy2 bmx-rate))
(uniform-addition (:instructions argmap) umad-rate)
Expand Down

0 comments on commit 2970632

Please sign in to comment.