[plt-scheme] Defining resource constrained producer/consumer in the simulation package

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Mon Jun 23 11:53:30 EDT 2008

The resources in the simulation collection are more simplistic than what you
want.  In particular, there is no way to pass a particular resource between
processes - they are always owned by the process that allocated them.  [You
could have one controller process that allocates the resource and controls
the execution of A and B, but that seems too artificial.]

The simplest solution is to use sets to implement the queues (and enforce
the limits yourself).  The sets can contain any type of objects you want to
pass around.  In the examples, the furnace model(s) use sets - model-1 is a
discrete-event simulation and might be closer to what you're doing.  The
harbor model example also uses sets and also shows more advances control

I'll reload 3.72 on one of my machines and send you a quick solution.  I'll
still having problems with V4.0 (and V4.0.1) and haven't gotten the
simulation and inference collections ported yet.


On Mon, Jun 23, 2008 at 8:55 AM, Noel Welsh <noelwelsh at gmail.com> wrote:

> Hi,
> I am trying to define the following producer/consumer process using
> the simulation package:
> There is a queue of resources of type A.
> Process X takes an A and produces a B (which contains the A).  The B
> is placed in a queue of fixed size
> Process Y takes a B, returns the A its queue and throws away the B.
> If any queue is empty a process that needs a resource of that type
> must wait.  If any queue is full a process that creates a resource of
> that type must wait.
> I can't work out how to model this.  If I model the As and Bs as
> resources, I have the problem that "It is an error to attempt to
> release more units than the process has allocated."
> (
> http://planet.plt-scheme.org/package-source/williams/simulation.plt/2/2/html/simulation-Z-H-8.html#node_sec_7.2.2
> ).
>  Since X takes A and never releases them, and Y releases As but never
> takes them, this is a problem.
> If I schedule As and Bs as events how do I enforce the resource limits?
> This kind of simulation is simple in a message passing thread system
> but I don't see how it fits into the simulation package's model.
> Also: the documentation for the simulation package would benefit from
> an introductory section that lays out the model used by the package.
> Thanks,
> Noel
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080623/4dbbe574/attachment.html>

Posted on the users mailing list.