Commit 3d1c148a authored by pfdietz's avatar pfdietz

Change the distribution of sizes when producing random partitions.

parent 75514be2
......@@ -74,6 +74,8 @@
(defvar *maximum-random-int-bits* 45)
(defvar *random-vals-list-bound* 20)
(defvar *max-compile-time* 0)
(defvar *max-compile-term* nil)
......@@ -137,7 +139,7 @@
)
(make-random-integer-form size)))
(vals-list
(loop repeat 20
(loop repeat *random-vals-list-bound*
collect
(mapcar #'(lambda (range)
(let ((lo (car range))
......@@ -153,6 +155,7 @@
:decls1 ,opt-decls-1
:decls2 ,opt-decls-2
:form ,form))
(finish-output)
;; (cl-user::gc)
)
(test-int-form form vars var-types vals-list opt-decls-1 opt-decls-2)))
......@@ -732,12 +735,32 @@
(defun random-partition (n p)
"Partition n into p numbers, each >= 1. Return list of numbers."
(assert (<= 1 p))
#|
(cond
((= p 1) (list n))
((< n p) (make-list p :initial-element 1))
(t
(let ((n1 (1+ (random (floor n p)))))
(cons n1 (random-partition (- n n1) (1- p)))))))
|#
(cond
((= p 1) (list n))
((= n 0) (make-list p :initial-element 0))
(t (let* ((r (random p))
(n1 (random (1+ n))))
(cond
((= r 0)
(cons n1 (random-partition (- n n1) (1- p))))
((= r (1- p))
(append (random-partition (- n n1) (1- p)) (list n1)))
(t
(let* ((n2 (random (1+ (- n n1))))
(n3 (- n n1 n2)))
(append (random-partition n2 r)
(list n1)
(random-partition n3 (- p 1 r))))))))))
(defun make-optimized-lambda-form (form vars var-types opt-decls)
`(lambda ,vars
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment