diff --git a/rs-tests.rkt b/rs-tests.rkt index f827539..f2fdb93 100644 --- a/rs-tests.rkt +++ b/rs-tests.rkt @@ -32,7 +32,8 @@ [rs (make-immutable-hash (list (cons 'a r1) (cons 'b r2)))] [dyn (dynamics rs)] [state1 (state (set) (list (set 'x) (set 'y) (set 'z) (set) (set 'z)))] - [sgr (dds-build-state-graph-annotated dyn (set state1))]) + [sgr (dds-build-state-graph-annotated dyn (set state1))] + [ip (build-interactive-process rs (list (set 'x) (set 'y) (set 'z) (set) (set 'z)))]) (check-equal? (dds-step-one-annotated dyn state1) (set (cons (set 'a 'b) @@ -70,4 +71,6 @@ (check-equal? (edge-weight sgr (state (set) (list (set 'x) (set 'y) (set 'z) (set) (set 'z))) (state (set 'y 'z) (list (set 'y) (set 'z) (set) (set 'z)))) - (set (set 'a 'b))))) + (set (set 'a 'b))) + + (check-equal? sgr ip))) diff --git a/rs.rkt b/rs.rkt index 3bd66e3..ac04a48 100644 --- a/rs.rkt +++ b/rs.rkt @@ -25,7 +25,8 @@ [dds-build-state-graph (-> dynamics? (set/c state? #:kind 'dont-care) graph?)] [dds-build-n-step-state-graph (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)] [dds-build-state-graph-annotated (-> dynamics? (set/c state? #:kind 'dont-care) graph?)] - [dds-build-n-step-state-graph-annotated (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)]) + [dds-build-n-step-state-graph-annotated (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)] + [build-interactive-process (-> reaction-system/c (listof (set/c species?)) graph?)]) ;; Predicates (contract-out [species? (-> any/c boolean?)]) ;; Contracts @@ -162,3 +163,11 @@ (apply-rs-annotate (set-union res ctx) rest-ctx)] [(state res '()) (apply-rs-annotate res '())])))]) + +;;; Builds the state graph of a reaction system driven by a given +;;; context sequence. When the context sequence is exhausted, keeps +;;; running the system without contexts. In other words, the context +;;; sequence is padded with empty contexts at the end. +(define (build-interactive-process rs contexts) + (dds-build-state-graph-annotated (dynamics rs) + (set (state (set) contexts))))