|
@@ -42,12 +42,25 @@
|
|
|
"Return a random generate tree without being evaluated."
|
|
|
(make-individual :tree (ramped-half-and-half tree-limit fset tset)))
|
|
|
|
|
|
-(defun make-population (size tree-limit fset tset)
|
|
|
- "Return an array filled with random gp individuals."
|
|
|
- (make-array size
|
|
|
- :initial-contents (loop repeat size
|
|
|
- collect (make-random-individual tree-limit fset tset))))
|
|
|
+(defparameter *initial-population* '())
|
|
|
+
|
|
|
+(defun set-initial-population (individuals)
|
|
|
+ "Sets the initial gp population to given list of individuals."
|
|
|
+ (when (listp individuals)
|
|
|
+ (setf *initial-population*
|
|
|
+ (remove-if-not #'individual-p individuals))))
|
|
|
|
|
|
+(defun make-population (size tree-limit fset tset)
|
|
|
+ "Return an array filled with gp individuals - using *initial-population* and
|
|
|
+ filling remaining positions with random gp individuals."
|
|
|
+ (make-array
|
|
|
+ size
|
|
|
+ :initial-contents
|
|
|
+ (if (< (length *initial-population*) size)
|
|
|
+ (append *initial-population*
|
|
|
+ (loop repeat (- size (length *initial-population*))
|
|
|
+ collect (make-random-individual tree-limit fset tset)))
|
|
|
+ (subseq *initial-population* 0 size))))
|
|
|
|
|
|
;;;
|
|
|
;;; evaluation
|