(asdf:oos 'asdf:load-op 'ltk) (asdf:oos 'asdf:load-op 'cgn) (use-package :ltk) (use-package :cgn) (defun hello-1 () (with-ltk () (let* ( (el (make-instance 'labelframe :text "Configuration")) (r (make-instance 'frame :width 100 :borderwidth 1)) (lamb (make-instance 'scale :label "LAMBDA" :from 1 :to 10 :master el :orientation 'horizontal)) (n (make-instance 'scale :label "N" :from 1 :to 10 :master el :orientation 'horizontal)) (f (make-instance 'scale :label "FValue" :from .01 :to .25 :master el :orientation 'horizontal :resolution .01)) (lr (make-instance 'scale :label "LRCap" :master el :from 50 :to 250 :resolution 25 :orientation 'horizontal)) (button (make-instance 'button :master r :text "Generate" :command #'(lambda () (evett (value lamb) (value n) (value f) (value lr)))))) (pack el :side :top) (pack n :side :left) (pack lamb :side :left) (pack f :side :left) (pack lr :side :left) (pack button) (pack r :side :bottom) (wm-title el "Evett") ))) (defun evett (lamb n f lr) (let* ((p-values #(.25 .22 .14 .14 .069 .064 .033 .033 .022 .02 .013)) (s-values #(.728 .166 .065 .018 .018 .006)) (path (make-pathname :name "tmp.dat")) (str (open path :direction :output :if-exists :supersede))) (format str "#LAMBDA ~A N ~A LR~%" #\Tab #\Tab) (dotimes (x lamb) (dotimes (y n) (format str "~A ~A ~A ~A ~A~%" (+ 1 x) #\Tab (+ 1 y) #\Tab (min lr (+ (/ (* (elt p-values 0) (calculate-t (+ 1 x) (+ 2 y))) (* (elt p-values 1) (elt s-values (+ 1 y)) f)) (calculate-t (+ 1 x) 0)))))) (close str) (with-gnuplot ('linux) (set-grid 'on) (format-gnuplot "set dgrid3d") (format-gnuplot "splot 'tmp.dat' with linespoints")))) (defun n! (n) (if (or (= n 0) (= n 1)) 1 (* n (n! (- n 1))))) (defun calculate-t (lamb j) (/ (* (exp (- lamb)) (expt lamb j)) (n! j)))