rename csys to asys (asynchronous actor systems
This commit is contained in:
parent
fbf735c0f2
commit
f86428a2c7
5 changed files with 50 additions and 34 deletions
|
@ -1,15 +1,15 @@
|
||||||
;;;; decons/csys - cybernetic communication systems
|
;;;; decons/asys - asynchronous actor systems
|
||||||
|
|
||||||
(defpackage :decons/csys
|
(defpackage :decons/asys
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:actor :scopes/core/actor)
|
(:local-nicknames (:actor :scopes/core/actor)
|
||||||
(:util :scopes/util))
|
(:util :scopes/util))
|
||||||
(:export #:neuron #:synapse
|
(:export #:neuron #:synapse
|
||||||
#:forward
|
#:forward #:cumulate
|
||||||
#:set-content
|
#:set-content
|
||||||
#:inhibit))
|
#:inhibit))
|
||||||
|
|
||||||
(in-package :decons/csys)
|
(in-package :decons/asys)
|
||||||
|
|
||||||
(defun neuron (proc &key state syns env)
|
(defun neuron (proc &key state syns env)
|
||||||
(actor:create
|
(actor:create
|
||||||
|
@ -22,9 +22,16 @@
|
||||||
;;;; simple default / example neuron processors
|
;;;; simple default / example neuron processors
|
||||||
|
|
||||||
(defun forward (msg state syns env)
|
(defun forward (msg state syns env)
|
||||||
|
(format t "*** forward ~a ~a~%" msg state)
|
||||||
(dolist (s syns)
|
(dolist (s syns)
|
||||||
(funcall s msg)))
|
(funcall s msg)))
|
||||||
|
|
||||||
|
(defun cumulate (msg state syns env)
|
||||||
|
(setf state (+ state msg))
|
||||||
|
(if (/= 0 state)
|
||||||
|
(forward state state syns env))
|
||||||
|
(lambda (msg) (cumulate msg state syns env)))
|
||||||
|
|
||||||
;;;; publish/subscribe - pubsub service
|
;;;; publish/subscribe - pubsub service
|
||||||
|
|
||||||
;;;; helpers for operations on complex messages (with content and customer slots)
|
;;;; helpers for operations on complex messages (with content and customer slots)
|
|
@ -5,10 +5,10 @@
|
||||||
:license "MIT"
|
:license "MIT"
|
||||||
:version "0.0.1"
|
:version "0.0.1"
|
||||||
:homepage "https://www.cyberconcepts.org"
|
:homepage "https://www.cyberconcepts.org"
|
||||||
:description "Deconstruction as a method for implementing machine intelligence."
|
:description "Deconstruction as a method for implementing machine un-intelligence."
|
||||||
:depends-on (:alexandria
|
:depends-on (:alexandria
|
||||||
:scopes-core :scopes/test)
|
:scopes-core :scopes/test)
|
||||||
:components ((:file "csys" :depends-on ("mlx"))
|
:components ((:file "asys" :depends-on ("mlx"))
|
||||||
(:file "mlx" :depends-on ("recurse"))
|
(:file "mlx" :depends-on ("recurse"))
|
||||||
(:file "recurse")
|
(:file "recurse")
|
||||||
(:file "xplore"))
|
(:file "xplore"))
|
||||||
|
@ -18,6 +18,6 @@
|
||||||
(defsystem :decons/test
|
(defsystem :decons/test
|
||||||
:depends-on (:decons)
|
:depends-on (:decons)
|
||||||
:components ((:file "test-decons")
|
:components ((:file "test-decons")
|
||||||
(:file "test-csys" :depends-on ("test-decons")))
|
(:file "test-asys" :depends-on ("test-decons")))
|
||||||
:perform (test-op (o c)
|
:perform (test-op (o c)
|
||||||
(symbol-call :decons/test-decons :run)))
|
(symbol-call :decons/test-decons :run)))
|
||||||
|
|
33
test-asys.lisp
Normal file
33
test-asys.lisp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
;;;; decons/test-asys - tests for the asys (asynchronous actor systems) package
|
||||||
|
|
||||||
|
(in-package :decons/test-decons)
|
||||||
|
|
||||||
|
(defun probe (msg state syns env)
|
||||||
|
(let ((t:*test-suite* env))
|
||||||
|
(== (actor:content msg) (pop state))
|
||||||
|
(lambda (msg) (probe msg state syns env))
|
||||||
|
))
|
||||||
|
|
||||||
|
(defun test-asys ()
|
||||||
|
(async:init)
|
||||||
|
(test-neuron-basics)
|
||||||
|
(async:finish))
|
||||||
|
|
||||||
|
(deftest test-neuron-basics ()
|
||||||
|
(let* ((prb (asys:neuron #'probe :env t:*test-suite* :state '(43 44 9 13)))
|
||||||
|
;(syn (asys:synapse prb (asys:set-content #'1+)))
|
||||||
|
(syn1 (asys:synapse prb #'1+))
|
||||||
|
;(syn (asys:synapse prb (asys:inhibit)))
|
||||||
|
(fw (asys:neuron #'asys:forward :syns (list syn1)))
|
||||||
|
(syn2 (asys:synapse fw #'1+))
|
||||||
|
(cum (asys:neuron #'asys:cumulate :state 0 :syns (list syn2))))
|
||||||
|
(actor:send fw 42)
|
||||||
|
(actor:send fw 43)
|
||||||
|
(actor:send cum 7)
|
||||||
|
(actor:send cum 4)
|
||||||
|
(sleep 0.1)
|
||||||
|
(actor:stop prb)
|
||||||
|
(actor:stop fw)
|
||||||
|
(actor:stop cum)
|
||||||
|
(sleep 0.1)
|
||||||
|
))
|
|
@ -1,25 +0,0 @@
|
||||||
;;;; decons/test-csys - tests for the csys (cybernetic ommunication systems) package
|
|
||||||
|
|
||||||
(in-package :decons/test-decons)
|
|
||||||
|
|
||||||
(defun probe (msg state syns env)
|
|
||||||
(let ((t:*test-suite* env))
|
|
||||||
(== (actor:content msg) (pop state))
|
|
||||||
(lambda (msg) (probe msg state syns env))
|
|
||||||
))
|
|
||||||
|
|
||||||
(defun test-csys ()
|
|
||||||
(test-neuron-basics))
|
|
||||||
|
|
||||||
(deftest test-neuron-basics ()
|
|
||||||
(let* ((prb (csys:neuron #'probe :env t:*test-suite* :state '(43 44)))
|
|
||||||
;(syn (csys:synapse prb (csys:set-content #'1+)))
|
|
||||||
(syn (csys:synapse prb #'1+))
|
|
||||||
;(syn (csys:synapse prb (csys:inhibit)))
|
|
||||||
(fw (csys:neuron #'csys:forward :syns (list syn))))
|
|
||||||
(actor:send fw 42)
|
|
||||||
(actor:send fw 43)
|
|
||||||
(sleep 0.1)
|
|
||||||
(actor:stop prb)
|
|
||||||
(actor:stop fw)
|
|
||||||
))
|
|
|
@ -3,7 +3,8 @@
|
||||||
(defpackage :decons/test-decons
|
(defpackage :decons/test-decons
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:actor :scopes/core/actor)
|
(:local-nicknames (:actor :scopes/core/actor)
|
||||||
(:csys :decons/csys)
|
(:async :scopes/util/async)
|
||||||
|
(:asys :decons/asys)
|
||||||
(:mlx :decons/mlx)
|
(:mlx :decons/mlx)
|
||||||
(:r :decons/recurse)
|
(:r :decons/recurse)
|
||||||
(:xplore :decons/xplore)
|
(:xplore :decons/xplore)
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
(test-recursive)
|
(test-recursive)
|
||||||
(test-line)
|
(test-line)
|
||||||
(test-quad)
|
(test-quad)
|
||||||
(test-csys)
|
(test-asys)
|
||||||
(t:show-result)))
|
(t:show-result)))
|
||||||
|
|
||||||
(deftest test-xplore ()
|
(deftest test-xplore ()
|
||||||
|
|
Loading…
Add table
Reference in a new issue