Loading


Queue system configuration exampleThis is a small toy example that shows how different model configurations can be easily defined and simulated when model parameters are defined as reference variables. The model is a variation of the Queue system example example. You should be familiar with the Queue system example example before reading about this example. This example will show how a function can be used to define and simulate a number of different configurations of a model. This net can be found in <cpntoolsdir>/Samples/QueueSystem/QueueSystemConfigs.cpn where <cpntoolsdir> is the directory in which CPN Tools is installed. The net can also be downloaded here. Model ConfigurationsIt is often necessary to analyze and compare the behavior of different configurations of a model. It is always possible to change the configuration of a model by manually editing declarations, net structure, and/or net inscriptions. However, it can be quite time consuming to make manual changes to a model, particularly if the changes require that a syntax check has to be done for large parts of the model, and/or if many different configurations have to be defined and investigated. If model parameters are defined as reference variables, then it is possible to use CPN ML functions to automatically define and simulate different configurations of a model. In the Queue system example, there are several model parameters that affect the behavior of the system, including:
In this example, we will consider model configurations in which the distribution of interarrival times and the queuing strategy will not be changed. As for the Queue system example example net, the interarrival times for jobs is exponentially distributed with a mean interarrival time of 100 time units, and the queuing strategy is firstinfirstout (FIFO). In contrast to the Queue system example example net, this example will geared towards investigating model configurations in which the following parameters vary: the number of servers, the average processing time, and the probability distribution of processing times. Each configuration will have either one server with relatively fast processing times, or two servers with slower processing times. And the processing times will be either exponentially distributed or uniformly distributed integers. DeclarationsMany of the declarations for this net are the same as the net for the Queue system example. The following declarations are unique for this example, and they are briefly explained below. colset ProcDist = with DISCRETE  EXP; globref num_of_servers = 4; globref avg_proc_time = 360; globref procdist = EXP; fun initServers() = (!num_of_servers)`server; fun genProcTime() = case !procdist of EXP => expTime(!avg_proc_time)  DISCRETE => discrete (!avg_proc_time  10, !avg_proc_time + 10) fun simulateConfigs(n:int) = let fun setOneServer() = (num_of_servers:=1; avg_proc_time:=90) fun setTwoServers() = (num_of_servers:=2; avg_proc_time:=180) in procdist := EXP; setOneServer(); CPN'Replications.nreplications n; setTwoServers(); CPN'Replications.nreplications n; procdist := DISCRETE; setOneServer(); CPN'Replications.nreplications n; setTwoServers(); CPN'Replications.nreplications n end
Values from the
The reference variables
The It is important to note that the contents of the reference variables are never changed when transitions occur in the model. The values of these variables should only be changed immediately before a simulation is started.
The
The
The function ModelThis model contains 3 pages with net structure: System, Arrivals, and Server. The System and Arrivals pages are the same as in the Queue system example example. The Server page for this example is somewhat different than the Server page in the Queue system example example, and it looks like this:
The Init place and transition are used to initialize the number of servers represented in the system. These nodes are used for technical reasons, as described in the help page for model parameters. The Init transition is only enabled at the beginning of a simulation, and it can only occur once during a simulation. When it occurs, the
The MonitorsFour monitors have been defined for the model: The Queue Length monitor is a list length data collector monitor that measures the length of the list on place Queue. This monitor is similar to the List_length_dc_System'Queue_1 monitor described on the help page for Queue system queue length. The Queue Delay monitor is a generic data collector monitor that measures the amount of time that a job spent in a queue. Queue delay is measured each time the Start transition occurs. This monitor is the same as the Queue Delay monitor described on the help page for Queue system queue delay. The ParameterValues monitor is a writeinfile monitor. It will update a file once during a simulation when the Init transition on the Server page occurs. The monitor's observation function is defined to generate a string containing information about the current values of the three reference variables: fun obs (bindelem) = "Number of servers: "^(Int.toString(!num_of_servers))^ "\nAverage processing time: "^(Int.toString(!avg_proc_time))^ "\nDistribution of processing times: "^ProcDist.mkstr(!procdist) The One Hundred Queue Delays monitor is a breakpoint monitor that is defined to stop a simulation after 100 jobs have been removed from the queue. This monitor is similar to the OneHundred_QueueDelays monitor described on the help page for Queue System Miscellaneous Monitors. Simulating several configurations
Given the
Simulations of each of these four configurations can be run by applying the Evaluate ML tool to an auxiliary text containing a CPN ML expression that calls the 
