Jump to content

Featured Replies

Posted
(defun prob-mutation (alist blist &key (factor 1) (prob-list nil))
    (loop for a in alist
          for b in blist
          for x in (if (null prob-list) 
                       (cumulative-sums (gen-repeat (length alist) (float (/ factor (length alist)))))
                     prob-list)
          when (probp x)
          collect b else collect a))

;;; with linear prob-incf
(prob-mutation (gen-repeat 100 1) (gen-repeat 100 2))
=> (1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 2 2 1 1 1 1 2 2 1 2 2 2 1 1 1 1 1 2 1 1 1 1 1 2 2 1 1 2 2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 1 1 1 1 2 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2)

;;; with an external prob-list 0 to 1.0 to 0
(setf half-sine (filter-first 100 (gen-sine 200 1 1.0)))
(prob-mutation (gen-repeat 100 1) (gen-repeat 100 2) :prob-list half-sine)
=> (1 1 1 1 1 1 1 1 1 2 2 1 1 2 2 1 2 1 2 1 1 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 1 1 1 2 2 2 2 2 2 2 1 1 2 1 2 1 2 1 1 2 1 1 2 1 1 1 2 1 1)

;;; with an external prob-list 0 to 0.3 to 0
(setf half-sine (filter-first 100 (gen-sine 200 1 0.3)))
(prob-mutation (gen-repeat 100 1) (gen-repeat 100 2) :prob-list half-sine)
=> (1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 2 1 1 1 1 1 2 1 2 1 1 2 1 2 1 2 1 1 1 2 1 1 1 2 1 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 2 1 2 1 1 1 1 1 2 1 1 2 2 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1)


 

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy