This page describes a number of additional monitors for the Queue System net.

Count_trans_occur_Arrivals’Arrive_1

This monitor is a Count Transition Occurrences monitor. It calculates the number of times the Arrive transition on the page Arrivals occurs during a simulation.

Count transition occurrences monitor

Count transition occurrences monitor

Processed_A_Jobs

This is a data collector monitor that counts how many jobs of job type A are processed by the server during a simulation. This monitor is somewhat similar to the Count_trans_occur_Arrivals'Arrive_1 monitor, but rather than just counting the number of times a particular transition occurs, it counts the number of times that a transition with a particular binding occurs.

The monitor is associated with the Stop transition, and it calculates untimed statistics.

Processed A Jobs monitor

Processed A Jobs monitor

This monitor does not need to collect data either before a simulation starts or when stop criteria are fulfilled. Therefore, the initialization and stop functions both return the value NONE.

The predicate function returns true when the Stop transition occurs, and when the job type of the job bound to the variable job is A. The # operator is a operator for record color sets, and it is used here to access the value of the jobType field for the record that is bound to the variable job.

fun pred (bindelem) =
let
fun predBindElem (Server’Stop (1, {job})) = (#jobType job)=A
| predBindElem _ = false
in
predBindElem bindelem
end

The observation function returns the value 1 whenever the predicate function returns true, i.e. whenever the server finishes processing a job of type A.

fun obs (bindelem) =
let
fun obsBindElem (Server’Stop (1, {job})) = 1
| obsBindElem _ = ~1
in
obsBindElem bindelem
end

Both the count and sum statistics for this monitor will indicate how many jobs of type A are processed during a simulation.

OneHundred_QueueDelays

This is a breakpoint monitor that is used to stop a simulation when 100 jobs have passed through the queue of jobs. The monitor is associated with the Start transition.

Breakpoint monitor based on queue delays

Breakpoint monitor based on queue delays

The predicate function accesses the count statistic for the Queue Delay monitor each time the Start transition occurs. When the count is equal to 100, i.e. when the queue delay has been measured for 100 jobs, then the predicate function will return true, and the simulation will stop.

fun pred (bindelem) =
let
fun predBindElem (Server’Start (1, {jobs, job,proctime})) =
Queue_Delay.count()=100
| predBindElem _ = false

in
predBindElem bindelem
end

Place_content_bp_Server’Completed_1

This is a Place Contents breakpoint monitor. It can be used to stop a simulation when the Completed place on the page Server contains at least one token, i.e. when the marking is not empty.

The index entry for this monitor is dimmed, indicating that the monitor has been disabled.

Place Contents breakpoint monitor

Place Contents breakpoint monitor

When the monitor is disabled, it will not be able to stop a simulation. If the monitor is enabled again, then it will stop a simulation when the appropriate conditions are fulfilled. For more about disabling and enabling monitors, see the help page about how to Edit a monitor.

Save arrival info

This is a write-in-file monitor that is used to save information about the jobs that arrive during a simulation. The monitor is associated with the Arrive transition.

Save Arrival information monitor

Save Arrival information monitor

Here is an example of a file that was generated by this monitor.

File generated by the monitor

File generated by the monitor

Initialization function

The initialization function adds some header-like information to the file before a simulation starts.

fun init () =
“Job arrivals \n============\n”

Predicate function

The predicate function returns true each time the Arrive transition occurs.

fun pred (bindelem) =
let
fun predBindElem (Arrivals’Arrive (1, {jobs, job})) = true
| predBindElem _ = false
in
predBindElem bindelem
end

Observation function

The observation function returns a string each time the predicate function returns true, i.e. each time the Arrive transition occurs.

The first part of the string is a counter indicating how many jobs have arrived. This number is accessed via the count function for the Count_trans_occur_Arrivals'Arrive_1 monitor. The second part of the string is a string representation of the job that just arrived, i.e. the job that is bound to the variable job when the Arrive transition occurred. The mkstr function is one of the color set functions.

fun obs (bindelem) =
let
fun obsBindElem (Arrivals’Arrive (1, {jobs, job})) =
Int.toString(Count_trans_occur_Arrivals’Arrive_1.count())^
” “^
(Job.mkstr job)^”\n”
| obsBindElem _ = “”
in
obsBindElem bindelem
end

Stop function

The stop function returns a string that is added to the file when simulation stop criteria are fulfilled. The string contains information about how many jobs arrived during the simulation and the number of steps that were executed during the simulation. The step() function is one of the simulator functions.

fun stop () =
“\n\nA total of “^
Int.toString(Count_trans_occur_Arrivals’Arrive_1.count())^
” jobs arrived during the “^(IntInf.toString(step()))^
” steps of this simulation.\n”

User defined log file

This is a user-defined monitor that creates and updates a file. Normally a write-in-file monitor would be used for this purpose, but this monitor is included just to show an example of how a user-defined monitor can be used.

The monitor is associated with almost all of the transitions in the net. The monitor is not associated with the Init transition on the Arrivals page.

User-defined monitor for log file

User-defined monitor for log file

Here is an example of a file that was generated by this monitor

File generated by user-defined monitor

File generated by user-defined monitor

Initialization function

The initialization function creates a file and adds a string to the head of the file. The function uses the initfile and getfid functions which are declared as declarations for the Queue System.

fun init () =
(initfile();
TextIO.output(getfid(), “Occurring transitions\n”))

Predicate function

The predicate function returns true each time one of the three transitions that are associated with the monitor occurs. This means that the file associated with the monitor will be updated when these three transitions occur.

fun pred (bindelem) =
let
fun predBindElem (Arrivals’Arrive (1, {jobs, job})) = true
| predBindElem (Server’Start (1, {jobs, job,proctime})) = true
| predBindElem (Server’Stop (1, {job})) = true
| predBindElem _ = false
in
predBindElem bindelem
end

Observation function

The observation function returns a string that will be added to the file by the action function. The first part of the string indicates the step number at which the transition occurred. The remaining part of the string indicates which transition occurred and some information about the binding of the variables of the transitions. The mkstr function is one of the color set functions.

fun obs (bindelem) =
let
fun obsBindElem (Arrivals’Arrive (1, {jobs, job})) =
“Arrive occurred: job=”^Job.mkstr(job)^”\n”
| obsBindElem (Server’Start (1, {jobs, job,proctime})) =
“Start occurred: job=”^Job.mkstr(job)^
“, length jobs=”^Int.toString(length jobs)^”\n”
| obsBindElem (Server’Stop (1, {job})) =
“Stop occurred: job=”^Job.mkstr(job)^”\n”
| obsBindElem _ = “This should never be in the file\n”
in
Int.toString(step())^” “^(obsBindElem bindelem)
end

Action function

The action function will add the string that is returned by the observation function (observedval) to the file associated with the monitor. The Option exception will be raised if the file has not been opened, in which case the file will be initialized and the string will be added to the file.

fun action (observedval) =
TextIO.output(getfid(), observedval)
handle Option => (initfile();
TextIO.output(getfid(), observedval))

Usually the file will have been opened by the initialization function. However if the monitor is modified, e.g. one of the monitoring functions is edited, after some simulation steps have been executed and the simulation is continued, then the file will no longer be open, and an error would occur if the file were not reopened.

Stop function

The stop function adds a string to the end of the file, closes the file, and sets the reference variable fileid to NONE, which indicates that the file has been closed.

fun stop () =
(TextIO.output(getfid(), “\n\n”^”Simulation stopped after ”
^Int.toString(step())^” steps\n”);
TextIO.closeOut(getfid());
fileid := NONE)

Related pages

Queue system, Queue System Queue Delay, Queue System Queue Length, Queue System Server Utilization

Queue system server utilization

You must be logged in to post a comment.