2023-03-26 23:29:51 +02:00
|
|
|
#lang scribble/manual
|
|
|
|
@(require scribble/example racket/sandbox
|
|
|
|
(for-label typed/racket/base
|
2023-03-27 23:23:34 +02:00
|
|
|
(submod "../tbn.rkt" typed)
|
2023-03-26 23:29:51 +02:00
|
|
|
"../networks.rkt"
|
|
|
|
"../utils.rkt"
|
|
|
|
"../functions.rkt"
|
|
|
|
"../dynamics.rkt"))
|
|
|
|
|
|
|
|
@(define tbn-evaluator
|
|
|
|
(parameterize ([sandbox-output 'string]
|
|
|
|
[sandbox-error-output 'string]
|
|
|
|
[sandbox-memory-limit 50])
|
2023-03-27 23:23:34 +02:00
|
|
|
(make-evaluator 'typed/racket #:requires '((submod "tbn.rkt" typed)))))
|
2023-03-26 23:29:51 +02:00
|
|
|
|
|
|
|
@(define-syntax-rule (ex . args)
|
|
|
|
(examples #:eval tbn-evaluator . args))
|
|
|
|
|
|
|
|
@(define-syntax-rule (deftypeform . args)
|
|
|
|
(defform #:kind "type" . args))
|
|
|
|
|
|
|
|
@(define-syntax-rule (deftype . args)
|
|
|
|
(defidform #:kind "type" . args))
|
|
|
|
|
|
|
|
@title[#:tag "tbn"]{dds/tbn: Threshold and Sign Boolean Networks (TBN and SBN)}
|
|
|
|
|
2023-03-27 23:23:34 +02:00
|
|
|
@defmodule[(submod dds/tbn typed)]
|
2023-03-26 23:29:51 +02:00
|
|
|
|
|
|
|
This module defines threshold Boolean networks (TBN), as well as sign
|
|
|
|
Boolean networks (SBN). The update functions in such networks are
|
|
|
|
respectively @seclink["tbf" #:doc '(lib
|
|
|
|
"dds/scribblings/dds.scrbl")]{threshold Boolean functions} and sign
|
|
|
|
Boolean functions.
|
2023-03-27 23:23:34 +02:00
|
|
|
|
|
|
|
@defproc[(apply-tbf-to-state [a-tbf TBF] [st (State (U Zero One))])
|
|
|
|
(U Zero One)]{
|
|
|
|
|
|
|
|
Applies a TBF to a state.
|
|
|
|
|
|
|
|
The values of the variables of the state are ordered by
|
|
|
|
@racket[hash-map] and fed to the TBF in order. The number of the
|
|
|
|
inputs of the TBF must match the number of variables in the state.
|
|
|
|
|
|
|
|
@ex[
|
|
|
|
(require "functions.rkt")
|
|
|
|
(apply-tbf-to-state (tbf #(1 1) 1) (hash 'x1 0 'x2 1))
|
|
|
|
]}
|
2023-03-29 01:16:12 +02:00
|
|
|
|
|
|
|
@defstruct*[tbf/state ([weights (VariableMapping Real)]
|
|
|
|
[threshold Real])]{
|
|
|
|
|
|
|
|
A state TBF is a @racket[TBF] with named inputs. A state TBF can be
|
|
|
|
applied to states in an unambiguous ways.
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@deftype[TBF/State]{
|
|
|
|
|
|
|
|
The type of the instances of @racket[tbf/state].
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@deftogether[(@defproc[(tbf/state-w [tbfs TBF/State]) (VariableMapping Real)]
|
|
|
|
@defproc[(tbf/state-θ [tbfs TBF/State]) Real])]{
|
|
|
|
|
|
|
|
Shorter synonyms for field accessors of @racket[tbf/state].
|
|
|
|
|
|
|
|
@ex[
|
|
|
|
(let ([tbfs (tbf/state (hash 'a 1 'b 1) 1)])
|
|
|
|
(values (tbf/state-w tbfs)
|
|
|
|
(tbf/state-θ tbfs)))
|
|
|
|
]}
|