Newsletter Contents
Introduction
CSIM Training Course in Austin - November 15-16, 2005
CSIM for Java Now in Beta
Ask Herb!
CSIM 19 Available for Electronic Purchase
Going to a Conference?
Technical Note - Processes in CSIM for Java
Your Feedback is Important
Greetings to all!
Mesquite Software would like to take this early opportunity to wish our readers a
very happy holiday season. Another year has come and almost gone, but 2006
holds exciting promise… including a much-anticipated new product,
CSIM for Java!
As always, we welcome your CSIM feedback and ideas - please feel free to contact us
with your thoughts. We're particularly interested to hear how you're using CSIM.
If you'd like to share, you can fill out our
User Story form
with details of your CSIM application, and we'll send you a limited edition CSIM
t-shirt! If your story is selected for publication on our
User Stories page,
you'll also receive a complimentary year of extended support.
Want to learn CSIM the easy way? Mesquite Software now offers CSIM training courses!
Taught by University of Texas professor and long-time CSIM contributor
Dr. Jeff Brumfield, this hands-on course teaches CSIM basics, plus inside tips and
tricks for optimizing CSIM use. You'll also learn best practices to follow when
programming discrete event simulations.
John McLemore, a Senior Staff Software Engineer in Phoenix, AZ, offers high praise,
"I cannot remember a time where I have learned so much in a two-day period in such
enjoyable and comfortable surroundings - and my team described the same experience.
I would highly recommend this training for any team serious about performance
modeling."
If you register for training within 30 days of purchasing CSIM, you will receive a
20% discount on the training class. We also offer Academic discounts.
Our next CSIM training class is scheduled for November 15-16, 2005, in Austin, TX.
Click here for more information.
CSIM for Java is now available for Beta testing! CSIM for Java is a library of Java
classes and routines that give Java programmers the functionality of the CSIM
library, while mimicking the style of CSIM models. CSIM users can now enjoy the
benefits of the CSIM toolkit together with Java's platform independence,
object-oriented approach, threading, and networking capabilities.
Please contact us to participate in our Beta release program. CSIM for Java will be
available for general release in early 2006.
Occasionally we receive questions from users on topics of interest to the CSIM
community. CSIM's founder, Dr. Herb Schwetman, will answer select questions in
this newsletter and by email. If you would like to submit a question for Herb,
please email him at
.
Dear Herb,
I am trying to calculate a confidence interval. I have 50 values (throughput from 50 runs generated using the 'rerun' statement) tabulated in a table. When I asked CSIM to calculate a confidence interval, I got the following error:
>> Insufficient observations to compute confidence interval
Because a confidence interval can be calculated using 50 data points (according to what I understand), I am wondering what I am missing here. I know that a confidence interval can be calculated for a sample with size > 30 using 1-alpha/2 quantile of a unit normal variate, and for a sample with size < 30 using that of a t-distribution.
For example, with a sample size n = 32 (32 data points), a sample mean x = 3.90, and a sample
standard deviation s = 0.95, a 90 % confidence interval for the mean is 3.90 +- (1.645)(0.95)/sqrt(32) = (3.62, 4.17), where 1.645 is 1-alpha/2 quantile of a unit normal variate.
I expect CSIM to do a similar computation for a sample with size 50, but it gave me the error above. I would really appreciate it if you could give me a clear understanding on how CSIM calculates confidence intervals.
Thanks,
***
Dear CSIM User,
You raise an interesting point.
In CSIM (and in simulation in general), people often compute confidence intervals for response times. It may not be well known, but to use this computation correctly, you need independent samples. The reason is that the formula used to compute the standard deviation depends on having independent samples.
Now, it turns out that response times (for example, response times at a single server queue) are NOT independent - they are auto-correlated. In this case, the standard technique for computing standard deviation gives a value for the standard deviation that is small - the standard deviation is under-estimated. This means that the confidence interval computed using this estimate is overly optimistic, or too narrow.
So, in simulation, a couple of techniques have been devised to get around this problem; one is called the method of batched (or batch) means. You compute an average for each of a number of sub-intervals (of the entire experiment interval); the idea is that the means for each sub-interval will be independent, and the calculation of the standard deviation of these means will be correct, and thus the confidence interval computed using this value of the standard deviation will be correct. Of course, determining the length of the sub-intervals to use to guarantee this independence is not straightforward.
If you are interested in all of this, you can read more in the text, "Simulation Modeling and Analysis," by Law and Kelton - the chapter on output analysis goes into some detail on the method of batch means.
CSIM uses a heuristic to do all of this calculation automatically. It computes the correlations for the first 5000 samples, to estimate the amount of autocorrelation. If 5000 is good enough to eliminate autocorrelation, then batches of length 5000 are used in the method of batch means, to estimate the standard deviation and compute the confidence interval. If batches of length 5000 are not sufficient, CSIM lengthens the batch size until the autocorrelation is removed.
Because of this methodology, asking CSIM to compute a confidence interval with less than 5000 samples does not work.
Now, there can be situations where the developer of the model knows that the samples are independent and that computing the confidence interval for these is valid. A routine to handle these situations is included here.
Herb Schwetman,
Mesquite Software, Inc.
CSIM Confidence Interval Routine
// confidenceLevel.cpp
#include "cpp.h"
#include
#include
FILE *fp;
const int numSamples = 10000;
const double mean = 2.0;
table *tbl;
void init()
{
fp = fopen("confidenceInterval.out", "w");
set_output_file(fp);
}
void initRun()
{
tbl = new table("table");
tbl->confidence();
}
void computeConfidenceInterval(table *t, double cl);
extern "C" void sim()
{
int i;
double x;
create("sim");
init();
initRun();
for(i = 0; i < numSamples; i++) {
x = exponential(mean);
tbl->record(x);
}
report_tables();
computeConfidenceInterval(tbl, 0.90);
computeConfidenceInterval(tbl, 0.95);
computeConfidenceInterval(tbl, 0.99);
}
extern "C" double normal_quantile (double p);
extern "C" double t_quantile (double p, long ndf);
void computeConfidenceInterval(table *t, double confLev)
{
double interval;
int ndf;
double level, quantile;
ndf = t->cnt();
level = (1.0 - confLev)/2;
if(ndf <= 30)
quantile = t_quantile(level, ndf-1);
else
quantile = normal_quantile(level);
interval = quantile*t->stddev()/sqrt((double)ndf);
fprintf(fp, " %.2lf %% conf interval = %.6lf +- %.6lf\n", confLev*100,
t->mean(), interval);
}
Now you can order CSIM online and begin using it immediately! Check out our
new online purchase process. You can still
request software on CD-ROM, but now you don't have to wait to begin using CSIM.
If you're going to a conference and presenting a project that uses CSIM, we'd love to
hear about it! Send your conference proceedings referencing CSIM to us, and we'll
send you a CSIM anniversary t-shirt.
Java (reg. Sun Microsystems, Inc.) has become a widely-used programming language.
To supply simulation tools to the growing group of Java programmers, Mesquite Software,
Inc. has developed a version of CSIM for use with Java. A major feature of CSIM is the
CSIM process; these processes are used to model active entities in a simulation model.
This note describes processes in CSIM for Java.
Processes in CSIM for Java are implemented with Java threads. A program extends the
Model class; the Model base class provides the "runtime environment" for the model.
Each process extends the Process class. So, a CSIM for Java process (henceforth called
a CSIM process) will look like this:
private class Job extends Process {
public Job() {
super("Job");
}
public void run() {
......
}
}
A CSIM process can perform a number of activities, including:
- Allow simulated time to pass (using the hold(t) statement),
- Use simulated resources,
- Use events to synchronize its activities with other processes, and
- Send messages to and receive messages from other processes via mailboxes.
The advantage of using CSIM processes, as opposed to Java threads, is that the CSIM processes are easier to invoke and control. The CSIM runtime environment includes a priority-driven process scheduler. The collection of processes and the runtime environment are engineered to create efficient and realistic simulation models of systems.
As an example, consider a process that represents a part being assembled on an assembly line. The assembly line has three stations: all parts visit station[0]; after leaving station[0], a subpart is split off; the main part then visits station[1] while the subpart visits station[2]. Before the finished part exits the assembly line, the main part must complete its use of station[1] and the subpart must complete its use of station[2].
A CSIM for Java model of the part process and the subpart process are as follows:
private class Part extends Process {
public Part() {
super("Part");
}
public void run() {
double startTime = m_inSystem.enter();
Event go = new Event("go");
m_station[0].use(rand.exponential(1.0));
add(new SubPart(go));
m_station[1].use(rand.exponential(0.5));
go.untimed_wait();
m_inSystem.exit(startTime);
}
}
private class SubPart extends Process {
public SubPart(Event go) {
super("SubPart");
localEvent = go;
}
Event localEvent;
public void run()
{
m_station[2].use(rand.exponential(0.25));
localEvent.set();
}
}
In the example:
- m_inSystem is a Box - a Box collects statistics on the mean number of parts in the system and the mean time in the system per part
- m_station[0], m_station[1] and m_station[2] are FCFS facilities, each with a single server
- go is an Event - this Event is used to synchronize the completion of the Part and SubPart processes; each go event is local to the Part process; the Part process passes the go event to the SubPart process as an argument
- the "add(new SubPart(go))" statement invokes an instance of the SubPart process, with the Event go passed as an argument
- in SubPart, the input argument, go, is stored in a local variable; in this case, the local variable is named localEvent; this is done so that the event can be accessed by the run method for SubPart
- the "go.untimed_wait()" statement, in Part, waits until the Event go is set by the SubPart process; if SubPart sets this event before Part waits, this routine still works correctly
The output for this model is as follows:
CSIM/Java Simulation Report
TechNote
October 11, 2005 9:31:54 PM CDT
Ending Simulation time: 5000.000
Elapsed Simulation time: 5000.000
Execution (CPU) time: 2.734
FACILITY SUMMARY
facility service service through- queue response compl
name disc time util. put length time count
--------------------------------------------------------------------------------
station0 fcfs 1.01468 0.515 0.50740 1.02311 2.01639 2537
station1 fcfs 0.49337 0.250 0.50740 0.33800 0.66615 2537
station2 fcfs 0.25121 0.127 0.50740 0.14818 0.29203 2537
BOX 0 in system
statistics on elapsed time
minimum 0.082503 mean 2.761926
maximum 14.601288 variance 4.195402
range 14.518785 standard deviation 2.048268
observations 2537 coefficient of var 0.741608
statistics on population
initial 0 minimum 0 mean 1.401401
final 0 maximum 9 variance 2.336675
entries 2537 range 9 standard deviation 1.528619
exits 2537 coeff of variation 1.090779
This example demonstrates that a CSIM for Java model is a Java program that uses the
well-known features of CSIM to create models realistic models of complex systems, in a
manner that is familiar to Java programmers. If you have additional questions about
CSIM for Java, please contact Mesquite Software.
We are currently designing CSIM 20 and would like to be able to incorporate your
suggestions. If you have comments on CSIM 19 or suggestions for CSIM 20, do let us know!
Please explore our website to see our latest updates, or contact us directly if you have ideas, comments, or questions.
With kind regards,

Nan Schwetman, President
Mesquite Software, Inc.
8500 North MOPAC, Suite 825
Austin, TX 78759, USA
Tel: (800) 538-9153 (US) or +1 (512) 338-9153
Fax: +1 (512) 338-4966
E-mail:
www: www.mesquite.com