<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-28856939</id><updated>2011-10-23T13:45:03.674-06:00</updated><category term='graphics'/><category term='inference'/><category term='simulation'/><category term='Chebyshev'/><category term='statistics'/><category term='packed-binary'/><category term='schemelab'/><category term='animated-canvas'/><category term='science'/><category term='PLT Scheme'/><title type='text'>Doug Williams' Racket Projects Blog</title><subtitle type='html'>This blog is about my Racket (formerly PLT Scheme) projects, in particular, the Science Collection, Simulation Collection, and Inference Collection.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>26</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-28856939.post-8870180804260628578</id><published>2011-09-24T13:19:00.000-06:00</published><updated>2011-09-24T13:19:41.503-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><title type='text'>New Process Synchronization Mechanism in the Simulation Collection</title><content type='html'>I have added a new process synchronization / communication mechanism to the simulation collection - similar to the Ada rendezvous mechanism. This adds call and accept syntaxes that allow processes to communicate in a synchronized manner. The call syntax allows the caller process to send a request to the callee process. The call syntax has the form:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (&lt;b&gt;call&lt;/b&gt; &lt;i&gt;callee &lt;/i&gt;(id . &lt;i&gt;arguments&lt;/i&gt;))&lt;/div&gt;&lt;br /&gt;Where &lt;i&gt;callee &lt;/i&gt;&lt;callee&gt;&lt;i&gt; &lt;/i&gt;is the receiving process, id is the request type (which is not evaluated), and &lt;i&gt;arguments&lt;/i&gt; are the arguments for the request. With a simple call, the caller is blocked until the callee accepts the request.&lt;br /&gt;&lt;br /&gt;The accept syntax allows the callee process to accept a request from a caller process. The accept syntax has the form:&lt;/callee&gt;&lt;br /&gt;&lt;br /&gt;&lt;callee&gt;&amp;nbsp; (&lt;b&gt;accept &lt;/b&gt;&lt;i&gt;caller &lt;/i&gt;(id . &lt;i&gt;parameters&lt;/i&gt;) . &lt;i&gt;body&lt;/i&gt;)&lt;/callee&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;Where &lt;i&gt;caller &lt;/i&gt;is the calling process, id is the request type (which is not evaluated), &lt;i&gt;parameters &lt;/i&gt;are the formal parameters for the request, and &lt;i&gt;body&lt;/i&gt; is the body of the accept - i.e., the critical section. With a simple accept, the callee is blocked until a caller sends a matching request. When a matching request is accepted, a rendezvous occurs - that is the body is evaluated and its result returned to caller as the result of the matching call.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;Each process maintains a queue of requests that have yet to be accepted - where each caller is blocked.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;Even with simple call / accept we can implement a simple lock process.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(define-process (lock)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (let loop ()&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (accept caller (lock))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (accept caller (unlock))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (loop)))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;This process will continuously loop waiting for a process to request a lock and then wait for a process to request an unlock. Here is an example process that uses the lock.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(define-process (p1 i a-lock)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (printf "~a: process p1(~a) started.~n"&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (current-simulation-time) i)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (call a-lock (lock))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (printf "~a: process p1(~a) acquired lock.~n"&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (current-simulation-time) i)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (wait (random-flat 0.0 10.0))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (printf "~a: process p1(~a) releasing lock.~n"&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (current-simulation-time) i)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (call a-lock (unlock)))&lt;/span&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;This process just requests a lock - blocking until it gets it, waits a random length of time to simulate some protected task, and requests an unlock.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;And here is a main procedure to start everything.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(define (main n)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (with-new-simulation-environment&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (let ((a-lock (schedule #:now (lock))))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (for ((i (in-range n)))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (schedule #:at (random-flat 0.0 10.0) (p1 i a-lock)))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (start-simulation))))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;If you run this with:&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;(main 10)&lt;/callee&gt;&lt;/div&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;You get the following output:&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;0.13863292728449428: process p1(5) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;0.13863292728449428: process p1(5) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;1.1536616785362432: process p1(7) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;2.0751959904191937: process p1(8) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;2.876463473845367: process p1(1) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;3.344929657351545: process p1(4) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;7.029086638253653: process p1(5) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;7.029086638253653: process p1(7) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;7.342236104231587: process p1(2) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;7.824845469456133: process p1(9) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;7.921942925957062: process p1(6) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;8.162050798467028: process p1(3) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;8.574025375628212: process p1(0) started.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;8.624836102585753: process p1(7) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;8.624836102585753: process p1(8) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;16.152957766273808: process p1(8) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;16.152957766273808: process p1(1) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;18.243251499858758: process p1(1) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;18.243251499858758: process p1(4) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;22.293434873464157: process p1(4) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;22.293434873464157: process p1(2) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;27.693559748646905: process p1(2) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;27.693559748646905: process p1(9) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;32.4025230155617: process p1(9) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;32.4025230155617: process p1(6) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;39.54837751017477: process p1(6) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;39.54837751017477: process p1(3) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;39.86720234676685: process p1(3) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;39.86720234676685: process p1(0) acquired lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;44.316970186291684: process p1(0) releasing lock.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;However, this is a (very) fragile implementation of a lock relying on well-behaved callers.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;A more robust implementation of a lock requires greater control over the acceptance of requests. The select syntax - in this case for accepts - plus some internal state variables allows us to do this. The select (for accepts) syntax has the following form.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp; (&lt;b&gt;select&lt;/b&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; accept-alternative&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [else-alternative])&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp; accept-alternative &lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; = ((&lt;b&gt;when &lt;/b&gt;&lt;i&gt;expr&lt;/i&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;b&gt;accept &lt;/b&gt;&lt;i&gt;caller &lt;/i&gt;(id . &lt;i&gt;parameters&lt;/i&gt;) . &lt;i&gt;body1&lt;/i&gt;)&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; . &lt;i&gt;body2&lt;/i&gt;)&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; | ((&lt;b&gt;accept &lt;/b&gt;&lt;i&gt;caller &lt;/i&gt;(id . &lt;i&gt;parameters&lt;/i&gt;) . &lt;i&gt;body1&lt;/i&gt;)&lt;/span&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; . &lt;i&gt;body2&lt;/i&gt;)&lt;/span&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; else-alternative&lt;/span&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; = (&lt;b&gt;else &lt;/b&gt;timing . &lt;i&gt;body&lt;/i&gt;)&lt;/span&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; timing&lt;/span&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;= &lt;b&gt;#:now&lt;/b&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; | &lt;b&gt;#:at&lt;/b&gt; &lt;i&gt;time&lt;/i&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; | &lt;b&gt;#:in&lt;/b&gt; &lt;i&gt;delta&lt;/i&gt;&lt;/callee&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;callee&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; | &lt;b&gt;#:when&lt;/b&gt; &lt;i&gt;event&lt;/i&gt;&lt;/callee&gt;&lt;/div&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;Which looks a bit daunting, but basically it is a list of possibly guarded accepts with an optional else. The select will evaluate all of the guards - the when exprs - to determine the open accepts. Unguarded accepts are always open. If any request form an open accept are queued, the highest priority request is selected and a rendezvous occurs. The body2 expressions are evaluated after the rendezvous. The else alternative specified a time-out and is evaluated (in lieu of a rendezvous) if no request is accepted before the specified time.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;Here is a better implementation of a lock process.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(define-process (lock)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (let ((process #f)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (locked? #f))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (let loop ()&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((when (not locked?)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (accept caller (lock)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! process caller)))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! locked? #t))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((accept caller (unlock)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (unless (eq? caller process)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (error 'unlock&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "process does not have the lock"&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; caller)))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! process #f)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! locked? #f)))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (loop))))&lt;/span&gt;&lt;/callee&gt;&lt;br /&gt;&lt;br /&gt;&lt;callee&gt;This uses two variables, &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;process &lt;/span&gt;and &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;locked?&lt;/span&gt;, to maintain the internal state of the lock. The lock process continuously loops processing lock or unlock requests. A lock request will only be accepted if the lock is not currently locked. An unlock request will be accepted any time, but will raise an error if the process requesting the unlock is not the process that has the lock.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;Running this lock process with the process p1 and main above gives identical results.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;In some cases, we don't know if we can fully process a request until we get the request - because it depends on the caller or arguments in the request. What of we wanted to extent the lock to allow nested lock/unlock pairs from a process. In that case, we want to accept lock requests from the process owning the lock at any time, but not from others. There isn't any way to do that with a guard. Instead, we use requeue.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(define-process (lock)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (let ((process #f)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (count 0))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (let loop ()&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((accept caller (lock)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (if process&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (if (eq? caller process)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! count (+ count 1))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (requeue))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (begin&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! process caller)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! count 1)))))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((accept caller (unlock)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (if (eq? caller process)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (begin&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! count (- count 1))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (when (= count 0)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (set! process #f)))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (error 'unlock&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "process does not have the lock"&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; caller)))))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (loop))))&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;Here we have a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;count &lt;/span&gt;variable instead of a simple Boolean &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;locked?&lt;/span&gt; variable. - when &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;count &lt;/span&gt;= 0 the lock is open to anyone, but only open open to the process current 'owning' the lock when &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;count &lt;/span&gt;&amp;gt; 0. In this case, we remove the guard from the accept for lock and requeue the request if the caller is not the process currently owning the lock.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;I believe this is a very robust interprocess synchronization / communications mechanism for the simulation collection. I have a complete knowledge-based simulation example I will be putting up in the near future.&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;&lt;br /&gt;&lt;/callee&gt;&lt;br /&gt;&lt;callee&gt;This code (and many examples) are included in the development branch of the simulation collection on the Schematic project at Sourceforge. I will update the PLaneT package when I update the documentation.&lt;/callee&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-8870180804260628578?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/8870180804260628578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=8870180804260628578' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/8870180804260628578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/8870180804260628578'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2011/09/new-process-synchronization-mechanism.html' title='New Process Synchronization Mechanism in the Simulation Collection'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-1560110079394117771</id><published>2010-08-14T13:26:00.005-06:00</published><updated>2010-08-14T14:13:10.799-06:00</updated><title type='text'>Simple Simulation in Racket</title><content type='html'>I updated the simple simulation example from the simulation collection to Racket. The simple simulation example shows how a basic discrete-event simulation engine can be written in pure Racket (specifically, the racket/base language). Fully commented it is only about two and a half pages of code and does not contain any references to external packages. If you're curious about the usage of continuations, this might be a good example to look at. [If you're an expert in continuations, any critique would be welcome - particularly on the event loop in the &lt;span style="font-family: courier new;"&gt;start-simulation&lt;/span&gt; procedure.]&lt;br /&gt;&lt;br /&gt;The code uses parameters for its global variables, which may be unfamiliar to some people. For example, the simulation clock is maintained by the &lt;span style="font-family: courier new;"&gt;current-time&lt;/span&gt; parameter. This parameter is created by &lt;span style="font-family: courier new;"&gt;(make-parameter current-time 0.0)&lt;/span&gt;. A call to &lt;span style="font-family: courier new;"&gt;(current-time)&lt;/span&gt; will return its current value. The call &lt;span style="font-family: courier new;"&gt;(current-time (event-time (current-event)))&lt;/span&gt; in &lt;span style="font-family: courier new;"&gt;start-simulation&lt;/span&gt; sets its value to the time of the next event. Finally, the &lt;span style="font-family: courier new;"&gt;parameterize&lt;/span&gt; call in &lt;span style="font-family: courier new;"&gt;run-simulation&lt;/span&gt; creates new instances of the parameters and (I think) is cleaner than just resetting their values.&lt;br /&gt;&lt;br /&gt;And, here is the actual code.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#lang racket/base&lt;br /&gt;;;; Simplified Simulation System&lt;br /&gt;&lt;br /&gt;;;; Global simulation control variables&lt;br /&gt;&lt;br /&gt;;;; future-event-list : (parameter/c (list? event?))&lt;br /&gt;;;; current-time : (parameter/c real?)&lt;br /&gt;;;; current-event : (parameter/c (or/c false/c event?))&lt;br /&gt;;;; event-loop-exit : (parameter/c (or/c false/c continuation?))&lt;br /&gt;;;; event-loop-next : (parameter/c (or/c false/c continuation?))&lt;br /&gt;(define future-event-list (make-parameter '()))&lt;br /&gt;(define current-time (make-parameter 0.0))&lt;br /&gt;(define current-event (make-parameter #f))&lt;br /&gt;(define event-loop-exit (make-parameter #f))&lt;br /&gt;(define event-loop-next (make-parameter #f))&lt;br /&gt;&lt;br /&gt;;;; Event definition and scheduling&lt;br /&gt;&lt;br /&gt;;;; (struct event (time function arguments))&lt;br /&gt;;;;   time : (&gt;=/c 0.0)&lt;br /&gt;;;;   function : (or/c false/c procedure?)&lt;br /&gt;;;;   arguments : list?&lt;br /&gt;;;; Each event has a time the event is to be executed, the function to&lt;br /&gt;;;; be executed, and the (evaluated) arguments to the function.&lt;br /&gt;(struct event (time function arguments))&lt;br /&gt;&lt;br /&gt;;;; (schedule event) -&gt; any&lt;br /&gt;;;;   event : event?&lt;br /&gt;;;; Add an event to the event list.&lt;br /&gt;(define (schedule event)&lt;br /&gt; (future-event-list (event-schedule event (future-event-list))))&lt;br /&gt;&lt;br /&gt;;;; (event-schedule event event-list) -&gt; (list-of event?)&lt;br /&gt;;;;   event : event?&lt;br /&gt;;;;   event-list : (list-of event?)&lt;br /&gt;;;; Return a new list of events corresponding to the given event added&lt;br /&gt;;;; to the given list of events.&lt;br /&gt;(define (event-schedule event event-list)&lt;br /&gt; (cond ((null? event-list)&lt;br /&gt;        (list event))&lt;br /&gt;       ((&lt; (event-time event)&lt;br /&gt;           (event-time (car event-list)))&lt;br /&gt;        (cons event event-list))&lt;br /&gt;       (else&lt;br /&gt;        (cons (car event-list)&lt;br /&gt;              (event-schedule event (cdr event-list))))))&lt;br /&gt;;;; Simulation control routines&lt;br /&gt;&lt;br /&gt;;;; (wait/work delay) -&gt; any&lt;br /&gt;;;;   delay : (&gt;=/c 0.0)&lt;br /&gt;;;; Simulate the delay while work is being done.  Add an event to&lt;br /&gt;;;; execute the current continuation to the event list.&lt;br /&gt;(define (wait/work delay)&lt;br /&gt; (let/cc continue&lt;br /&gt;   ;; Add an event to execute the current continuation&lt;br /&gt;   (schedule (event (+ (current-time) delay) continue '()))&lt;br /&gt;   ;; Return to the main loop&lt;br /&gt;   ((event-loop-next))))&lt;br /&gt;&lt;br /&gt;;;; (start-simulation) -&gt; any&lt;br /&gt;;;; This is the main simulation loop.  As long as there are events to&lt;br /&gt;;;; be executed (or until the simulation is explicitly stopped), remove&lt;br /&gt;;;; the next event from the event list, advance the clock to the time&lt;br /&gt;;;; of the event, and apply the event's functions to its arguments.&lt;br /&gt;(define (start-simulation)&lt;br /&gt; (let/ec exit&lt;br /&gt;   ;; Save the event loop exit continuation&lt;br /&gt;   (event-loop-exit exit)&lt;br /&gt;   ;; Event loop&lt;br /&gt;   (let loop ()&lt;br /&gt;     ;; Exit if no more events&lt;br /&gt;     (when (null? (future-event-list))&lt;br /&gt;       ((event-loop-exit)))&lt;br /&gt;     (let/cc next&lt;br /&gt;       ;; Save the event loop next continuation&lt;br /&gt;       (event-loop-next next)&lt;br /&gt;       ;; Execute the next event&lt;br /&gt;       (current-event (car (future-event-list)))&lt;br /&gt;       (future-event-list (cdr (future-event-list)))&lt;br /&gt;       (current-time (event-time (current-event)))&lt;br /&gt;       (apply (event-function (current-event))&lt;br /&gt;              (event-arguments (current-event))))&lt;br /&gt;     (loop))))&lt;br /&gt;&lt;br /&gt;;;; (stop-simulation) -&gt; any&lt;br /&gt;;;; Stop the execution of the current simulation (by jumping to its&lt;br /&gt;;;; exit continuation).&lt;br /&gt;(define (stop-simulation)&lt;br /&gt; ((event-loop-exit)))&lt;br /&gt;&lt;br /&gt;;;; Random Distributions (to remove external dependencies)&lt;br /&gt;&lt;br /&gt;;;; (random-flat a b) -&gt; inexact-real?&lt;br /&gt;;;;   a : real?&lt;br /&gt;;;;   b : real?&lt;br /&gt;;;; Returns a random real number from a uniform distribution between a&lt;br /&gt;;;; and b.&lt;br /&gt;(define (random-flat a b)&lt;br /&gt; (+ a (* (random) (- b a))))&lt;br /&gt;&lt;br /&gt;;;; (random-exponential mu) -&gt; inexact-real?&lt;br /&gt;;;;   mu : real?&lt;br /&gt;;;; Returns a random real number from an exponential distribution with&lt;br /&gt;;;; mean mu.&lt;br /&gt;(define (random-exponential mu)&lt;br /&gt; (* (- mu) (log (random))))&lt;br /&gt;&lt;br /&gt;;;; Example Simulation Model&lt;br /&gt;&lt;br /&gt;;;; (generator n) -&gt; any&lt;br /&gt;;;;   n : exact-positive-integer?&lt;br /&gt;;;; Process to generate n customers arriving into the system.&lt;br /&gt;(define (generator n)&lt;br /&gt; (do ((i 0 (+ i 1)))&lt;br /&gt;     ((= i n) (void))&lt;br /&gt;   (wait/work (random-exponential 4.0))&lt;br /&gt;   (schedule (event (current-time) customer (list i)))))&lt;br /&gt;&lt;br /&gt;;;; (customer i) -&gt; any&lt;br /&gt;;;;   i : exact-nonnegative-integer?&lt;br /&gt;;;; The ith customer into the system.  The customer is in the system&lt;br /&gt;;;; 2 to 10 minutes and then leaves.&lt;br /&gt;(define (customer i)&lt;br /&gt; (printf "~a: customer ~a enters~n" (current-time) i)&lt;br /&gt; (wait/work (random-flat 2.0 10.0))&lt;br /&gt; (printf "~a: customer ~a leaves~n" (current-time) i))&lt;br /&gt;&lt;br /&gt;;;; (run-simulation n) -&gt; any&lt;br /&gt;;;;   n : exact-positive-integer?&lt;br /&gt;;;; Run the simulation for n customers (or until explicitly stopped at&lt;br /&gt;;;; some specified time).&lt;br /&gt;(define (run-simulation n)&lt;br /&gt; ;; Create new global values&lt;br /&gt; (parameterize ((future-event-list '())&lt;br /&gt;                (current-time 0.0)&lt;br /&gt;                (current-event #f)&lt;br /&gt;                (event-loop-exit #f)&lt;br /&gt;                (event-loop-next #f))&lt;br /&gt;   ;; Schedule the customer generator&lt;br /&gt;   (schedule (event 0.0 generator (list n)))&lt;br /&gt;   ;; Stop the simulation at the specified time (optional)&lt;br /&gt;   ;(schedule (event 50.0 stop-simulation '()))&lt;br /&gt;   ;; Start the simulation main loop&lt;br /&gt;   (start-simulation)))&lt;br /&gt;&lt;br /&gt;;;; Run the simulation for 10 customers.&lt;br /&gt;(run-simulation 10)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;An example of the output looks like:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;2.3985738870908615: customer 0 enters&lt;br /&gt;5.395876334125138: customer 1 enters&lt;br /&gt;7.716207787604494: customer 2 enters&lt;br /&gt;8.062394508850671: customer 1 leaves&lt;br /&gt;9.204092461998275: customer 0 leaves&lt;br /&gt;14.431739507072376: customer 3 enters&lt;br /&gt;15.15611565215575: customer 2 leaves&lt;br /&gt;19.107487138771972: customer 4 enters&lt;br /&gt;19.67563344212178: customer 3 leaves&lt;br /&gt;26.51109574171283: customer 5 enters&lt;br /&gt;27.060305975366514: customer 4 leaves&lt;br /&gt;31.04777263526701: customer 6 enters&lt;br /&gt;32.83444054122948: customer 5 leaves&lt;br /&gt;36.31758748274069: customer 7 enters&lt;br /&gt;39.27687483880874: customer 6 leaves&lt;br /&gt;40.643350655011744: customer 8 enters&lt;br /&gt;41.76876758081738: customer 7 leaves&lt;br /&gt;42.82235216823591: customer 8 leaves&lt;br /&gt;47.63479457664656: customer 9 enters&lt;br /&gt;57.31661407095231: customer 9 leaves&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Your output will vary slightly because of the random numbers. That is, this is a stochastic model.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-1560110079394117771?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/1560110079394117771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=1560110079394117771' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/1560110079394117771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/1560110079394117771'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2010/08/simple-simulation-in-racket.html' title='Simple Simulation in Racket'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-3488109840388632189</id><published>2010-08-13T10:39:00.003-06:00</published><updated>2010-08-14T13:23:50.654-06:00</updated><title type='text'>Status Update</title><content type='html'>I haven't posted for a while, so I just wanted to provide an update on the status and (hopeful) direction of my various PLaneT packages. This post will cover the science, simulation, and inference collections, which work together to provide a knowledge-based simulation capability.&lt;br /&gt;&lt;br /&gt;We at SET Corporation are using the science, simulation, and inference collections as part of our Multi-Agent, Dynamic NEtwork Simulation System (MADNESS). The inference collection is also used in our COntent GENeration from Templates (COGENT) system. These are used on a daily basis in our agent-based simulation work.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Science Collection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The current release of the science collection is version 3.10. I only expect to do bug fixes to the version 3 code. The next release should be version 4.0. For version 4.0 I plan to convert the code to Typed Racket, which has gotten to the point that typed code generally runs as fast or faster than my hand-optimized numeric code.&lt;br /&gt;&lt;br /&gt;The only major new functionality planned for version 4.0 are fast Fourier transforms. This code is already written and ready for release, but the documentation has not been updated. Vincent St-Amour at Northeastern University converted the FFT code to Typed Racket to test the optimized code generation for numeric processing. The results were extremely impressive and I need to make a separate post on this.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Simulation Collection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The current version of the simulation collection is version 3.4. I only expect to do bug fixes to the version 3 code. At some point I will release a version 4.0, which may (or may not) be in Typed Racket. The decision to use Typed Racket will be based on my experience in converting the science collection. I will also rewrite the simulation language using syntax-parse to provide better syntax error handling.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Inference Collection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The current version of the inference collection is version 2.7. There was a flurry of releases earlier this year as we really began to use the inference collection in MADNESS and COGENT. Unfortunately, the documentation has not yet caught up with the code changes.&lt;br /&gt;&lt;br /&gt;I made earlier posts on the upcoming version 3 rewrite. As with the simulation collection, this may (or may not) be in Typed Scheme. I will definitely use syntax-parse to implement a rule compiler for the rule language.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-3488109840388632189?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/3488109840388632189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=3488109840388632189' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/3488109840388632189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/3488109840388632189'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2010/08/status-update.html' title='Status Update'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-2775594791801560117</id><published>2009-09-26T10:31:00.006-06:00</published><updated>2009-09-26T19:35:25.008-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='inference'/><title type='text'>Getting Ready for Inference Collection V3.0 Update 1</title><content type='html'>One of the major changes for version 3.0 of the inference collection is a rule compiler that generates code for (portions of) the match/join process. This will be done at expansion (compile) time by the rule language macros themselves. The rule language macro include &lt;span style="font-family:courier new;"&gt;define-ruleset&lt;/span&gt;, &lt;span style="font-family:courier new;"&gt;define-facts&lt;/span&gt;, and &lt;span style="font-family:courier new;"&gt;define-rule&lt;/span&gt;. The rule compilation itself takes place in the &lt;span style="font-family:courier new;"&gt;define-rule&lt;/span&gt; macro.&lt;br /&gt;&lt;br /&gt;So far, I have the rule parsing, rule validation, and rule normalization phases pretty much complete. The rule normalization phase converts Boolean expressions within the pattern clauses on a standard &lt;span style="font-family:courier new;"&gt;(and &amp;lt;pattern-clause&amp;gt; ...)&lt;/span&gt; | &lt;span style="font-family:courier new;"&gt;(or (and &amp;lt;pattern-clause&amp;gt; ...) ...)&lt;/span&gt;. The first form is a simple rule while the second  is a sequence of simple rules. For example:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(define-rule (some-rule some-ruleset)&lt;br /&gt;    (p1 ?a ?b ?c)&lt;br /&gt;    (p2 ?a ?b ?c)&lt;br /&gt;    (or (and (p3 ?a)&lt;br /&gt;             (p4 ?b))&lt;br /&gt;        (p3 ?c))&lt;br /&gt;  ==&gt;&lt;br /&gt;    (printf "a = ~a, b = ~a, c = ~a~n" ?a ?b ?c))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;would expand into the equivalent of the two rules:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(define-rule (some-rule-a some-ruleset)&lt;br /&gt;    (p1 ?a ?b ?c)&lt;br /&gt;    (p2 ?a ?b ?c)&lt;br /&gt;    (p3 ?a)&lt;br /&gt;    (p4 ?b)&lt;br /&gt;  ==&gt;&lt;br /&gt;    (printf "a = ~a, b = ~a, c = ~a~n" ?a ?b ?c))&lt;br /&gt;&lt;br /&gt;(define-rule (some-rule-b some-ruleset)&lt;br /&gt;    (p1 ?a ?b ?c)&lt;br /&gt;    (p2 ?a ?b ?c)&lt;br /&gt;    (p3 ?c))&lt;br /&gt;  ==&gt;&lt;br /&gt;    (printf "a = ~a, b = ~a, c = ~a~n" ?a ?b ?c))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This can simplify writing complex rulesets.&lt;br /&gt;&lt;br /&gt;I am now coding the actual rule compiler. This will generate procedures for matching pattern elements and joining matches - applying join constraints. For example, the pattern&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(p1 ?a 12 ?b : (&gt; ?b 10) (c . ?c))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;would compile into:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(p1&lt;br /&gt; (#:variable #f ?a #f (lambda (?a bindings)&lt;br /&gt;                        (vector-immutable&lt;br /&gt;                         (unsafe-vector-ref bindings 0))))&lt;br /&gt; (#:literal #f #f 12 (lambda (x bindings)&lt;br /&gt;                       (if (= x 12) bindings #f)))&lt;br /&gt; (#:variable #f ?b (&gt; ?b 10) (lambda (?b bindings)&lt;br /&gt;                               (let ((?a (unsafe-vector-ref bindings 1)))&lt;br /&gt;                                 (if (&gt; ?b 10)&lt;br /&gt;                                     (vector-immutable&lt;br /&gt;                                      (unsafe-vector-ref bindings 0) ?a ?b)&lt;br /&gt;                                     #f))))&lt;br /&gt; (#:variable c ?c #f (lambda (?c bindings)&lt;br /&gt;                       (let ((?a (unsafe-vector-ref bindings 1))&lt;br /&gt;                             (?b (unsafe-vector-ref bindings 2)))&lt;br /&gt;                         (vector-immutable&lt;br /&gt;                          (unsafe-vector-ref bindings 0) ?a ?b ?c))))))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where each pattern element is a five element list (&amp;lt;type&amp;gt; &amp;lt;key&amp;gt; &amp;lt;variable&amp;gt; &amp;lt;constraint&amp;gt; &amp;lt;matcher&amp;gt;), where &amp;lt;type&amp;gt; is the pattern element type (e.g., #:variable or #:literal), &amp;lt;key&amp;gt; is the key for association list matching, &amp;lt;variable&amp;gt; is a variable name, &amp;lt;constraint&amp;gt; is a constraint expression, and &amp;lt;matcher&amp;gt; is a procedure to match the pattern element. These are used at execution time to build the rule network.&lt;br /&gt;&lt;br /&gt;The structure of the pattern is maintained in the compiled form and is used to structure the match nodes and the data flow between them. The &amp;lt;type&amp;gt;, &amp;lt;key&amp;gt;, &amp;lt;variable&amp;gt;, and &amp;lt;constraint&amp;gt; fields are used to determine when nodes can be shared among rules. Finally, the procedure in the &amp;lt;matcher&amp;gt; field does the actual matching and variable binding.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);font-size:130%;" &gt;Data Structures for Matching and Joining&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Immutable vectors are used to represent matches. For example, the pattern&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(p1 ?a 12 ?b : (&gt; ?b 10) (c . ?c))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;matched against the asserted fact&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(p1 10 12 14 (c . 16) (d . 18))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;would produce a match of&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#(&amp;lt;assertion&amp;gt; 10 14 16)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where &amp;lt;assertion&amp;gt; is the assertion object for the specified fact and 10, 14, and 16 are the values matching the variables ?a, ?b, and ?c, respectively.&lt;br /&gt;&lt;br /&gt;Immutable vectors are also used to represent joined matches. For example, the patterns&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(p1 ?a ?b ?c)&lt;br /&gt;?p2 &lt;- (p2 ?a ?b ?c)&lt;br /&gt;(no (p3 ?a))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;matched against the asserted facts&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(p1 1 2 3)&lt;br /&gt;(p2 1 2 3)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;with no asserted &lt;span style="font-family:courier new;"&gt;(p3 1)&lt;/span&gt;) fact, would produce a match of&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#(#(&amp;lt;assertion&amp;gt; 1 2 3)&lt;br /&gt;  #(&amp;lt;assertion&amp;gt; 1 2 3)&lt;br /&gt;  #(#t))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;A major bottleneck in the current inference engine is the amount of work done in propagating (or unpropagating) assertions and deletions through the join (and rule) nodes of the rule network. For version 3.0, I'm planning on two (eq?) hash tables for each join node to index left and right matches and a double doubly-linked list of joined matches. This will allow efficient insertion and deletion of both left and right matches during join processing (for propagating and unpropagating).&lt;br /&gt;&lt;br /&gt;More to come.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-2775594791801560117?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/2775594791801560117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=2775594791801560117' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/2775594791801560117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/2775594791801560117'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2009/09/getting-ready-for-inference-collection.html' title='Getting Ready for Inference Collection V3.0 Update 1'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-3402639077678788095</id><published>2009-09-20T09:49:00.006-06:00</published><updated>2009-09-26T19:42:14.735-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistics'/><category scheme='http://www.blogger.com/atom/ns#' term='Chebyshev'/><category scheme='http://www.blogger.com/atom/ns#' term='science'/><title type='text'>Science Collection Updated</title><content type='html'>I released a new version of the Science Collection with reimplemented statistics and Chebyshev approximation routines.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);font-size:130%;" &gt;Statistics&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The statistics routines have been rewritten to take sequences (for example, lists and vectors) as arguments instead of just vectors - except for the median and quantile routines that require sorted vectors. Unfortunately, the sequence versions, which are generally implemented using &lt;span style="font-family:courier new;"&gt;for/fold&lt;/span&gt;, were more than twice as slow as the previous vector versions. So, I wrote dispatching &lt;span style="font-family:courier new;"&gt;for&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;for/fold&lt;/span&gt; macros (see below) that take a general sequence and generate a &lt;span style="font-family:courier new;"&gt;cond&lt;/span&gt; expression with special cases for vectors and lists that the complier can better optimize. These perform about the same as the old code for vectors and lists perform about the same (as vectors). And, we still get the benefit of general sequences.&lt;br /&gt;&lt;br /&gt;I also added the correlation function that I had somehow missed in the original implementation. [Unfortunately, the first version had a bug (&lt;a href="http://planet.plt-scheme.org/trac/ticket/203"&gt;#203&lt;/a&gt;) in it - actually, there were two since the contract was also wrong. It has since been fixed.]&lt;br /&gt;&lt;br /&gt;I also added running statistics to the statistics routines. If you only need simple statistics (e.g., n, min, max, mean, variance, and standard deviation), you don't need to maintain a list (or vector) of the values. Instead, you create a statistics object and tally successive values. The statistics object can be queried at any time for the values of its statistics at that point.&lt;br /&gt;&lt;br /&gt;I also implemented a &lt;span style="font-family:courier new;"&gt;mean-variance&lt;/span&gt; function that computes both the mean and variance for a sequence in a single pass through the data. [The previous functions requires two passes - one to compute the mean and one to compute the variance.] This also reduces the number of passes required for computing skew and kurtosis when the mean and standard deviation aren't given.&lt;br /&gt;&lt;br /&gt;I also implemented contracts for &lt;span style="font-family:courier new;"&gt;sequence-of-real?&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;nonempty-sequence-of-real?&lt;/span&gt; that are used in the contracts for the statistics routines. As usual in the Science Collection, there are unchecked versions of the statistics routines that bypass the contract check.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);font-size:130%;" &gt;Chebyshev Approximations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Chebyshev approximation routines were reimplemented for clarity and efficiency. I changed the &lt;span style="font-family:courier new;"&gt;make-chebyshev-series&lt;/span&gt; function to be more general. It replaces the functionality of &lt;span style="font-family:courier new;"&gt;make-chebyshev-series-order&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;chebyshev-series-init&lt;/span&gt;, which are still available as legacy routines. I also added &lt;span style="font-family:courier new;"&gt;make-chebyshev-series-derivative&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;make-chebyshev-series-integral&lt;/span&gt; that generate new series to compute the derivative and integral, respectively, of a given Chebyshev series.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);font-size:130%;" &gt;Dispatching  &lt;span style="font-family:courier new;"&gt;for&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;for/fold&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In reimplementing the statistics routines to allow general sequences as arguments, I also implemented &lt;span style="font-family:courier new;"&gt;dispatch-for&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;dispatch-for/fold&lt;/span&gt; macros, as described above. These macro are not exported from the statistics collection and are implemented using &lt;span style="font-family:courier new;"&gt;syntax-rules&lt;/span&gt; - so error messages are pretty much limited to 'bad-syntax'. With that caveat, they do produce code that outperforms (due to compiler optimizations) a straight &lt;span style="font-family:courier new;"&gt;for&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;for/fold&lt;/span&gt; for vectors and lists.&lt;br /&gt;&lt;br /&gt;The implementation of the macros and examples their usage can be seen in the &lt;a href="http://planet.plt-scheme.org/package-source/williams/science.plt/3/9/statistics.ss"&gt;statistics.ss&lt;/a&gt; file in the Science Collection.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-3402639077678788095?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/3402639077678788095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=3402639077678788095' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/3402639077678788095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/3402639077678788095'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2009/09/science-collection-updated.html' title='Science Collection Updated'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-2663406293338494451</id><published>2009-08-08T20:37:00.002-06:00</published><updated>2009-09-26T19:36:32.910-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='inference'/><title type='text'>Getting Ready for Inference Collection 3.0</title><content type='html'>I've been working on improvements to the inference collection now that we are actually using it (and the simulation collection) on a regular basis for agent-based simulation work. There will be in Version 3.0 of the inference collection. This is just to put forward some of the changes I'm planning on including.&lt;br /&gt;The major change affecting user code is that Version 3.0 is that only (immutable) lists will be used to represent facts. This includes association lists for named slots. [Previously, vectors and structures could also be used.] Immutability simplifies many things associates with truth maintenance and explanation.&lt;br /&gt;An ontology capability will be added that allows the user to define a set of taxonomies for the facts in the knowledge base. [Actually, this capability is already in Version 2.2 of the inference collection, but isn't released to PLaneT yet.] Taxonomic relations are asserted (much the same as facts) and these relations are used in matching rule preconditions. For example, (assert '(#:class hunter ())) and (assert '(#:class duck-hunter (hunter))) specifies that facts about hunters also apply to duck hunters. Classes may be generalizations of multiple parent classes. Basically, when a fact is asserted, it matched precondition clauses for its own class and (recursively) its parent classes. So, (duck-hunter clyde) would match both (duck-hunter ?x) and (hunter ?x) patterns as preconditions in rules.&lt;br /&gt;Backward chaining is better integrated with forward chaining. When propogating assertions (or retractions) through the rule network, backward chaining will be automatically invoked. [Currently, backward chaining is only invoked when explicitly requested - via (query fact).]&lt;br /&gt;Rulesets have a run-time instantiation now. [They were just collections of rules before.] When a ruleset is activated, a ruleset instance is created. The ruleset instance contains the agenda (for rule instances from the ruleset). This allows different conflict resolution strategies to be applied to rulesets within a single inference environment. [It will also allow us to experiment with conflict resolution among rulesets in the future.]&lt;br /&gt;Certainty values for facts are implemented. A certainty may be specified when a fact is asserted and these are maintained as facts are inferred via rule firings.&lt;br /&gt;Boolean connectives are allowed among rule preconditions. This simplifies writing complex rules.&lt;br /&gt;This is a fairly substantial rewrite of the inference collection and should result in a better package all around. Our agent-based simulation work is leading us to look at less monolithic knowledge bases and more distributed ones. Although Version 3.0 is not truly distributed, it should help us along those lines as PLT Scheme continues to mature.&lt;br /&gt;I'm not aware of any regular users outside of our small cadre of agent-based simulation folks. But, if there are, I'd like to solicit your inputs on any changes you might like and also make you aware of specific changes to the collection.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-2663406293338494451?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/2663406293338494451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=2663406293338494451' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/2663406293338494451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/2663406293338494451'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2009/08/getting-ready-for-inference-collection.html' title='Getting Ready for Inference Collection 3.0'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-1995680861675516187</id><published>2008-12-01T07:47:00.003-07:00</published><updated>2009-09-26T19:38:29.340-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><title type='text'>Simulation Collection Update</title><content type='html'>I have updated the PLTScheme Simulation Collection to Version 3.2.  This was primarily to release the Scribble documentation.  The Scribble documentation is about 90% complete, which is a bit more than the previous HTML documentation.&lt;br /&gt;&lt;br /&gt;I have begun adding new graphics capabilities to the simulation collection.  So far I have added variable-slider%, variable-gauge%, and variable-message% classes.  These are subclasses of the MrEd slider%, gauge%, and message% classes that are automatically synchronized with a specified simulation variable.&lt;br /&gt;&lt;br /&gt;The variable-slider% class sets its associated variable to the value of the slider.  That is, whenever the user moves the slider, the associated variable value is changed.  This is input only.&lt;br /&gt;&lt;br /&gt;The variable-gauge% class updates the gauge whenever the value of its associated variable is changed.  The range of a variable-gauge% object may also be associated with a simulation variable.  This is output only (for both the value variable and the range variable, if any).&lt;br /&gt;&lt;br /&gt;The variable-message% class displays its associated variable's value and is updated whenever the value of that variable is changed.  This is output only.&lt;br /&gt;&lt;br /&gt;The graphical open and closed loop examples have been updated to show the use of these classes.&lt;br /&gt;&lt;br /&gt;As usual, these are available on the Schematics project at SourceForge.  I will update the PLaneT package when everything is stable and documented.&lt;br /&gt;&lt;br /&gt;There are several other variable controls I plan on implemented in the next few weeks.  The variable-text-field% class will provide both input and output for its associated variable's value.  The variable-plot% class will provide a plot capability for variables.  Initially, plots will just be time-value plots, but it will support multiple variables on each plot.&lt;br /&gt;&lt;br /&gt;Currently, for my agent-based simulations I am using the animated-canvas% class to display the cell grid (or whatever 2D or 3D representation is appropriate).  I need to generalize that as part of generalizing the agent-based capability.  [Although simulation processes aren't very heavy-weight, continually adding and removing many thousands of them from the event list  each generation is quite time-consuming.]  That is next on my to do list.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-1995680861675516187?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/1995680861675516187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=1995680861675516187' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/1995680861675516187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/1995680861675516187'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2008/12/simulation-collection-update.html' title='Simulation Collection Update'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-4717023906969066602</id><published>2008-09-26T09:28:00.004-06:00</published><updated>2008-09-26T09:40:56.447-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='science'/><title type='text'>PLT Scheme Science Collection Version 4.1 Released</title><content type='html'>I released Version 4.1 of the &lt;a href="http://planet.plt-scheme.org/display.ss?package=science.plt&amp;amp;owner=williams"&gt;PLT Scheme Science Collection&lt;/a&gt; to PLaneT earlier this week.  There were no functionality changes, but the &lt;a href="http://planet.plt-scheme.org/package-source/williams/science.plt/3/1/planet-docs/science/index.html"&gt;documentation&lt;/a&gt; has been converted to the Scribble format.&lt;br /&gt;&lt;br /&gt;As usual, it is available from the PLaneT repository using the form:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;(require (planet williams/science/science))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;(require (planet williams/science/science-with-graphics))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;depending on whether or not the graphics routines are needed.&lt;br /&gt;&lt;br /&gt;The source code is maintained on the &lt;a href="http://sourceforge.net/projects/schematics/"&gt;Schematics&lt;/a&gt; project subversion repository on SourceForge.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-4717023906969066602?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/4717023906969066602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=4717023906969066602' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/4717023906969066602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/4717023906969066602'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2008/09/plt-scheme-science-collection-version.html' title='PLT Scheme Science Collection Version 4.1 Released'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-3329522696004687683</id><published>2008-09-26T08:47:00.003-06:00</published><updated>2008-09-26T09:06:51.826-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='graphics'/><category scheme='http://www.blogger.com/atom/ns#' term='animated-canvas'/><title type='text'>Animated Canvas Released to PLaneT</title><content type='html'>I've released the animated canvas that I use for animated graphics in PLT Scheme.  An animated canvas uses two bitmaps to provide a double-buffered animation capability. This is implemented by a new class &lt;span style="font-family: courier new;"&gt;animated-canvas%&lt;/span&gt; that specializes the&lt;span style="font-family: courier new;"&gt; canvas%&lt;/span&gt; class. At any specific time, one bitmap, the background bitmap, is being used for all drawing operations and the other bitmap, the foreground bitmap, is being used to paint the canvas.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family: courier new;"&gt;swap-bitmaps&lt;/span&gt; method is used to swap the background and foreground bitmaps. When the bitmaps are swapped, the contents of the new foreground bitmap – the old background bitmap – is displayed on the canvas. The new background bitmap – the old foreground bitmap – is automatically cleared, unless specifically prevented by the &lt;span style="font-family: courier new;"&gt;'no-autoclear&lt;/span&gt; style option.&lt;br /&gt;&lt;br /&gt;The device context returned by the animated canvases’s &lt;span style="font-family: courier new;"&gt;get-dc&lt;/span&gt; method is the device context of the background bitmap. This value is not valid across calls to swap-bitmaps. Therefore, it is important to re-retrieve, via &lt;span style="font-family: courier new;"&gt;get-dc&lt;/span&gt;, the device context across bitmap swaps.&lt;br /&gt;&lt;br /&gt;The animated canvas also supports resizing on the canvas, which automatically resizes the background buffer after the bitmaps are swapped.&lt;br /&gt;&lt;br /&gt;A simple example using the animated canvas is also provided.&lt;br /&gt;&lt;br /&gt;As usual, the package is available from &lt;a href="http://planet.plt-scheme.org/display.ss?package=animated-canvas.plt&amp;amp;owner=williams"&gt;PLaneT&lt;/a&gt; using the form:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;(require (planet williams/animated-canvas/animated-canvas))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The source code is maintained on the &lt;a href="http://sourceforge.net/projects/schematics/"&gt;Schematics&lt;/a&gt; subversion repository at SourceForce.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-3329522696004687683?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/3329522696004687683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=3329522696004687683' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/3329522696004687683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/3329522696004687683'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2008/09/animated-canvas-released-to-planet.html' title='Animated Canvas Released to PLaneT'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-475447113196252946</id><published>2008-09-01T10:41:00.013-06:00</published><updated>2008-09-26T09:13:55.978-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='packed-binary'/><title type='text'>Packed Binary Routines for PLT Scheme</title><content type='html'>I have implemented an equivalent of the Python pack/unpack functions in PLT Scheme.  I needed it primarily to be able to (more easily) read binary data from other applications for analysis in PLT Scheme.&lt;br /&gt;&lt;br /&gt;The documentation for the Python capability can be found in the Python Library Reference: &lt;a href="http://docs.python.org/lib/module-struct.html"&gt;4.3 &lt;span style="font-family:courier new;"&gt;struct&lt;/span&gt; -- Interpret strings as packed data&lt;/a&gt;.  I have implemented the entire capability except for the "&lt;span style="font-family:courier new;"&gt;p&lt;/span&gt;" and "&lt;span style="font-family:courier new;"&gt;P&lt;/span&gt;" formats that encode a "Pascal string".  [I don't have pack_into or unpack_from implemented yet - they are new in Pyton 2.5 - but I will implement them before posting the package to PLaneT.  The following description is modified from the above reference.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;packed-binary.ss&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This module performs conversions between PLT Scheme values and C structs represented as PLT Scheme byte strings.  It uses &lt;span style="font-style: italic;"&gt;format strings&lt;/span&gt; (explained below) as compact descriptions of the layout of the C structs and the intended conversion to/from PLT Scheme values.  This can be used in handling binary data stored in files or from network connections, among other sources.&lt;br /&gt;&lt;br /&gt;The module defines the following functions:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="font-weight: bold;"&gt;pack &lt;/span&gt;&lt;span style="font-style: italic;"&gt;format v1 v2 ...&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;Returns a byte string containing the values &lt;span style="font-style: italic;font-family:courier new;" &gt;v1, v2, ... &lt;/span&gt;packed according to the given &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt;.  The arguments must match the values required by the &lt;span style="font-family:courier new;"&gt;format&lt;/span&gt; exactly.&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="font-weight: bold;"&gt;pack-into&lt;/span&gt; &lt;/span&gt;&lt;span style="font-style: italic;font-family:courier new;" &gt;format buffer offset v1 v2 ...&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;Pack the values &lt;span style="font-style: italic;"&gt;&lt;span style="font-family:courier new;"&gt;v1, v2, ...&lt;/span&gt; &lt;/span&gt;according to the given &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt; into the (mutable) byte string &lt;span style="font-style: italic;font-family:courier new;" &gt;buffer&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;starting at &lt;span style="font-style: italic;font-family:courier new;" &gt;offset&lt;/span&gt;.  Note that the &lt;span style="font-style: italic;font-family:courier new;" &gt;offset&lt;/span&gt; is not an optional argument.&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="font-weight: bold;"&gt;write-packed&lt;/span&gt; &lt;span style="font-style: italic;"&gt;format port v1 v2 ...&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;Pack the values &lt;span style="font-style: italic;font-family:courier new;" &gt;v1, v2, ...&lt;/span&gt; according to the given &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt; and write them to the specified output &lt;span style="font-style: italic;font-family:courier new;" &gt;port&lt;/span&gt;.  Note that &lt;span style="font-style: italic;font-family:courier new;" &gt;port&lt;/span&gt; is not an optional argument.  [Note that &lt;span style="font-weight: bold;font-family:courier new;" &gt;write-packed&lt;/span&gt; is not part of the Python module, but was added because of its utility.]&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="font-weight: bold;"&gt;unpack &lt;/span&gt;&lt;span style="font-style: italic;"&gt;format bytes&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;Unpack the &lt;span style="font-style: italic;font-family:courier new;" &gt;bytes&lt;/span&gt; according to the given &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt;.  The result is a list, even if it contains exactly one item.  The &lt;span style="font-style: italic;font-family:courier new;" &gt;bytes&lt;/span&gt; must contain exactly the amount of data required by the &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt; [&lt;span style="font-family:courier new;"&gt;(bytes-length bytes)&lt;/span&gt; must equal &lt;span style="font-family:courier new;"&gt;(calculate-size format)&lt;/span&gt;].&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="font-weight: bold;"&gt;unpack-from&lt;/span&gt; &lt;span style="font-style: italic;"&gt;format buffer (offset 0)&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;Unpack the byte string &lt;span style="font-style: italic;font-family:courier new;" &gt;buffer&lt;/span&gt; according to the given &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt;.  The result is a list, even if it contains exactly one element.  The &lt;span style="font-style: italic;font-family:courier new;" &gt;buffer&lt;/span&gt; must contain at least the amount of data required by the &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt; [&lt;span style="font-family:courier new;"&gt;(- (bytes-length buffer) offset)&lt;/span&gt; must be at least &lt;span style="font-family:courier new;"&gt;(calculate-size format)&lt;/span&gt;].&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="font-weight: bold;"&gt;read-packed&lt;/span&gt; &lt;span style="font-style: italic;"&gt;format port&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;Read &lt;span style="font-family:courier new;"&gt;(calculate-size &lt;span style="font-style: italic;"&gt;format&lt;/span&gt;)&lt;/span&gt; bytes from the input &lt;span style="font-style: italic;font-family:courier new;" &gt;port&lt;/span&gt; and unpack them according to the given &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt;.  The result is a list, even if it contains exactly one element.  [Note that &lt;span style="font-weight: bold;font-family:courier new;" &gt;read-packed&lt;/span&gt; is not part of the Python module, but was added because of its utility.]&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="font-weight: bold;"&gt;calculate-size&lt;/span&gt; &lt;span style="font-style: italic;"&gt;format&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;Return the size of the byte string corresponding to the given &lt;span style="font-style: italic;font-family:courier new;" &gt;format&lt;/span&gt;.&lt;br /&gt;&lt;/blockquote&gt;Format characters have the following meaning; the conversion between C and PLT Scheme values should be obvious given their types:&lt;br /&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="font-weight: bold;"&gt;Format&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;C Type&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;PLT Scheme&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;x&lt;/td&gt;&lt;td&gt;pad byte&lt;/td&gt;&lt;td&gt;no value&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;c&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;char&lt;/td&gt;&lt;td&gt;char&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;b&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;signed char&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;B&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;unsigned char&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;h&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;short&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;H&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;unsigned short&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;i&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;int&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;I&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;unsigned int&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;l&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;long&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;L&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;unsigned long&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;q&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;long long&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;Q&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;unsigned long long&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;f&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;float&lt;/td&gt;&lt;td&gt;real&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;d&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;double&lt;/td&gt;&lt;td&gt;real&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family: courier new;"&gt;s&lt;/td&gt;&lt;td style="font-family: courier new;"&gt;char[]&lt;/td&gt;&lt;td&gt;string&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;A format character may be preceded by an integral repeat count.  For example, the format string &lt;span style="font-family:courier new;"&gt;"4h"&lt;/span&gt; means exactly the same thing as &lt;span style="font-family:courier new;"&gt;"hhhh"&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Whitespace characters between formats are ignored; a count and its format must not contain whitespace though.&lt;br /&gt;&lt;br /&gt;For the &lt;span style="font-family:courier new;"&gt;"s"&lt;/span&gt; format character, the count is interpreted as the size of the string, not a repeat count like for the other format characters.  For example, &lt;span style="font-family:courier new;"&gt;"10s"&lt;/span&gt; means a 10-byte string while &lt;span style="font-family:courier new;"&gt;"10c"&lt;/span&gt; means 10 characters.  For packing, the string is truncated or padded with null bytes as appropriate to make it fit.  For unpacking, the resulting string always has exactly the specified number of bytes.  As a special case, &lt;span style="font-family:courier new;"&gt;"0s"&lt;/span&gt; means a single, empty string (while &lt;span style="font-family:courier new;"&gt;"0c"&lt;/span&gt; means 0 characters).&lt;br /&gt;&lt;br /&gt;By default, C numbers are represented in the machine's native format and byte order, and properly aligned by skipping pad bytes if necessary.&lt;br /&gt;&lt;br /&gt;Alternatively, the first character of the format string can be used to indicate the byte order, size, and alignment of the packed data according to the following table:&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="font-weight: bold;"&gt;Character&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Byte order&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Size and alignment&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;@&lt;/td&gt;&lt;td&gt;native&lt;/td&gt;&lt;td&gt;native&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;=&lt;/td&gt;&lt;td&gt;native&lt;/td&gt;&lt;td&gt;standard&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;lt;&lt;/td&gt;&lt;td&gt;little endian&lt;/td&gt;&lt;td&gt;standard&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;gt;&lt;/td&gt;&lt;td&gt;big endian&lt;/td&gt;&lt;td&gt;standard&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;!&lt;/td&gt;&lt;td&gt;network (= big endian)&lt;/td&gt;&lt;td&gt;standard&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;If the first character is not one of these, &lt;span style="font-family:courier new;"&gt;"@"&lt;/span&gt; is assumed.&lt;br /&gt;&lt;br /&gt;Native byte order is big endian or little endian.  For example, Motorola and Sun processors are big endian; Intel and DEC processors are little endian.&lt;br /&gt;&lt;br /&gt;Standard size and alignment are as follows: no alignment is required for any type (so you have to use pad bytes); &lt;span style="font-family:courier new;"&gt;short&lt;/span&gt; is 2 bytes; &lt;span style="font-family:courier new;"&gt;int&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;long&lt;/span&gt; are 4 bytes; &lt;span style="font-family:courier new;"&gt;long long&lt;/span&gt; is 8 bytes; &lt;span style="font-family:courier new;"&gt;float&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;double&lt;/span&gt; are 32-bit and 64-but IEEE floating point numbers, respectively.&lt;br /&gt;&lt;br /&gt;Note the difference between &lt;span style="font-family:courier new;"&gt;"@"&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;"="&lt;/span&gt;: both use native byte order, but the size and alignment of the latter is standardized.&lt;br /&gt;&lt;br /&gt;The form &lt;span style="font-family:courier new;"&gt;"!"&lt;/span&gt; is available for those who can't remember whether network byte order is big endian or little endian - it is big endian.&lt;br /&gt;&lt;br /&gt;There is no way to indicate non-native byte order (force byte swapping); use the appropriate choice of &lt;span style="font-family:courier new;"&gt;"&lt;"&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;"&gt;"&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Hint, to align the end of a structure to the alignment requirement of a particular type, end the format with the code for that type with a repeat count of zero.  For example, the format &lt;span style="font-family:courier new;"&gt;"llh0l"&lt;/span&gt; specified two pad bytes at the end, assuming longs are aligned on 4-byte boundaries.  This only works when native size and alignment are in effect; standard size and alignment does not enforce any alignment.&lt;br /&gt;&lt;br /&gt;The current implementation may not properly handle native alignment in all cases.  For the current implementation, the native alignment is assumed to be the same as the size.  This may result in excess pad bytes, particularly for 8-byte objects.&lt;br /&gt;&lt;br /&gt;I will be putting the code up on the Schematics project on source forge (probably tomorrow) and it will be available on PLaneT soon thereafter.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-475447113196252946?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/475447113196252946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=475447113196252946' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/475447113196252946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/475447113196252946'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2008/09/packed-binary-routines-for-plt-scheme.html' title='Packed Binary Routines for PLT Scheme'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-8441549158422105040</id><published>2008-07-01T07:37:00.006-06:00</published><updated>2009-09-26T19:39:30.331-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PLT Scheme'/><title type='text'>PLT Scheme on Vista</title><content type='html'>First off, I'd like to thank Eli Barzilay from the PLT team for helping track down these Vista 'features' that, together with a PLaneT 'feature', are causing my PLT Scheme problems on Vista.  We also found the reason for long PLaneT download times on PLT Scheme V4.0 in the process.&lt;br /&gt;&lt;br /&gt;This particular problem started when I tried to upgrade to PLT Scheme V4.0.1.  After uninstalling PLT Scheme V4.0 (and making sure the uninstall completely removed the C:\Program Files\PLT directory) and installing V4.0.1, I would get the error "collects\srfi\compiled\provider_ss.zo::0: read (compiled): code compiled for version 4.0, not 4.0.1".  I reported this on the bug tracker (&lt;a href="http://bugs.plt-scheme.org/query/?cmd=view&amp;amp;pr=9554"&gt;http://bugs.plt-scheme.org/query/?cmd=view&amp;amp;pr=9554&lt;/a&gt;) where you can read the e-mail thread on the problem.&lt;br /&gt;&lt;br /&gt;The Vista 'feature' that is biting us is called "UAC virtualization services" and is described in this article on the &lt;a href="http://zone.ni.com/devzone/cda/tut/p/id/5538"&gt;National Instruments Developer Site&lt;/a&gt;.  (I'm sure there are many other such explainations that could be referenced.)  It's a good read and goes into details that I will only summarize here.  In short, if a user application attempts to modify protected portions of the file system (like C:\Program Files), the UAC virtualization service silently redirects the access to an unprotected, site-specific area (like C:\Users\doug\AppData\Local\VirtualStore\Program Files).  Subsequent reads of affected files will use the copy in the virtual store.  The problem is that install and uninstall (and probably some other application specific programs) don't know about the virtual store and files stay persistant across uninstall/install boundaries.&lt;br /&gt;&lt;br /&gt;This was coupled with the current PLaneT 'feature' (&lt;a href="http://bugs.plt-scheme.org/query/gnatsweb.pl?debug=&amp;amp;database=default&amp;amp;cmd=view+audit-trail&amp;amp;cmd=view&amp;amp;pr=9555"&gt;http://bugs.plt-scheme.org/query/gnatsweb.pl?debug=&amp;amp;database=default&amp;amp;cmd=view+audit-trail&amp;amp;cmd=view&amp;amp;pr=9555&lt;/a&gt;) that compiles PLaneT packages with errortrace (i.e., debugging) when the initial require is from within DrScheme - it doesn't seem to happen from within MzScheme.  In my case, when I would require the science collection (for example) from within DrScheme, it would download the collection and compile it and all referenced collections with errortrace turned on.  This would recompile the referenced PLT Scheme collections (in C:\Program Files\PLT\collects) and the compiled files were put in the virtual store.  This works okay until the uninstall of V4.0 and install of V4.0.1 where the compiled files in the virtual store (from V4.0) were seen instead of the newly installed files (from V4.0.1).&lt;br /&gt;&lt;br /&gt;In any case, you can read the e-mail thread in the bug list for the details of how we finally tracked the problem down.&lt;br /&gt;&lt;br /&gt;There are some work arounds that can be used until the PLT Scheme team figures out the best way to 'play nice' with Vista - although it would be nice if Vista played nice with legacy applications, but don't hold your breath for that.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;When you do an uninstall, check to see if C:\Users\&amp;lt;user&amp;gt;\AppData\Local\VirtualStore\PLT exists.  If it does, delete it also.  This will remove the user modified files that might exist - even if they didn't realize they had modified any.  [Note that the location of the virtual store may be different, so you might want to do a search for 'PLT' and include system and hidden files in the search.  Also, if there are multiple users, they may be multiple virtual stores.]&lt;/user&gt;&lt;/li&gt;&lt;li&gt;For the initial load of PLaneT collections where you don't want errortrace turned on, do the initial require from MzScheme.  For example, start up MzScheme from the command prompt and type "(require (planet "science.ss" ("williams" "science.plt")))" to load the science collection.  This should work for any collection.&lt;/li&gt;&lt;/ol&gt;I will be 'upgrading' by laptop from Vista to XP and at least the first problem will go away.  I would still recommend doing the initial require for PLaneT packages from MzScheme.  I still have my Vista machine at home and will be dealing with some of these issues in an on-going basis.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-8441549158422105040?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/8441549158422105040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=8441549158422105040' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/8441549158422105040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/8441549158422105040'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2008/07/plt-scheme-on-vista.html' title='PLT Scheme on Vista'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-5522476527005926755</id><published>2008-06-26T14:22:00.002-06:00</published><updated>2009-09-26T19:39:30.331-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PLT Scheme'/><title type='text'>Progress Updating to PLT Scheme V4.0</title><content type='html'>Now that PLT Scheme is official released, I am updating the science, simulation, and inference collections to be compatible with the new version.  These changes are incompatible with pre-V4.0 versions of PLT Scheme and will be stored in the PLaneT 4.x repository.  Anyone using pre-V4.0 code should continue to use the versions in the PLaneT 3xx repository.  V4.0 compatible versions of the science collection (Version 3.0) and simulation collection (Version 3.0) have been released already.  I am now working on the V4.0 version of the inference collection (Version 2.0) and expect to release it this weekend.&lt;br /&gt;&lt;br /&gt;There were several rather simple global changes that occurred in all of the code.  For example, using the new &lt;span style="font-family: courier new;"&gt;#lang&lt;/span&gt; construct for all modules, using modules for all examples, hash table name changes, changes to &lt;span style="font-family: courier new;"&gt;require &lt;/span&gt;constructs, some contract changes (in particular &lt;span style="font-family: courier new;"&gt;union/c&lt;/span&gt; becomes &lt;span style="font-family: courier new;"&gt;or/c&lt;/span&gt;), and &lt;span style="font-family: courier new;"&gt;define-struct&lt;/span&gt; syntactic changes.&lt;br /&gt;&lt;br /&gt;Some other changes were more difficult.  The changes to keywords and keyword parameters required individual attention to each specific usage.  Fortunately, much of my usage of keyword parameters is in macros and those still work the same in V4.0.  I often use keywords as special values (e.g. &lt;span style="font-family: courier new;"&gt;#:now&lt;/span&gt;).  These used to self evaluate, but now require quoting.  Fortunately, these don't occur in user code.  The other major problem is with mutable lists.  These also have to be looked at on an individual bases.  In some cases, I reverted to immutable lists (e.g. when using reverse! to reorder a constructed list being returned from a function) and in other cases I converted them to explicit mutable lists.  It can be a chore to track down all of the references in a large body of code.&lt;br /&gt;&lt;br /&gt;One big remaining issue is converting the documentation over to use Scribble.  Unfortunately, the existing HTML documentation for PLaneT packages is not made available in the new Help Desk.  [I honestly think that they should retain the ability for developers to distribute HTML documentation for PLaneT packages.]&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PLT Scheme Science Collection:&lt;/span&gt; The science collection was rather straightforward to convert since I had kept the older versions compatible with both 372 and 399 (the V4.0 pre-release).  Version 2.9 is the last pre-V4.0 compatible version and Version 3.0 is the new V4.0 compatible version.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PLT Scheme Simulation Collection:&lt;/span&gt; The simulation collection was more complicated to convert since it mutates lists in the implementation of the event list and variable histories (and probably a few others that I don't remember).  I also had some problems with keywords since I had implemented my own keyword parameter scheme before it was added into PLT Scheme.  Version 2.2 is the last pre-V4.0 compatible version and Version 3.0 is the new V4.0 compatible version.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PLT Scheme Inference Collection:&lt;/span&gt; The inference collection makes extensive use of list mutation and I am still tracking down and fixing them on an individual basis.  I expect to have the V4.0 compatible version out this weekend.&lt;br /&gt;&lt;br /&gt;If anybody runs into any problems with any of these packages, please let me know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-5522476527005926755?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/5522476527005926755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=5522476527005926755' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/5522476527005926755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/5522476527005926755'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2008/06/progress-updating-to-plt-scheme-v40.html' title='Progress Updating to PLT Scheme V4.0'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-613628625985489785</id><published>2008-03-27T09:25:00.005-06:00</published><updated>2009-09-26T19:41:37.834-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='schemelab'/><title type='text'>Homogeneous, N-Dimensional Arrays (ndarrays)</title><content type='html'>The basic representational element for PLT Scheme Schemelab is a homogeneous, n-dimensional array - or ndarray.  This post will discuss the initial design for ndarrays and discuss some of the operations on them.&lt;br /&gt;&lt;br /&gt;Internally, an ndarray is represented by a structure with the following elements:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;ordering - (symbols 'row 'column), specifies the order in which dimensions are stored ('row for row major and 'column for column major).  Generally, this isn't that useful except for (eventually) interfacing with foreign code (C uses row major and FORTRAN uses column major).  Also, the transpose operation converts from one to the other (although that is more a side effect that its real functionality).  [read only]&lt;br /&gt;&lt;/li&gt;&lt;li&gt;shape - (listof natural-number/c), specifies the shape of the array.  The length of the shape list is the number of dimensions for the array and each element is the cardinality of the corresponding dimension.  This may be set to reshape the array.&lt;/li&gt;&lt;li&gt;ndim - natural-number/c, the number of dimensions for the array.  This is equal to (length shape).  [read only]&lt;/li&gt;&lt;li&gt;size - natural-number/c, the total number of elements in the array.  [read only]&lt;/li&gt;&lt;li&gt;disp - natural-number/c, the displacement (in elements) of this subarray is the data vector.  This will be zero for any ndarray that owns its own data.  [read only]&lt;/li&gt;&lt;li&gt;strides - (listof natural-number/c), a list of the number of elements to skip to move to the next element in the corresponding dimension. [read only]&lt;/li&gt;&lt;li&gt;offset - natural-number/c, the offset (in elements) for each addressed element.  This will be zero for any ndarray that owns its own data.  [read only]&lt;/li&gt;&lt;li&gt;data - typed-vector?, the typed vector containing the data for the array.  [A typed vector encapsulates an SRFI 4 vector (for u8, u16, u32, u64, s8, s16, s32, s64, f32, or f64 arrays), a complex vector (for c64 or c128 arrays), or a Scheme vector (for Scheme object arrays).]  [read only]&lt;/li&gt;&lt;li&gt;base - (or/c array? false/c), the base array for this (sub)array or #f if the array owns its own data (i.e. it is a base array).  Note that the referenced array may itself  base a non-#f base entry.  [read only]&lt;/li&gt;&lt;/ul&gt;Note that I may not need both the displacement (disp) and offset fields.  But, the general idea for array iteration is to add the displacement once when the iterator is initialized and to add the offset for each element.  It might be possible to collapse those into one offset without loss of generality.&lt;br /&gt;&lt;br /&gt;The most general array constructor is make-array, which has the following contract:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;vpre&gt;&lt;br /&gt;(-&gt;* ((listof natural-number/c))&lt;br /&gt;     (#:vtype (or/c vtype? symbol?)&lt;br /&gt;      #:ordering (symbols 'row 'column)&lt;br /&gt;      #:fill any/c)&lt;br /&gt;     array?)&lt;br /&gt;&lt;br /&gt;&lt;/vpre&gt;&lt;/span&gt;&lt;br /&gt;The required argument is the shape of the array.  The optional keyword arguments are #:vtype, which specifies the type of the array (default object), #:ordering, which defaults to 'row, and #:fill.  If #fill is not specified, the array elements are not initialized.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;(define a1 (make-array '(3 2) #:vtype f32 #:fill 0.0))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Creates an array whose shape is '(3 2) (i.e. three rows and two columns) and whose elements are 32-bit floating-point numbers that are initially 0.0.&lt;br /&gt;&lt;br /&gt;A fully qualified reference for the array returns the corresponding (scalar) element.  For example, (array-ref a1 '(1 1) returns the value of the element at '(1 1).&lt;br /&gt;&lt;br /&gt;A partially qualified reference for the array returns a reference to the corresponding subarray.  For example, (array-ref a1 '(: 1) ) returns the subarray of shape '(3) that corresponds to the second column of a1.  [Note that this is a reference to the second column of a1 and not a copy of it.  Array referencing never copies anything.]  Likewise, (array-ref a1 '(1 :)) [or equivalently, (array-ref a1 '(1))]  returns a reference to the second row of a1.&lt;br /&gt;&lt;br /&gt;Array mutation also allows partially qualified references.  In that case, the value specified must be broadcastable (described in a future post) to the shape of the reference.  For example, (array-set! a1 '(: 1) 1.0) sets the elements of the second column of a1 to 1,0 (yes, the scalar 1.0 is broadcastable to shape '(3)).  Likewise, (array-set! a1 '(1) '(4.0 8.0)) sets the elements of the second row of a1 to 4.0 and 8.0.&lt;br /&gt;&lt;br /&gt;A complete set of array manipulation functions will be provided.  This will include: build-array, array-map, array-map!, array-for-each (i.e., similar to what SRFI 43 provides for vectors).&lt;br /&gt;&lt;br /&gt;I haven't though about the semantics for things like array-fold and array-unfold.  They may be well-defined someplace - I really haven't looked.  If anyone knows where or has any ideas, please let me know.&lt;br /&gt;&lt;br /&gt;Note that it is not my intention to define functions like add, subtract, multiply, divide, ... (as numpy does for Python).  Rather, we will rely on the array mapping functions to extend scalar operations to arrays.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-613628625985489785?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/613628625985489785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=613628625985489785' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/613628625985489785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/613628625985489785'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2008/03/homogeneous-n-dimensional-arrays.html' title='Homogeneous, N-Dimensional Arrays (ndarrays)'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-2389764404227170668</id><published>2008-03-27T07:59:00.002-06:00</published><updated>2009-09-26T19:41:37.834-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='schemelab'/><title type='text'>Schemelab Concept</title><content type='html'>My PLT Scheme project for this year is to create a Schemelab collection to provide better analysis capabilities in PLT Scheme.  It will be something of a mini-Matlab with capabilities similar to what numpy, scipy, and matplotlib provide in Python.  I plan on making a new numeric collection to provide homogeneous, n-dimensional arrays (and, as a subset, matrices) as the primary underlying representation.  Next, the science collection will be updated to use the new numeric package.  Finally, a new plot collection will be developed to provide better visualization functionality.  [After these are done I'll also update the simulation and inference collections to use the new Schemelab packages.]&lt;br /&gt;&lt;br /&gt;I've already started work on the numeric collection.  The basic representational element is a homogeneous, n-dimensional array (ndarray).  An ndarray's type and shape are specified when it is created.  The type may be any of the element types allowed for SRFI 4 vector types (u8, u16, u32, u64, s8, s16, s32, s64, f32, or f64), a complex type (c64 or c128), or may hold any Scheme object (object).  The shape is a list of natural numbers where the length of the shape is the number of dimensions for the ndarray and each element is the cardinality of the corresponding dimension.  References to array elements will support array slicing (in any dimension) for both array accessing (array-ref) and mutation (array-set!).  Slicing operations create new views of the referenced array as opposed to copying portions of the array.  I will start posting entries on different aspects of the numeric collection in the next few days.&lt;br /&gt;&lt;br /&gt;The updates to the science collection to support (or to make use of internally) the new numeric collection should be relatively straightforward.  The main issue will be to retain compatibility with the existing data types (i.e. vectors).  Most of the really numerically complex code (e.g. special functions and random number distributions) will not be affected since they don't generally provide vector or array operations.  The main changes will be to the statistics and histogram modules, which will be modified to work with ndarrays as well as vectors.  Finally, some of the modules (e.g. histograms and ordinary differential equations) will benefit from being reimplemented using ndarrays internally.&lt;br /&gt;&lt;br /&gt;I've also prototyped some code for the new plot package that provides much more functionality than the current PLoT package.  The initial capability will be very much patterned after the functionality provided by Matlab (or more precisely, matplotlib for Python, which is also based on Matlab).  It provides precise control over the elements of a graph (or multiple subgraphs).  It also provides interactive graphics functionality for more dynamic analysis capabilities.&lt;br /&gt;&lt;br /&gt;Note that all of these new (or updated) collections require PLT Scheme Version 4 (currently 3.99) and are not compatible with earlier versions.  As such, I am not releasing them to PLaneT until either PLT Scheme Version 4 is officially released or there is a separate PLaneT repository for PLT Scheme Version 4 code.  I will be putting the code on the Schematics web site at some point.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-2389764404227170668?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/2389764404227170668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=2389764404227170668' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/2389764404227170668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/2389764404227170668'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2008/03/schemelab-concept.html' title='Schemelab Concept'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-308405177562428019</id><published>2007-11-19T13:11:00.000-07:00</published><updated>2009-09-26T19:37:34.529-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='science'/><title type='text'>PLT Scheme Science Collection Version 2.8</title><content type='html'>Version 2.8 of the PLT Scheme Science Collection has been released via PLaneT.  There are two major changes from Version 2.7:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The random-sources.ss file has been reverted back to its previous implementation.  This is because the interface for SRFI 27 was changed to be compatible with the pre PLT Scheme V371.1  version.  That is, Version 2.7 is only required for PLT Scheme V371.1 (which probably isn't being used by anyone).  Version 2.8 will work with V371 (and before) as well as with V371.2 and later.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Unchecked versions of many of the functions are now provided that bypass the contract check.  These are called internally where it is known that the contract would be met.  Obviously, they may also be called from user code in similar circumstances or where the contract check is not desired for some reason.&lt;/li&gt;&lt;/ul&gt;The unchecked version of a function  is provided by renaming the function in a provide statement.  The standard version is provided in a provide/contract statement.  A trivial example is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;(module test-unchecked mzscheme&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  (require (lib "contract.ss"))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  (provide&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;      (rename double unchecked-double))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  (provide/contract&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    (double&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;      (-&gt; real? real?)))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  (define (double x)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    (+ x x))&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;)&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This works fine.  But, I'm not sure there is any guarantee that it will work in the future.&lt;br /&gt;&lt;br /&gt;This will probably be the last revision before the release of PLT Scheme v4.0.  I have branched the source code (at the Schematics project on SourceForge) for the PLT Scheme Science Collection Version 3.0 to be released with PLT Scheme Version 4.0.  These changes will be tested using the PLT Scheme v3.99.x releases.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-308405177562428019?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/308405177562428019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=308405177562428019' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/308405177562428019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/308405177562428019'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2007/11/plt-scheme-science-collection-version.html' title='PLT Scheme Science Collection Version 2.8'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-5287088369259333858</id><published>2007-11-06T10:31:00.000-07:00</published><updated>2009-09-26T19:38:29.340-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='inference'/><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><category scheme='http://www.blogger.com/atom/ns#' term='science'/><title type='text'>Science, Simulation, and Inference Collections Source Code Moved to SourceForge</title><content type='html'>I finally got around to moving the source code for the science, simulation, and inference collections to the &lt;a href="http://sourceforge.net/projects/schematics/"&gt;schematics project at SourceForge&lt;/a&gt;.  This will help me manage the collections better and allow others to contribute more easily, if they wish.  Unfortunately, I've been rather busy with work and haven't had much opportunity to work with the collections.&lt;br /&gt;I have been playing around with Scribble for the documentation - it's currently in TeX.  I'm not sure Scribble is ready for prime time in terms of graphics and mathematics typesetting yet.&lt;br /&gt;Here is the status and high-level to-do list for the collections.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;PLT Scheme Science Collection&lt;br /&gt;&lt;/span&gt;The science collection is stable.  The only things I might add in the near-term are additional random distributions and ordinary differential equation solvers.  Also, if there are any capabilities that anyone would like added, drop me an e-mail.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;PLT Scheme Simulation Collection&lt;span style="font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;The simulation collection is where I have the most near-term activities.  I have pretty much finished the design of the process interactions capability, based on the Ada rendezvous mechanism.  Coding this up, with examples, and testing it are the next things to do.  I will then reimplement the current resource mechanism using interprocess interactions.&lt;br /&gt;Another thing I would like to do is to add vector valued variables.  This is pretty straightforward, but also requires implementing vector values histories and statistics.  It won't be hard, just a fair amount of coding.  I may also add complex (and maybe quaternian) valued variables also.&lt;br /&gt;The final thing for the simulation collection is to add components and a graphical construction method.  I'm still working this through.  Any ideas would be appreciated.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;PLT Scheme Inference Collection&lt;/span&gt;&lt;br /&gt;The inference collection is the one that still needs the most work.  I still haven't written the reference manual.  I will quit waiting for Scribble to shape up and just use TeX or OpenOffice.&lt;br /&gt;To improve performance, I need to add more indexing to the various internal data structures - e.g., use hash tables instead of association lists.  I have implemented indexing for existential pattern handling, but still need to add indexing for binding patterns and the agenda (at a minimum).&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-5287088369259333858?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/5287088369259333858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=5287088369259333858' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/5287088369259333858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/5287088369259333858'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2007/11/science-simulation-and-inference.html' title='Science, Simulation, and Inference Collections Source Code Moved to SourceForge'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-7596992374267293117</id><published>2007-05-13T08:49:00.000-06:00</published><updated>2009-09-26T19:38:29.340-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><title type='text'>PLT Scheme Simulation Collection Version 2.2 Released</title><content type='html'>Yesterday I released &lt;a href="http://planet.plt-scheme.org/display.ss?package=simulation.plt&amp;owner=williams"&gt;PLT Scheme Simulation Collection Version 2.2&lt;/a&gt; via &lt;a href="http://planet.plt-scheme.org/"&gt;PLaneT&lt;/a&gt;.  Version 2.2 includes some additional graphical examples.  See the &lt;a href="http://planet.plt-scheme.org/package-source/williams/simulation.plt/2/2/examples/"&gt;examples&lt;/a&gt; directory (in the PLaneT cache).  All of the graphical examples can be run under either DrScheme or MrEd (mred -r ...).&lt;br /&gt;The &lt;a href="http://planet.plt-scheme.org/package-source/williams/simulation.plt/2/2/examples/interactions.ss"&gt;interactions.ss&lt;/a&gt; example is still my favorite.  It shows the use of a simulation monitor to produce a visualization of a simulation, in this case,  the interaction of particles with both attractive and repulsive forces.  It is a hybrid simulation with both discrete-event (creating and deletion of particles) and continuous (modeling the forces) simulation elements.  The animation works very well when its window is on the top, but doesn't repaint when it has been hidden.  I have played a little with using a bitmap for the animation and transferring the bitmap to the canvas each update.  This fixes the repaint when it's hidden, but I haven't been able to get a decent looking animation without flicker or other artifacts.  A good animation example (or just plain help) would be appreciated.  The only other thing I'd like to add to this simulation is a was to stop the simulation.&lt;br /&gt;The other graphical examples aren't animations, they just provide a GUI for the simulation.  For each of these there was already a simulation with graphical elements (i.e., a histogram or other plot of simulation data).  The graphical example adds a GUI that allows simulation parameters to be modified.&lt;br /&gt;The best GUI example is &lt;a href="http://planet.plt-scheme.org/package-source/williams/simulation.plt/2/2/examples/open-closed-loop-graphical.ss"&gt;open-closed-loop-graphical.ss&lt;/a&gt;.  This provides an example GUI for performing analysis on a (very simple) system.  From the Edit &gt; Options ... menu, you can select either open-loop (infinite resources) or closed-loop (with a specified number of resources) processing and other simulation parameters.  The number of runs and number of customers per run are specified via sliders on the main window.  The results are displayed in a pane in the main window.&lt;br /&gt;As both a user of graphical tools (i.e., PLoT) and a provider of graphical tools, I am still annoyed at the differences between the various ways of providing graphical output in the PLT Scheme suite of tools (e.g., DrScheme, MrEd, and open-output-text-editor).  I thought I had a nice mental model of DrScheme as an IDE for graphical PLT Scheme programs and MrEd as a run-time for the same programs.  To the PLT Scheme developers the model seems to be that MrEd is (just) a tool to develop DrScheme and other graphical applications.  My mental model of a graphical PLT Scheme program is just an illusion.  Unfortunately, to people with my mental model, it seems that MrEd is just brain damaged with respect to executing what to me seems to be valid PLT Scheme graphical programs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-7596992374267293117?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/7596992374267293117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=7596992374267293117' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/7596992374267293117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/7596992374267293117'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2007/05/plt-scheme-simulation-collection.html' title='PLT Scheme Simulation Collection Version 2.2 Released'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-1198776235051174902</id><published>2007-04-06T15:25:00.000-06:00</published><updated>2009-09-26T19:38:29.341-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><title type='text'>Simulation Collection Version 2.1 Available</title><content type='html'>I just released Version 2.1 of the &lt;a href="http://planet.plt-scheme.org/display.ss?package=simulation.plt&amp;amp;owner=williams"&gt;Simulation Collection&lt;/a&gt; to &lt;a href="http://planet.plt-scheme.org/"&gt;PLaneT&lt;/a&gt;.  This fixes a bug in the variable monitors and updates the interacting particles example (interactions.ss) to illustrate their use in graphical simulations.  If anyone with more experience with graphics programming with MrED would look it over and make suggestions on improving it, I would appreciate it.&lt;br /&gt;Variables are used for automatic data collection in the Simulation Collection.  [Note that these variables are not Scheme identifiers with values associates with them, but a separate data type and associated semantics.]  Variable monitors allow arbitrary code to be attached to getting or setting a variable's value.  This is especially useful in adding graphics to a simulation.  In the particle interactions example, one is used to update the progress bar.&lt;br /&gt;The particle interactions example also uses a simulation monitor that is executed each time the simulation clock is advanced.  This provides the main simulation visualization.&lt;br /&gt;This weekend I plan on adding process monitors that are executed whenever a process event is executed.  This will be useful for updating graphics based on the (change in) state of a process.  I will also update the reference manual with a section on Monitors.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-1198776235051174902?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/1198776235051174902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=1198776235051174902' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/1198776235051174902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/1198776235051174902'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2007/04/simulation-collection-version-21.html' title='Simulation Collection Version 2.1 Available'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-115912689712071049</id><published>2006-09-24T13:35:00.000-06:00</published><updated>2009-09-26T19:36:32.910-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='inference'/><title type='text'>Inference Collection - Fact Modification Semantics</title><content type='html'>I need to specify the semantics for the various ways to change a fact in the inference engine.  There are three ways to reassert a fact.  The first is to explicitly retract the existing assertion and then to assert its replacement.  The second is to replace an assertion using the replace function.  The third is to modify (the fact within) an assertion using the modify function.  Each of these has a different set of semantics - largely associated with the level of reuse.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Retract and Assert&lt;/span&gt;&lt;br /&gt;By explicitly retracting an assertion, all reference to it should be removed.  This is true in terms of the rule network, but currently references to the assertion may still exist in rule instances retained as the reasons for other assertions.  I need to think of a better mechanism to retain the relevant information from the rule instance or give up on consistency when reusing assertions or facts.&lt;br /&gt;One approach would be to sanitize the rule instance before using it as a reason.  This would involve removing the assertion list (easy) and any assertion variables from the bindings.  [These would not be reliable as reasons following any replace or modify of tge assertion.]&lt;br /&gt;An alternative is to try to determine which assertion references are still valid following a replace or modity.  We could remove any such references (in reason fields) or we could maintain a generation field and have an explicit assertion reference type with generation checking.&lt;br /&gt;For now, I will document the inconsistence problem and live with it.  It only affect debugging at the moment anyway.]  I will revisit this when I implement truth maintenance in the future.&lt;br /&gt;In any case, a separate retract and assert does not provide any reuse of assertions and the above problems will not occur.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Replace&lt;/span&gt;&lt;br /&gt;Currently, replace literally implements an assert preceded by a retract as above.  I will change this to reuse the assertion object for the next release.  This will have the inconsistenct problem noted above.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Modify&lt;/span&gt;&lt;br /&gt;The new modify functionality will reuse the underlying fact object within the assertion object being modified.  Only the fields that are specified will be changed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-115912689712071049?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/115912689712071049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=115912689712071049' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/115912689712071049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/115912689712071049'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2006/09/inference-collection-fact-modification.html' title='Inference Collection - Fact Modification Semantics'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-115884382295993095</id><published>2006-09-21T07:02:00.000-06:00</published><updated>2009-09-26T19:36:32.910-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='inference'/><title type='text'>PLT Scheme Inference Collection</title><content type='html'>The PLT Scheme Inference Collection has been released.  Version 1.3 is the current released version.&lt;br /&gt;All of the basic functionality has been implemented.  There are several examples coded: ancestors, Towers of Hanoi, and Sudoku.  The Sudoku example is the most complex requiring a search (using hierarchical inference environments).&lt;br /&gt;I am not satisfied with the current implementation of 'modify'.  I am going to rename the current functionality to be 'replace'.  The semantics match that new term better.&lt;br /&gt;I need to implement a real modify functionality that does modify the underlying fact object.  This will be useful with fact objects with names fields: association lists, structures, and class instances.  The primary additional work is how to map field names to their location in the fact object.  Association lists aren't a problem since the field names are stored in the association list.  I haven't found any way to get the names of structure fields - and I'm not sure there is any way to do so.  Class instances are still a future implementation feature - but it does seem to be possible to get the field names for classes.&lt;br /&gt;The initial implementation for modify will just support association lists.  This will not require any additional syntax beyond modify itself.&lt;br /&gt;Next, I will implement the modify functionality for structures.  This will likely involve a new syntax - define-template - to supply the field names.  It will have essentially the same syntax as define-struct.  I will also implement define-struct/template that does the structure definition and template definition in one call.&lt;br /&gt;This will also make it easier to implement the rule-based system benchmarks.  I would like to code and bechmark the performance of the system before I begin adding more efficient algorithms (i.e. hashing for node matches).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-115884382295993095?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/115884382295993095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=115884382295993095' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/115884382295993095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/115884382295993095'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2006/09/plt-scheme-inference-collection.html' title='PLT Scheme Inference Collection'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-115282930399484201</id><published>2006-07-13T16:13:00.000-06:00</published><updated>2009-09-26T19:36:32.911-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='inference'/><title type='text'>Inference Collection Prototype</title><content type='html'>I have been working on  the prototype of the Inference Collection.  It is now working for data-driven (forward chaining) rules.  This includes existential (i,e, no, any, not all, all) joins, binding joins, and constraints.&lt;br /&gt;To keep the code simpler, the prototype does not include the syntax elements (e.g. define-rule).  Instead, the rule instances are created directly.  I have protptyped the syntax elements separately and need to merge them in at some point.  I will likely wait until after I get goal-driven (backward chaining) rules working.&lt;br /&gt;The rule network consists of three basic type of nodes:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Match nodes&lt;/li&gt;&lt;li&gt;Join nodes&lt;/li&gt;&lt;li&gt;Rule nodes&lt;/li&gt;&lt;/ul&gt;The simple data-driven rule set I have been using is for finding ancestors.  It only uses binding joins.  The rule set, using the define-rule format is:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(define-ruleset ancestors)&lt;br /&gt;&lt;br /&gt;(define-rule (initialize ancestors)&lt;br /&gt;  ?start &lt;- (start)  &lt;br /&gt; --&gt;&lt;br /&gt;  (retract ?start)&lt;br /&gt;  (printf "Please enter the first name of a~n")&lt;br /&gt;  (printf "person whose ancestors you would~n")&lt;br /&gt;  (printf "like to find:~n")&lt;br /&gt;  (assert `(request ,(read))))&lt;br /&gt;&lt;br /&gt;(define-rule (print-ancestor ancestors)&lt;br /&gt;  ?request &lt;- (request ?name)  &lt;br /&gt;  (parents ?name ?mother ?father)  &lt;br /&gt; --&gt;&lt;br /&gt;  (retract ?request)&lt;br /&gt;  (when ?mother&lt;br /&gt;      (printf "~a is an ancestor via ~a~n" ?mother ?name)&lt;br /&gt;      (assert `(request ,?mother)))&lt;br /&gt;  (when ?father&lt;br /&gt;      (printf "~a is an ancestor via ~a~n" ?father ?name)&lt;br /&gt;      (assert `(request ,?father))))&lt;br /&gt;&lt;br /&gt;(define-rule (remove-request ancestors)&lt;br /&gt;  ?request &lt;- (request ?) &lt;br /&gt; --&gt;&lt;br /&gt;  (remove ?request))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When this rule set is activated, it results in a rule network with 4 match nodes (1 for each precondition clause), 5 join nodes (1 initial join and 1 for each precondition clause), and 3 rule nodes (1 for each rule).&lt;br /&gt;&lt;br /&gt;A more complex ruleset that includes existential joins is one that solves the Towers of Hanoi problem.&lt;br /&gt;&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;(define-ruleset towers)&lt;br /&gt;&lt;br /&gt;(define-rule (rule-1 towers)&lt;br /&gt;    - (ring ? on left)&lt;br /&gt;    - (ring ? on middle)&lt;br /&gt;  --&gt;&lt;br /&gt;    (printf "Problem solved!~n"))&lt;br /&gt;&lt;br /&gt;(define-rule (rule-2 towers)&lt;br /&gt;    - (move)&lt;br /&gt;      (ring ?ring on (?peg (not (eq? ?peg 'right))))&lt;br /&gt;    - (ring (?ring-1 (&gt; ?ring-1 ?ring))&lt;br /&gt;            on (?peg-1 (not (eq? ?peg-1 'right))))&lt;br /&gt;  --&gt;&lt;br /&gt;    (assert `(move ?ring from ?peg to right)))&lt;br /&gt;&lt;br /&gt;(define-rule (rule-3 towers)&lt;br /&gt;      ?move-assertion &lt;- (move ?ring from ?from to ?to)&lt;br /&gt;      ?ring-assertion &lt;- (ring ?ring on ?from)&lt;br /&gt;    - (ring (?ring-1 (&lt; ?ring-1 ?ring)) on ?from)&lt;br /&gt;    - (ring (?ring-2 (&lt; ?ring-2 ?ring)) on ?to)&lt;br /&gt;  --&gt;&lt;br /&gt;    (printf "Move ring ~a from ~a to ~a.~n" ?ring ?from ?to)&lt;br /&gt;    (modify ?ring-assertion `(ring ,?ring on ,?to))&lt;br /&gt;    (retract ?move-assertion))&lt;br /&gt;&lt;br /&gt;(define (rule-4 towers)&lt;br /&gt;      ?move-assertion &lt;- (move ?ring from ?from to ?to)&lt;br /&gt;      (peg (?other (not (memq ?other (list ?from ?to)))))&lt;br /&gt;      (ring (?ring-1 (&lt; ?ring-1 ?ring))&lt;br /&gt;            on (?peg-1 (not (eq? ?peg-1 ?other))))&lt;br /&gt;    - (ring (?ring-2 (&lt; ?ring-1 ?ring-2 ?ring))&lt;br /&gt;            on (?peg-2 (not (eq? ?peg-2 ?other))))&lt;br /&gt;  --&gt;&lt;br /&gt;    (modify ?move-assertion `(move ,?ring-1 from ,?peg-1 to ,?other)))))&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;&lt;br /&gt;I will post a separate entry explaining this ruleset.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-115282930399484201?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/115282930399484201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=115282930399484201' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/115282930399484201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/115282930399484201'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2006/07/inference-collection-prototype.html' title='Inference Collection Prototype'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-114917533110803040</id><published>2006-06-01T09:08:00.000-06:00</published><updated>2009-09-26T19:38:29.341-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><category scheme='http://www.blogger.com/atom/ns#' term='science'/><title type='text'>Links to Presentations on the Science and Simulation Collections</title><content type='html'>I have given a couple of talks at local Lisp users groups in Denver and Vancouver on Knowledge-Based Simulation.  To date these have covered the Science Collection and the Simulation Collection.  Thanks to Bill Clementson who taped each of the presentations and provided links to them and the presentation materials in his &lt;a href="http://bc.tech.coop/blog/index.html"&gt;blog&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The first presentation is from the &lt;a href="http://bc.tech.coop/blog/041011.html"&gt;September 2004 Denver Area Lisp Users Group (DALUG) meeting&lt;/a&gt; and primarily covers the science collection.  This includes links to a video of the presentation and to the presentation slides.  An update to the post includes a link to an audio only version of the presentation.&lt;br /&gt;&lt;br /&gt;The second presentation is from the &lt;a href="http://bc.tech.coop/blog/060219.html"&gt;February 2006 Vancouver Lisp Users Group (lispvan) meeting&lt;/a&gt; on the PLT Scheme Simulation Collection.  This also includes links to a video of the presentation, the presentation slides, and to the documentation for both the science and simulation collections.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-114917533110803040?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/114917533110803040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=114917533110803040' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114917533110803040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114917533110803040'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2006/06/links-to-presentations-on-science-and.html' title='Links to Presentations on the Science and Simulation Collections'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-114911705650868889</id><published>2006-05-31T17:01:00.000-06:00</published><updated>2009-09-26T19:38:29.341-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><title type='text'>Syntax for Interprocess Communication in the Simulation Collection</title><content type='html'>I am planning on extending the simulation collection to include interprocess  communications (and synchronization) functionality based of Ada task interactions.  Note that this is between processes in the simulation collection, not OS processes.&lt;br /&gt;&lt;br /&gt;This will allow the model developer to more easily specify process interactions.  For examples, resources could be implemented using this functionality.  &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Entry Definition&lt;br /&gt;&lt;/span&gt;Each process entry must be declared in the define-process macro call that defines the process.&lt;br /&gt;&lt;pre&gt;(entry (&lt;span style="font-style: italic;"&gt;name&lt;/span&gt; . &lt;span style="font-style: italic;"&gt;arguments&lt;/span&gt;))&lt;/pre&gt;&lt;span style="font-weight: bold;"&gt;Entry Acceptance&lt;/span&gt;&lt;br /&gt;The simplest use of an entry is the accept statement.&lt;br /&gt;&lt;pre&gt;(accept (&lt;span style="font-style: italic;"&gt;name&lt;/span&gt; . &lt;span style="font-style: italic;"&gt;arguments&lt;/span&gt;)&lt;br /&gt;&lt;span style="font-style: italic;"&gt;body&lt;/span&gt;...)&lt;/pre&gt;This is an executable statement that will either accept the first (i.e. highest priority) call to &lt;span style="font-style:  italic;"&gt;name&lt;/span&gt; or wait until such a call occurs.&lt;br /&gt;The select statement allows more control over the selection of entry calls.&lt;br /&gt;&lt;pre&gt;(select&lt;br /&gt;&lt;span style="font-style: italic;"&gt;accept-clause&lt;/span&gt;&lt;br /&gt;...)&lt;/pre&gt;Each select clause has one of the following forms:&lt;br /&gt;&lt;pre&gt;((accept (&lt;span style="font-style: italic;"&gt;name&lt;/span&gt; . &lt;span style="font-style: italic;"&gt;arguments&lt;/span&gt;)&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    body&lt;/span&gt; ...)&lt;br /&gt;&lt;span style="font-style: italic;"&gt; body&lt;/span&gt; ...)&lt;br /&gt;&lt;br /&gt;((&lt;span style="font-style: italic;"&gt;expr&lt;/span&gt;)&lt;br /&gt;(accept (&lt;span style="font-style: italic;"&gt;name&lt;/span&gt; . &lt;span style="font-style: italic;"&gt;arguments&lt;/span&gt;)&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    body&lt;/span&gt; ...)&lt;br /&gt;&lt;span style="font-style: italic;"&gt; body&lt;/span&gt; ...)&lt;br /&gt;&lt;br /&gt;((delay &lt;span style="font-style: italic;"&gt;n&lt;/span&gt;)&lt;br /&gt;&lt;span style="font-style: italic;"&gt; body&lt;/span&gt; ...)&lt;br /&gt;&lt;br /&gt;(else&lt;br /&gt;&lt;span style="font-style: italic;"&gt; body&lt;/span&gt; ...)&lt;/pre&gt;The first clause specifies an unguarded accept statement.  That is, there are no conditions on its acceptance.  The second clause specified a guarded clause.  The accept is only active if the guard expression evaluates to true.  The third clause is a timeout.  The body will be evaluated if none of the alternatives have been accept before the specified (simulated) time has elapsed.  The last is an else clause.  Its body will be evaluated of no other clause is active.&lt;br /&gt;&lt;br /&gt;[We could also allow a simple accept statement as an alternative when no code is specified other than the entry code itself.  That is, allow the following:&lt;br /&gt;&lt;pre&gt;(select (&lt;span style="font-style: italic;"&gt;name&lt;/span&gt; . &lt;span style="font-style: italic;"&gt;arguments&lt;/span&gt;)&lt;br /&gt; &lt;span style="font-style: italic;"&gt;body&lt;/span&gt; ...)&lt;/pre&gt;Simple examples:&lt;br /&gt;&lt;pre&gt;(define-process (test)&lt;br /&gt;   (entry (abc a b c))&lt;br /&gt;   ...&lt;br /&gt;   (accept (abc a b c)&lt;br /&gt;      (printf "a=~s b=~s c=~s~n" a b c))&lt;br /&gt;   ...)&lt;br /&gt;&lt;br /&gt;(define-process (test)&lt;br /&gt;   (entry (abc a b c))&lt;br /&gt;   ...&lt;br /&gt;   (select&lt;br /&gt;      (accept (abc a b c)&lt;br /&gt;         (printf "a=~s b=~s c=~s~n" a b c))&lt;br /&gt;      (else&lt;br /&gt;         (printf "No entry waiting~n")))&lt;br /&gt;   ...)&lt;br /&gt;&lt;br /&gt;(define-process (test)&lt;br /&gt;   (entry (abc a b c))&lt;br /&gt;   ...&lt;br /&gt;   (select&lt;br /&gt;      (accept (abc a b c)&lt;br /&gt;         (printf "a=~s b=~s c=~s~n" a b c))&lt;br /&gt;      ((delay 10.0)&lt;br /&gt;       (printf "No entry after waiting 10.0 units~n")))&lt;br /&gt;   ...)&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Entry Calls&lt;/span&gt;&lt;br /&gt;For now, I will implement an enter statement with a syntax similar to the send statement for classes:&lt;br /&gt;&lt;br /&gt;(enter &lt;span style="font-style: italic;"&gt;process-instance&lt;/span&gt; &lt;span style="font-style: italic;"&gt;name . arguments&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;A more advanced use is to also allow the select statement with wither a delay or an else clause.&lt;br /&gt;&lt;pre&gt;(define my-test (make-process test))&lt;br /&gt;&lt;br /&gt;(select&lt;br /&gt;  (enter my-test x y z)&lt;br /&gt;  ((delay 10.0)&lt;br /&gt;   (printf "Entry no accepted after 10.0 units~n")))&lt;br /&gt;&lt;br /&gt;(select&lt;br /&gt;  (enter my-test x y z)&lt;br /&gt;  (else&lt;br /&gt;   (printf "Entry not open~n")))&lt;/pre&gt;&lt;br /&gt;I need to decide if it makes any sense to allow other code after the entry call but withn the select.&lt;br /&gt;&lt;br /&gt;Since the delay and else clauses don't make sense together (because a delay will always be open), I could combine them:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;(else&lt;br /&gt; [(delay &lt;span style="font-style: italic;"&gt;n&lt;/span&gt;)]&lt;br /&gt;&lt;span style="font-style: italic;"&gt; body&lt;/span&gt; ...)&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/pre&gt;I will cover possible implementation strategies in a later post.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-114911705650868889?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/114911705650868889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=114911705650868889' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114911705650868889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114911705650868889'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2006/05/syntax-for-interprocess-communication.html' title='Syntax for Interprocess Communication in the Simulation Collection'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-114911416437165165</id><published>2006-05-31T16:16:00.000-06:00</published><updated>2009-09-26T19:38:29.341-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><title type='text'>PLT Scheme Simulation Collection</title><content type='html'>&lt;span style="font-family:verdana;"&gt;The PLT Scheme Simulation Collection implements a combined discrete event and continuous event simulation engine for developing simulation models in PLT Scheme.  The simulation engine: &lt;/span&gt;&lt;br /&gt;&lt;ul style="font-family: verdana;"&gt;&lt;li&gt;Provides a process-based, discrete event simulation engine &lt;/li&gt;&lt;li&gt;Supports combined discrete and continuous simulation models &lt;/li&gt;&lt;li&gt;Provides automatic data collection &lt;/li&gt;&lt;li&gt;Is designed to facilitate construction of component-based simulation models &lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:verdana;"&gt;The source code is distributed with the simulation collection and licensed under the GNU Lesser General Public License (LGPL).&lt;br /&gt;&lt;br /&gt;The PLT Scheme Simulation Collection provides the following functionality for building and executing simulation models:&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Simulation Environments (Basic) &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Simulation Control (Basic) &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Events &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Processes &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Resources &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Data Collection &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Sets &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Continuous Simulation Models &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Monitors &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Simulation Classes &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Simulation Control (Advanced) &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Simulation Environments (Hierarchical) &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Components&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;The PLT Scheme Simulation Collection is available via the PLaneT repository using the following form:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;(require (planet "simulation.ss" ("williams" "simulation.plt")))&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;&lt;br /&gt;This will download and install the latest version of the simulation collection. The reference manual is available on the PLT Scheme Help Desk once the collection is installed.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;I am still actively developing the PLT Scheme Simulation Collection.  The Simulation Classes needs to be enhanced.  The Hierarchical Simulation Environments and Components functionality needs to be completed,  Also, I plan on added a process interaction capability using a rendezvous mechanism (similar to Ada task interactions).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Verson 2.0&lt;/span&gt;&lt;br /&gt;Version 2.0 of the PLT Scheme Simulation Collection features a full Reference Manual that is compatible with the PLT Scheme Help Desk. The reference manual was written in TEX and converted to HTML using tex2page. A pdf version of the reference manual is also available.&lt;br /&gt;&lt;br /&gt;Version 2.0 also provides priority ordering for events and resource allocation; reneging for resources; and linking event execution.&lt;br /&gt;&lt;br /&gt;Finally, Version 2.0 adds a monitor capability for simulation timing and for variables.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Bug Fixes&lt;/span&gt;&lt;br /&gt;The schedule macro was changed to generate code that is compatible with its use within a module. Previously, it generated code that worked only at the top level.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-114911416437165165?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/114911416437165165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=114911416437165165' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114911416437165165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114911416437165165'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2006/05/plt-scheme-simulation-collection.html' title='PLT Scheme Simulation Collection'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-114903697085016717</id><published>2006-05-30T18:55:00.000-06:00</published><updated>2009-09-26T19:37:34.530-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='science'/><title type='text'>PLT Scheme Science Collection</title><content type='html'>The PLT Scheme Science Collection is a collection of modules that provide functions for numerical computing.  The structure of the science collection and many of the underlying algorithms were inspired by the GNU Scientific Library (GSL).  The functions are written entirely in PLT Scheme and present a true Scheme look-and-feel throughout.  The source code is distributed with the science collection and licensed under the GNU Lesser General Public License (LGPL).&lt;br /&gt;The PLT Scheme Science Collection covers a range of topics in numerical computing.  Functions are available for the following areas:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Mathematical Constants and Functions&lt;/li&gt;&lt;li&gt;Special Functions&lt;/li&gt;&lt;li&gt;Random Numbers&lt;/li&gt;&lt;li&gt;Random Distributions&lt;/li&gt;&lt;li&gt;Statistics&lt;/li&gt;&lt;li&gt;Histograms&lt;/li&gt;&lt;li&gt;Orginary Differential Equations&lt;/li&gt;&lt;li&gt;Chebyshev Approximations&lt;/li&gt;&lt;/ul&gt;The PLT Scheme Science Collection is available via the PLaneT repository using the following form:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;(require (planet "science.ss" ("williams" "science.plt")))&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;&lt;br /&gt;This will download and install the latest version of the science collection.  The reference manual is available on the PLT Scheme Help Desk once the collection is installed.&lt;br /&gt;I don't have any updates scheduled for the PLT Scheme Science Collection.  Bugs reports or requests for enhancements are welcome, however.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Version 2.2.1&lt;/span&gt;&lt;br /&gt;Version 2.2.1 is a point release of Version 2.2 where the discrete random routines were reimplemented using Walker's O(1) algorithm.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Version 2.2&lt;/span&gt;&lt;br /&gt;Version 2.2 of the PLT Scheme Science Collection features a reformatted Reference Manual that is compatible with the PLT Scheme Help Desk.  The reference manual was written in TeX  and converted to HTML using tex2page.  A pdf version of the reference manual is also available.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Bug Fixes&lt;/span&gt;&lt;br /&gt;The &lt;span style="font-family:courier new;"&gt;gamma-inc-Q&lt;/span&gt; function has been added.  It was accidentally stubbed out in Version 2.1&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Version 2.1&lt;/span&gt;&lt;br /&gt;Version 2.1 of the PLT Scheme Science Collection added cummulative density functions for the rest of the 1-dimensional, continuous distributions (except the Gaussian tail distribution).  The corresponding graphics routines were also updated to plot the cummulative density functions.  Also, beta, incomplete gamma, and exponential integral special functions were implemented.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Bug Fixes&lt;/span&gt;&lt;br /&gt;The lngamma function returned incorrect values for positive values less than 0.5.&lt;br /&gt;&lt;br /&gt;Downloading the science collection from PLaneT on a computer with less than(approximately) 1GB of memory failed.  This is caused in a bug in the PLT Scheme setup collection that fails on large files.  The pdf file for the reference manual -- the large file that caused the problem -- was removed from the distributed science collection.&lt;br /&gt;&lt;br /&gt;2-dimensional histogram plots failed.  This was an error in the PLoT package distributed with PLT Scheme.  It is fixed in V301.5 and later.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Version 2.0&lt;/span&gt;&lt;br /&gt;Version 2.0 of the PLT Scheme Science Collection added ordinary differential equations.  These were needed for the PLT Scheme Simulation Collection.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-114903697085016717?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/114903697085016717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=114903697085016717' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114903697085016717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114903697085016717'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2006/05/plt-scheme-science-collection.html' title='PLT Scheme Science Collection'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28856939.post-114878063248981942</id><published>2006-05-27T19:39:00.001-06:00</published><updated>2009-09-26T19:40:37.176-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='inference'/><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><category scheme='http://www.blogger.com/atom/ns#' term='PLT Scheme'/><category scheme='http://www.blogger.com/atom/ns#' term='science'/><title type='text'>PLT Scheme Projects</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/8083/3062/320/photo1.0.jpg" alt="" border="0" /&gt;&lt;/a&gt;This blog is about my various open source PLT Scheme projects.  There are three major Scheme projects I am currently working on.  Two of these - PLT Scheme Science Collection and PLT Scheme Simulation Collection - have already been released.  The third - PLT Scheme Inference Collection - is currently under development.&lt;br /&gt;I had developed a knowledge-based simulation capability in Symbolics Common Lisp back in the late 1980s.  I moved on to more traditional simulation technologies in my professional career and the work was largely forgotten.  In the 1990s as PCs made their way into the classroom, I began using Scheme for teaching AI.  However, at the time I didn't consider Scheme to be suitable for production quality software.&lt;br /&gt;A few years ago, I came across PLT Scheme that seemed to meet my needs: it had an integrated development environment, it supported modern programming paradigms (e.g. object oriented programming, graphical user interfaces, exception handling, and modules), it was reasonably efficient, and it was portable across Windows and Linux, which are my two main platforms.  Eventually I decided to resurrect my knowledge-based simulation work in PLT Scheme.&lt;br /&gt;It was obvious that a simple port of the original Common Lisp code was not the best approach to the problem.  I decomposed the problem into three basic components: the underlying mathematical and analysis capability, the simulation engine, and the inference engine.  These became the science collection, simulation collection, and inference collection.&lt;br /&gt;As I began developing the science collection, I noticed that much of what I needed was in the GNU Scientific Library (GSL).  So, I decided that I would use the structure, and algorithms to the extent practical, of the GSL for the science collection.  Version 1.0 of the PLT Scheme Science Collection was released via PLaneT in October 2004.&lt;br /&gt;The simulation collection is a complete rewrite from the Common Lisp code.  One of the advantages of Scheme is the availability of continuations, which are ideally suited for the implementation of a process-based simulation engine.  I also decided to add a continuous simulation capability to the simulation engine.  Version 1.0 of the PLT Scheme Simulation Collection was released in August 2005.&lt;br /&gt;With my background in Artificial Intelligence, I was somewhat surprised at myself for leaving the inference collection as the last of the three to be implemented; particularly since I already have a Scheme version of a naive inference engine written.  But, it made sense that way.  It also turns out that the inference collection is a complete rewrite of the Common Lisp (and earlier Scheme) code.  I plan on releasing Version 1.0 of the PLT Scheme Inference Collection during the summer of 2006.&lt;br /&gt;I also have some Scheme programs that I have used in teaching AI classes over the years.  Over time, I will convert these to PLT Scheme and make them available.  The only one I have converted so far is a collection for defining state space problems and solving them using a graph search algorithm.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28856939-114878063248981942?l=drschemer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://drschemer.blogspot.com/feeds/114878063248981942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28856939&amp;postID=114878063248981942' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114878063248981942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28856939/posts/default/114878063248981942'/><link rel='alternate' type='text/html' href='http://drschemer.blogspot.com/2006/05/plt-scheme-projects.html' title='PLT Scheme Projects'/><author><name>Doug Williams</name><uri>http://www.blogger.com/profile/11823762612932116497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://photos1.blogger.com/blogger/8083/3062/1600/photo1.0.jpg'/></author><thr:total>0</thr:total></entry></feed>
