An event can be in either the OCCURRED
state or the NOT_OCCURRED state. A
process can wait for a specified event
to "occur". Another process
can set an event, causing it to be
placed in the OCCURRED state and allowing
all of the waiting processes to resume
(enter the Ready state).
A mailbox is a place where processes
can exchange information (messages).
One process can send a message to
a mailbox. Another process can attempt
to receive a message from a mailbox;
if a message is "in" the
mailbox, the receiving process gets
that message and continues computing;
if there are no messages in the mailbox,
each receiving process must wait until
a message is sent to that mailbox.
An Example
As an example, consider an assembly
line, where TV sets pass through an
assembly station and then are inspected.
About 20% of the inspected sets fail
and are sent back to the assembly
station for rework. If a set fails
inspection a second time, it is scrapped.
The parameters of the model are the
arrival rate of sets to this station,
the time required to assemble or rework
a set, the number of workers (servers)
at the assembly station, the number
of inspectors and the inspection failure
rate. The goal is to determine the
number of workers and inspectors required
to insure that this station is not
a "bottleneck" in the operation
of the factory.
A complete CSIM 19 model of this system
follows as Figure 1; the report output
for this model appears in Figure 2.
The model is a C++ program which utilizes
the classes, methods and procedures
of the CSIM 19 library.
// Model TV
Set Assembly and Inspection Stations
#include "cpp.h"
const double simTime = 8*60.0; //
parameters, constants
const long numberWorkers = 5;
const long numberInspectors = 2;
const double arrTime = 2.0;
const double assemblyTime = 3.0;
const double reworkTime = 1.5;
const double inspectTime = 2.0;
const double failRate = 0.20;
facility initialPrep("initial");
// facilities
facility_ms assembly("assmbly",
numberWorkers);
facility_ms inspect("inspect",
numberInspectors);
facility finalPrep("final");
facility scrapPrep("scrap");
FILE *fp;
void generate(); // prototypes
void TVSet();
extern "C" void sim() //
main process
{
fp = fopen("xxx.out", "w");
set_output_file(fp);
create("sim");
generate(); // start generate process
hold(simTime); // lengthof run
report(); // producereport
}
void generate()
// generator process
{
create("gen");
while(1) {
TVSet(); // start TV Set process
hold(exponential(arrTime)); // timebetween
TV Sets
}
}
void TVSet() // TV Set process
{
long inspectCt = 0;
double stationTime;
long exitCond = 0;
create("TVSet");
initialPrep.use(0.5); // prep station
stationTime = assemblyTime;
do {
assembly.use(exponential(stationTime));
// assembly station
inspect.use(exponential(inspectTime));
// inspect station
inspectCt++;
if(bernoulli(failRate) == 0) { //
outcome of inspection
finalPrep.use(0.5); // passed ->
final prep
exitCond = 1;
}
else {
if(inspectCt < 2) {
stationTime = reworkTime; // failed
1st, rework
}
else {
scrapPrep.use(0.5); // failed 2nd,
-> scrap
exitCond = 1;
}
}
} while(exitCond == 0);
}
Figure
1: Listing of Example Model (TV Sets)
CSIM Simulation Report (Version 19
for MS Visual C++)
Tue Apr 08 13:25:46 1997
Ending simulation time: 480.000
Elapsed simulation time: 480.000
CPU time used (seconds): 0.160
| Facility
Summary |
facility
name |
service
disk |
service
time |
util. |
through-put |
queue
length |
response
time |
compl
count |
| initial |
fcfs |
0.50000 |
.0263 |
0.52500 |
0.30024 |
0.57199 |
252 |
| assembly |
fcfs |
2.70720 |
1.686 |
0.62292 |
1.69512 |
2.72126 |
299 |
| >server |
0 |
3.05139 |
0.661 |
0.21667 |
|
|
104 |
| >server |
1 |
2.38099 |
0.486 |
0.20417 |
|
|
98 |
| >server |
2 |
2.92460 |
0.299 |
0.10208 |
|
|
49 |
| >server |
3 |
2.70011 |
0.196 |
0.06875 |
|
|
33 |
| >server |
4 |
1.75744 |
0.055 |
0.03125 |
|
|
15 |
| inspect |
fcfs |
2.03109 |
1.261 |
0.62083 |
1.98357 |
3.19500 |
298 |
| >server |
0 |
2.10837 |
0.685 |
0.32500 |
|
|
156 |
| >server |
1 |
1.94619 |
0.576 |
0.29583 |
|
|
142 |
| final |
fcfs |
0.50000 |
0.250 |
0.50000 |
0.29389 |
0.58777 |
240 |
| scrap |
fcfs |
0.50000 |
0.010 |
0.02083 |
0.0142 |
0.50000 |
10 |
Figure
2: Report Output for TV Set Example
The model has two kinds of processes
(in addition to the initial "sim"
process): the "generate"
process injects TVSet processes into
the model at varying intervals which
model the arrivals of TV Sets at this
station. The probability distribution
of these interarrival intervals is
a negative exponential distribution
with mean as specified by the arrTime
constant. The TVSet process models
the behavior of a TV set as it progresses
through the set of stations. The facilities
(representing the stations of the
system) are declared and constructed
a global, static objects. Each TVSet
process uses (visits), in turn, the
initialPrep station, the assembly
station and the inspection station.
The times spent at each station are
all sampled from negative exponential
probability distributions, with means
specified by the appropriate constants.
CSIM 19 provides a variety of probability
driven random number functions, so
that it is likely that an appropriate
function can be found for any modeling
situation.
The outcome of the inspection is determined
by a Bernoulli function; the parameter
is the mean failure rate. Thus, a
successful outcome of the Bernoulli
function is a failed TV set and an
unsuccessful outcome of the Bernoulli
function is a passed TV set. Passed
sets go to the finalPrep station and
then exit the model. Failed sets can
return to the assembly station for
a rework cycle, but only one time.
Thus, a unit failing for the second
time is sent to the scrapPrep station
and then exits.
The report output shows that with
five assembly workers and two inspectors,
the model predicts "acceptable"
performance. Other runs of the model,
for example with one inspector, show
that the number of inspectors can
be critical to successful operation.
With one inspector, the response time
at the inspector station climbs to
about 20 minutes per TV set.
Other Features
CSIM 19 includes many features which
were not described above. For example,
there are extensive capabilities for
collecting specialized data, which
are needed to gain insight into specific
aspects of the operation of the model.
Both real-valued items, such as response
times, and time-based, integer-valued
items (such as queue lengths) can
be collected. Included in these data
gathering features are special mechanisms
for producing confidence intervals
for output values. There is also a
"automatic run-length control"
feature, which lets a model execute
until desired levels of statistical
accuracy for specified output values
are achieved.
All of the data collected at facilities,
storages, tables (for real valued
data) and qtables (for time-based,
integer-valued data) are accessible
via a group of inspector functions.
These can be used to produce output
reports tailored to specific reporting
needs.
There are capabilities for testing
the status of the simulated resources
and for modifying the characteristics
of these resources. These can be used
to produce very accurate representations
of many different kinds of system
resources.
All of the features and capabilities
of all of the classes, methods and
procedures in the CSIM 19 library
are described in the CSIM
19 User's Guide (both the C and
C++ versions).
Summary
This Primer has described some of
the features and capabilities of the
CSIM 19 simulation software toolkit.
The Primer has focused on CSIM 19 processes,
as these are critical to implementing
robust models of complex systems.
A fairly detailed example illustrated
the use of processes and facilities
to model a section of a TV set assembly
line. The interested reader is referred
to the CSIM 19 User's Guides and the
CSIM 19 Getting Started manuals for
additional information.