Systems Thoughts

Try to think everything systematically

Archive for the ‘SPiM’ Category

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.1

let 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))

process_on_pressure.JPG

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…

Comments (0) Posted on Wednesday, March 5th, 2008

This is a log for my thesis study on Stochastic Pi-Calculus Machine (SPiM).

Here is a sample code for implementing hill-type equation in SPiM:

directive sample 10.0 1000
directive plot sender();receiver()
directive graph
new comm@1.0:chan(float)
let sender(n:float) = (
!comm(n);
sender(n/2.0)
)
and receiver() = (
do delay@1.0; receiver()
or ?comm(n); delay@n
)
run (sender(1.0)|500 of receiver())

You will get a curve looks like this:

hill-type1.jpg

The receiver()’s degrade time is controlled by n which becomes half fold every stochastic time period. For more complex equations I think you can modify sender() and pass your private channel for communication though the parameters. Then the result will not be seen by any other processes, hopefully:). But I haven’t test it yet.

Comments (1) Posted on Tuesday, February 26th, 2008