This is a log for my thesis study on Stochastic Pi-Calculus Machine (SPiM).
One thing that disturbs me a lot is there is no global variable in SPiM. My method is to define a process that broadcast a value on some global channel all the time, so any other processes can inquire this value by simply monitor the output on this channel. Another process can be used to modify this global value by sending a specific parameter on that broadcast process to trigger the switch inside.
My experimental codes:
(* Global Value *)
directive sample 1000.0 1000
directive plot A();B()new pressure@1.0:chan(float)
new keep@1.0:chan(float)
new change_keep@1.0:chan(float)
val step = 1.0
val re1=1.0
val re2=0.1let A() = (
do delay@re1; (B()|Press(step))
or ?keep(n); delay@re1/n; (B()|Press(step))
)and B() = (
delay@re2; (A()|Press((-1.0)*step))
)and Press(p:float) = (
?keep(current_p);!change_keep(current_p+p)
)and keeper(n:float) = (
if n > 0.0
then
(do !keep(n);keeper(n)
or ?change_keep(current_p);keeper(current_p)
)
else
keeper(1.0)
)run (100 of A()|50 of B()|keeper(1.0))
The only problem for now is some processes seemed missing, therefore could not provide a control over the A() production based on pressure changes… Still working on it…