Type list-syntactic-interactions.

This commit is contained in:
Sergiu Ivanov 2022-05-09 10:54:53 +02:00
parent 893b375b91
commit 0018c91fb6
2 changed files with 38 additions and 29 deletions

View file

@ -22,6 +22,8 @@
network-form->network/any network-form->network/boolean network-form->network/any network-form->network/boolean
network-form->network/01 make-boolean-network-form network-form->network/01 make-boolean-network-form
forms->boolean-network forms->boolean-network
list-syntactic-interactions
) )
(define-type (State a) (VariableMapping a)) (define-type (State a) (VariableMapping a))
@ -238,6 +240,20 @@
'b '(not b)))) 'b '(not b))))
(check-equal? (network-domains n) (hash 'a '(#f #t) (check-equal? (network-domains n) (hash 'a '(#f #t)
'b '(#f #t))))) 'b '(#f #t)))))
(: list-syntactic-interactions
(All (a) (-> (NetworkForm a) Variable (Listof Variable))))
(define (list-syntactic-interactions nf x)
(set-intersect
(extract-symbols (hash-ref (network-form-forms nf) x))
(hash-keys (network-form-forms nf))))
(module+ test
(test-case "list-syntactic-interactions"
(define n (make-boolean-network-form #hash((a . (+ a b c))
(b . (- b c)))))
(check-true (set=? (list-syntactic-interactions n 'a) '(a b)))
(check-true (set=? (list-syntactic-interactions n 'b) '(b)))))
) )
(require 'typed) (require 'typed)
@ -254,8 +270,7 @@
[struct dynamics ([network network?] [struct dynamics ([network network?]
[mode mode?])]) [mode mode?])])
;; Functions ;; Functions
(contract-out [list-syntactic-interactions (-> network-form? variable? (listof variable?))] (contract-out [build-syntactic-interaction-graph (-> network-form? graph?)]
[build-syntactic-interaction-graph (-> network-form? graph?)]
[interaction? (-> network? variable? variable? boolean?)] [interaction? (-> network? variable? variable? boolean?)]
[get-interaction-sign (-> network? variable? variable? (or/c #f -1 0 1))] [get-interaction-sign (-> network? variable? variable? (or/c #f -1 0 1))]
[build-interaction-graph (-> network? graph?)] [build-interaction-graph (-> network? graph?)]
@ -405,34 +420,7 @@
;;; Inferring interaction graphs ;;; Inferring interaction graphs
;;; ============================ ;;; ============================
;;; In this section I provide inference of both unsigned and signed
;;; interaction graphs, but since the inference of signed interaction
;;; graphs is based on analysing the dynamics of the networks, it may
;;; be quite resource-consuming, especially since I allow any
;;; syntactic forms in the definitions of the functions.
;;;
;;; Note the fine difference between syntactic interaction graphs and
;;; interaction graphs generated from the dynamics of the network.
;;; The syntactic interaction graphs are based on the whether
;;; a variable appears or not in the form of the function for another
;;; variable. On the other hand, the normal, conventional interaction
;;; graph records the fact that one variable has an impact on the
;;; dynamics of the other variable. Depending on the model, these may
;;; or may not be the same.
;;; Lists the variables of the network form appearing in the update
;;; function form for x.
(define (list-syntactic-interactions nf x)
(set-intersect
(extract-symbols (hash-ref (network-form-forms nf) x))
(hash-keys (network-form-forms nf))))
(module+ test
(test-case "list-syntactic-interactions"
(define n (make-boolean-network-form #hash((a . (+ a b c))
(b . (- b c)))))
(check-true (set=? (list-syntactic-interactions n 'a) '(a b)))
(check-true (set=? (list-syntactic-interactions n 'b) '(b)))))
;;; Builds the graph in which the vertices are the variables of a ;;; Builds the graph in which the vertices are the variables of a
;;; given network, and which contains an arrow from a to b whenever a ;;; given network, and which contains an arrow from a to b whenever a

View file

@ -346,6 +346,27 @@ a change in the value of @tt{y}. Thus the syntactic interaction graph may have
extra arcs if @tt{x} appears in the form of @tt{y}, but has no actual influence extra arcs if @tt{x} appears in the form of @tt{y}, but has no actual influence
on @tt{y}. on @tt{y}.
@defproc[(list-syntactic-interactions [nf (NetworkForm a)]
[x Variable])
(Listof Variable)]{
Lists the variables of the network form appearing in the update function form
for @racket[x].
The variables which are not part of the network are excluded from the listing.
@ex[
(list-syntactic-interactions
(make-boolean-network-form #hash((a . (+ a b))
(b . (- b))))
'a)
(list-syntactic-interactions
(make-boolean-network-form #hash((a . (+ a b c))
(b . (- b c))))
'a)
]}
@section{Dynamics of networks} @section{Dynamics of networks}
This section contains definitions for building and analysing the dynamics This section contains definitions for building and analysing the dynamics