Uploaded by ha7165614

Lupiya Grant 1991 Object Oriented Languages

advertisement
PROGRAMMING SIMULATIONS USING OBJECT-ORIENTED
LANGUAGES WITH EXAMPLES INC++
by
Grant
Lupiya
)
A project
Major
Professor:
Dr Timothy
Budd
Minor
Professor:
Dr Toshimi
Minoura
Other
Committee
report
Oregon
State
requirements
,,
I
submitted
to
University
for
the
member:
the
Department
in partial
degree
Professor
Bella
of
Computer
fulfillment
of Master
Bose
of
of
Science
Science,
the
TABLE OF CONTENTS
Ac know 1 edgemen t ...........................................
Abstract
1.
2.
3.
5.
)
(ii)
. ...............................................
1.1
Overview
1. 2
How simulation
The process
of
The steps
2.2
Types
of
.
is
defined
simulation
of
simulations
...
2
4
. .4
. .9
pure
Object-oriented,
LISP-
....................................
Object-oriented
3. 2
SIMULA.....
3. 3
Smalltalk
3.4
c++ Language.
3. 5
PASION.
3.6
ROSS ..............................................
paradigm
and
10
simulation
..........
10
.12
..
.14
.....
......
Overview
4.2
Simulation
of
a bank
4.3
Simulation
of
a hospital
4.4
Simulation
of
a livestock
5.1
Overview
5.2
Problems
5.3
Suggestions
5.4
Lessons
.
scenario
....
scenario.
farm ....
.
• •••••••
26
. ......
27
• • • • • • •31
••••••••••••
.....................................
............
learned
.
.. 38
. . 38
improvements.
..............
. ................................................
36
38
experienced.
for
20
26
..........................
and conclusion
18
22
............................................
4.1
References
. ..............
.
representing
and c extensions
1
.. .
3.1
comment
..
. ..............
.............................
in modeling
languages
Implementations
1
..................
doing
2.1
based,
4.
.................................................
Introduction
A survey
( i)
•• 39
.
. ••••••
39
41
Acknowledgement
I would
like
to
Budd,
who has
been
years
of
at
stay
my studies
were
and
a source
tackling
this
My thanks
for
their
agreeing
support
convey
my Major
Oregon
this
of
a high
State
Professor
Timothy
during
my three
and Advisor
University
project
inspiration
to
. He guided
. His
for
me,
me throughout
patience
and
guidance
and greatly
helped
Minoura
Bella
in
.
go to
to be on the
and
thanks
Professor
research
project
also
my sincere
Professors
Toshimi
committee
encouragement.
)
( i)
for
my research
and
project
Bose
and for
Abstract
In
)
this
project
programming
choice
languages
for
and
c++ in order
are
in
constructing
the
make
features
them
simulations.
livestock
language
examine
that
implementing
hospital,
used
we
farm
to
demonstrate
simulation
(ii)
most
Three
scenarios
of
oriented
likely
languages
simulations
of
were
how Object
software.
object
implemented
- Oriented
of
a bank,
in
the
languages
Chapter 1
)
Introduction
1.1 Overview
Simulation
many
is
used
real-world
may be too
frequently
systems.
complex,
in
Most
or too
of
the
study
these
dangerous
of
systems
the
behavior
are
to be modeled
the
of
kind
using
that
analytical
methods.
Why is
simulation
simulation
for
is
ways
cost,
to
increase
estimation
parameters,
or operating
languages
simulation
Simulation
are
with
animation
and
Simulation
graphical
thus
A simulated
such
as
compressed
time
in
order
to
system
observe
if
the
by
they
make
to
some fine
1
speed
details
proposed
The
availability
of
to popularize
various
can
fields.
be displayed
languages
it
easier
and
to
do
simulation.
without
order
new policies,
simulation
of
avoid
Simulation
helped
if
can be studied
in
the
in
use
to
can be simulated.
solving
of
production
alternative
they
capabilities,
experimentation
time
for
on them has,
advent
encouraging
allows
of a system
why
looking
tool
life.
understood
the
reduce
and human
problem
easily
therefore
hardware
of
reasons
are
an inexpensive
backed
can run
method
and
Therefore
computers,
many
As industries
finances
and evaluated
that
results
graphically,
system.
a
as
conditions.
personal
as
of
are
quality,
of performance
can be compared
simulation
today.
adopted
terms
can provide
of
use
been
in
popularity
There
productivity,
has
mistakes,
designs
popular?
widespread
simulation
costly
)
in
so
disturbing
in different
up a
in
time
study
the
the
study.
or
real
frames
expanded
This
project
languages,
)
ideal
report
drawn
for
e x amines
from
three
simulation.
languages,
the
of object-oriented
representative
The three
LISP - based
attributes
classes
languages,
groups,
that
make them
pure
object
oriented
are
and c-extension
languages.
1.2 How simulation is defined
Since
simulation
propose
a good
reasonable
is
definition
in which
The process
real
with
the
Models
real
and
model
real
system .
are
which
proposed
simulation
conducting
it
is
by
is
quite
hard
to
general.
Hoover
and
A
Perry
as:
a mathematical
then
of
Those
or logical
computer-based
e xplain,
as
and predict
containing
aspects
to
obscure
not
for
either
Models
fields,
model
of a
experiments
the
behavior
of
system
the
only
the
behavior
solution
for
the
wrong,
true
or
the
essentials
system
which
are
included
not
problem
the
of
do
not
since
model
is
solve.
appropriate
therefore
one
defined
may be thought
only
Models
varying
system.
they
to
the
to describe,
significantly
would
in
simulation
of designing
contribute
trying
)
is
they
system
of the
the
of
definition
[Hoope89]
)
employed
can
Iconic
models
models
resemble
models
have
right
the
or
analysis
be accurate
be classified
resemble
the
no physical
or
hand
[Hoope89].
but
they
Models
are
may
inaccurate.
as being
the
real
at
false,
real
iconic,
system
system
only
or analog
physically,
in
relationship,
2
analog,
behavior,
only
or symbolic.
while
analog
and
symbolic
logical.
A system
that
interact
According
to
to be modeled
and operate
to Biles
the
focus
simulated
be
the
important
Despite
the
simulation,
that
also
stochastic
)
true
employed
to
optimal
generally
results
model
requires
modeled.
terms
In
of
end (Polla89].
constitutes
a system
boundaries
of
to
objectives
nature
compare
to
can
number
the
of the
is relative
system
include
the
being
important
study,
accrued
and exclude
from
problems
One observed
weakness
that
since
their
results
and
and
models
produce
be
alternative
solutions,
but
to
a valid
to
be
representation
accurate.
careful
planning
general,
coming
and
of
study
may be
and
system
the
lengthy
therefore
only
find
requires
the
Therefore
simulation
resources,
of
contain
of
can
Simulation
. It
estimates
modeling
not
is
develop
simulation
be
of
weaknesses
to
many simulation
problem.
use
of simulation
difficult
can only
the
. Therefore
a specific
computer
be
of
expensive
observed
must
output
a
simulation.
solution
model
some logical
order
that
are
parameters,
system's
the
to the
of entities
ones .
are
been
in
advantages
with
models
has
defined
there
associated
what
Therefore
related
less
of a collection
to accomplish
study.
characteristics
composed
[Biles87],
of
must
is
the
that
for
the
up with
a valid
situation
being
and
good
expensive
designs
in
are
imperative.
Figure
2 shows
a simulation.
the
As it
execution
of parallel
of events
can
iterative
is
most
events,
be simulated
process
of
the
figure
time
3
is
involved
required
to
4 shows how parallel
on a sequential
)
that
machine.
in doing
simulate
the
execution
Chapter 2
The process of doing simulation
2.1 The steps in modeling
The process
following
1.
of modeling
steps
[Polla89]
Definition
of
In
the
description
of
its
is
[Nance81]
through
a
submodels,
the
possible
Forrester
widely
been
is
into
lower
is
reached.
objects
states
adopted
process
these
entities
4
this
stage
i.e.
what
simulation
study.
should
the
proceed
model
and
into
so forth
of
representing
This
their
the
includes
attributes,
participate,
and
system.
devised
in
at
system.
system,
[Forr61]
environment
study,
of
of the
of the
undertaken,
submodels,
the
in which
The
collection
the
of
is
definition
submodels
is
the
define
solved.
the
by the
decomposition
of the
and
being
happening
of
that
and data
analyze
defining
answered
level
to
be modeled
top-down
the
activities
what
recommends
features
the
to
execution
objectives
is
objectives
specification
describing
need
which
terms
be
specification
essential
)
to
an atomic
Model
the
and thus
the
are
simulation
system
In simple
Nance
Model
the
the
and
problem
determining
until
is
boundaries
questions
involves
problem
there
thoroughly
as well.
2.
the
simulation
giving
)
generally
writing
symbols
that
relational
have
now
diagrams
[Brock79,
capture
Pella82].
all
other
.
The
into
of
of
model
language
one,
to each
can
later
formulae,
the
be
make
computer
the
program
a
the
is
for
an
to
objects
choice
of
tailored
for
part
and therefore
problem.
The
in simulation
a
applications,
objects
the
are
simulation
less
using
are
not
task
of
object-
cumbersome
as objects
way
in the
of
real
in the
application.
of insuring
that
the
model
is,
the
computer
and validation
Verification
built
but
languages
designing
Verification
any computer
The
offers
parallel
in
easier.
languages
will
importance
task
simulation
to take
The choice
this
oriented
system
vital
of simulation,
every
a general
language.
makes
selected
may be
simulation,
simulation
classes
the
Theoretically
language
particular
used
of
simulation.
purpose
creating
language
using
simulation
be used
appropriate
answer
implemented
language
could
special
is
. The
computer
language
program
or special
accomplishing
is the
according
program
confirming
the
helps
relation
which
implementing
a computer
conceptual
purpose
4.
diagrams
diagrams
difficult.
computer
an
and their
mathematical
stages
3 . Construction
of
entities
relational
subsequent
The
of relational
important
translated
less
The use
real
to
process
specification.
That
properly.
Validation
performs
the
model
is
system
and
that
5
a
faithful
it
can
refers
representation
actually
imitate
is
to
of
its
behavior.
Sargent
validation
stage
steps,
where
(i)
[Sarge83]
should
be divided
Comparison
with
of the
This
should
models
the
results
of
may also
take
the
model
to
form
other
of
models.
comparing
known
be
the
results
of
models.
validity
Events
are
other
with
Event
or occurrences
compared
determine
The
to
if
Extreme
validity
Face
validity
about
the
data
model,
validate
the
simulation
the
real
model
system
to
same.
test
should
be
bound
outside
and
of the
prevent
defined
ranges.
Face
Historical
are
of behavior
operating
behavior
of
they
model
of the
those
condition
occurrence
If
following
validated
analytical
(v)
the
being
simulation
(iv)
into
the
model
compared
(iii)
that
feasible:
output
(ii)
recommends
is
system
is
asking
people
whether
the
knowledgeable
model
or
its
reasonable.
data
can
be collected
part
of
the
model.
6
the
before
data
can
building
be
used
the
to
(vi)
Interval
validity
Doing
)
several
variability
(vii)
replication
of the
Multistage
stage
theory,
observation,
the
intuition,
and
relationship
of
Sensitivity
(ix)
of
and
output.
simulation
in
experimental
is
state
values,
real
knowledge
the
input
system
on
assumption
and
output
and the
model.
of changing
and
interval
the
the
parameters
effect
in
upon
model
the
the
the
frames.
are
model's
followed
logic
duty
to
to
is
design
An experimental
of circumstances
be observed
during
variables,
input
termination
model
correct.
and analysis
has
specification
to
testing
determine
if
experiment
modeler
the
and general
based
Traces
determine
The
developed
comparing
input
to
Entities
5.
is
consists
a model
its
model
analysis
The technique
values
the
model.
before
empirically
(viii)
determine
validation
At this
and
can
the
conditions
under
7
variables,
and
or
is
defined
frame
experimentation.
to
one
which
It
the
consists
more
as
model
of
initialization
variables
for
data
collection
analyze
6.
(output).
the
results
Documentation
of
of
the
The program
must
and
written
reports
recommendation
following
the
statistical
the
methods
simulation
must
be used
run.
results
be documented
by explaining
up on the
made.
elements
Gauss
of
results
of
[Gauss78]
information
how it
the
study,
recommends
should
works
and
that
the
be included
in
documentation.
(i)
A precise
statement
suppose
(ii)
to
The mathematical/logical
being
(iii)
the
model
is
definition,
formulation
of
the
problem
and
output,
modeled.
test
A set
the
(v)
and
A complete
and
(iv)
of what
do.
assumptions,
)
set
cases
of
of
that
operating
simulation
A well
to
current
have
input
been
run.
instruction
for
program.
documented
8
program
listing.
user
of
Planning simulations
Formulation
problem
of the
J
l
'
Collection
and
processing
of data
,'
Formulati on of
mathematical
model
Estimation
of
parameters
,
model
)
reject
evaluation
accept
Formul at ion of
computer
program
va lidati on
Design of experiments
I
Analysis
of data
)
Figure
1
l
l
Simulation Algorithm
Create Model
GENERATE
Find Next
Potent al Event
Select activity
2
SIMULATE
3
y
}
4
5
Change Image
Gather Statistics
Generate report
Figure 2
REPORT
SIMULATION PROGRAMMING TASKS:
System Image
Routines
•
Simulation
algorithm
,.
)
Report Generator
Figure 3
Modeling Para 11el ism on Sequential Machines
Begin Simulation
Initialize
time to zero
-select code to execute~----------.
-Pass contro 1 to code
)
code 1
code 2
code n
no
Update c 1ock
Figure 4
2.2 TYPES OF SIMULATION
Constructing
a simulation
simulationist
design
and
builds
a model
an experiment,
observes
study,
the
the
and
have
event
properties
a collection
of
of the
On the
changes
output.
other
in
the
the
attributes.
hand,
the
the
adjustment
state
state
a continuous
variables
display
a
on to
experiment
goals
to
the
of
model
of objects
called
The state
of the
variables
that
occur
lie
system.
otherwise
a system.
of
the
and
entities
system
represent
environment
If
the
it
a system
environment
is
open.
9
the
and
are
and
is
one
is
the
continuously
in
used
which
are
boundaries,
empty,
to
hybrid
continuous
made up of
is
in which
generally
Systems
discrete
outside
is
smoothly
equations
of
combination
that
simulation
differential
The system
closed,
on
goes
A
system.
simulation
to
then
using
based
composed
or
continuous
said
and
process.
simulation.
called
model
the
system,
make
is
attributes
an iterative
simulation
system
or
influence
the
may
Difference
and activities
the
Eventually,
time.
characteristics.
basically
of
runs
re-execute
A discrete
entities
then
simulationist
experiment
that
is
event
any
objects
but
which
may
the
system
is
Chapter 3
A Survey of languages representing pure Object-Oriented,
LISP-based, and C extensions Languages
3.1 Object-Oriented paradigm and simulation
Simulations
have
languages,
with
FORTRAN, or
a dialect
to
implement
languages,
the
the
simulation,
the
use
object-oriented
reducing
cost
application
software.
mapped
the
into
are
although
most
is
that
it
do,
instead
for
the
of how it
representation
of the
object-oriented
objects,
instead
is
languages
simulation
all
the
to
in
behavior.
task.
provides
real
able
respond
an easy
producing
the
is
and
not
in
The
a way
the
of
simulation
world
are
easily
model.
programming
in research
to
is done.
are
concentrate
procedure
on what
utilized
paradigm
10
with
The advantages
style
Object-oriented
calls
in use,
As Budd [Budd91)
object-oriented
programming
languages
laboratories.
extensive.
of objects
of
written
special
define
in
of the
users
to
from
been
behave
software
involved
imperative
implementor
is
languages
permits
the
languages
are
advantage
to
has
in
of procedural
objects
object-oriented
of these
having
programming
simulation
of object-oriented
a major
various
The objects
several
them
that
producing
that
conducted
opposed
implementor
advantage,
the
There
as
advantage
as the
this
of
been
FORTRAN. The use
how the
Despite
out,
of
understand
of
majority
simulation,
offers
clearly
traditionally
it
of programming
is
they
programming
in
of sending
want
is
simulations.
parameters
points
ideal
The use
messages
is
to
an
to
)
appropriate
way of
Inheritance
in
complexity
allows
representing
object-oriented
of software
efficiency
to
involving
perform
the
creation
groups
LISP
extensions,
languages
simulation.
reduces
of software
the
objects
construction.
take
a totally
new view
languages
of objects
which
language.
programming
based
Object-oriented
on their
and
send
Everything
giving
a consistent
languages.
inheritance
relation
as
C++ and
efficient
in
view
each
of
what
it
programming
other
as
requests
implementation:
may be
pure
Smalltalk
language,
is
classified
to
which
is
an interpreted,
interface.
ROSS, and FLAVOR belong
to change
after
in
this
class
as
The C-based
are
typed
program
11
strongly
compilation.
and
pure
objects
may
dynamically.
a
typeless
is
Languages
represented
into
Object-oriented,
Smalltalk
Objective-C,
code,
languages
C extensions.
programming
LISP-based
yield
in
some task.
three
such
events
The re-use
Object-oriented
Object-oriented
thus
construction.
languages
program.
world
programming
of software
Object-oriented
means
real
and
to the
allow
the
languages,
as
a result
3.2 SIMULA
The roots
Algol.
of SIMULA (SIMUlation
The language
alternatively
SIMULA
is
be considered
(i)
Ability
(ii)
to
Ability
a superset
as Algol
specify
to
Language)
class
can
be traced
of Algol
with
the
60.
back
to
SIMULA can
following
features:
declarations.
generate
coroutine
objects
from
class
declaration.
(iii)
Ability
to
give
manipulated
(iv)
to
generated
by procedures
Presence
of
chained
hierarchical
)
names
defined
class
objects
in
the
which
get
program.
declaration,
which
form
a
structure.
Support for simulation in SIMULA
SIMULA designers
simulation.
All
other
defined
These
classes
classes
subclassing
these
five
in
handling
Languages
supporting
MESA, Concurrent
Pascal,
SIMULA. A SIMULA class
of
objects
instance
and
of
each
classes,
class
input
actions
object
classes
support
the
in a simulation
SIMULATION. Another
used
five
process
using
and
output
the
idea
in
view
be
of
language
provides
can
SIMULA is
used
in
simulation.
are
formed
by
SIMSET, and
BASICIO which
is
operations.
of data
ACT, Smalltalk,
can
this
can
NAMEDLINK, HEAD, LINK,
important
it
that
encapsulation
such
and c++, have
all
an encapsulation
perform
follow.
12
and
of the
the
as CLU,
roots
in
properties
"life-cycle"
the
Class
to
hierarchies
communicate
inheritance,
along
with
there
language
with
each
is
coroutine
other.
no
facility
SIMULA only
multiple
inheritance
permit
objects
permits
single
provided
in
the
design.
Class Simset
This
called
are
class
sets
supports
in
formed
doubly
linked
SIMULA terminology,
using
these
circular
has
lists.
objects
The
as members.
list,
Queues
lists.
Class Simulation
The
class
responsible
(i)
)
(ii)
(iii)
[ Fran77 J provides
simulation
(v)
that
are
for:
Event
notice
generation,manipulation,
The system
Scheduling
A link
and
cancellation.
clock.
The sequencing
(iv)
constructs
set.
constructs.
between
and the
system
the
coroutine
clock
provided
and the
by class
sequencing
objects
set.
Class Basicio
Basicio
The input
are
using
is
the
class
and output
objects.
various
files
Input/output
procedures
responsible
are
is
for
built
done
in the
handling
on the
concept
by manipulating
class
13
Basicio.
input
and output.
of text,
the
text
which
objects
3.3 Smalltalk
Smalltalk
is
the
object-oriented
an
system
a name
Object,
that
languages
Smalltalk-80
has
language
and
which
over
a link
does
aggregate
has
of
to
to
not
the
have
the
a parent
except
class.
some
of
we see
in the
the
A
system
root
A Smalltalk
these
in
community.
. Each class
superclass,
from
ideas
programming
200 classes
its
objects
introduced
class,
program
classes,
and
is
their
subclasses.
Support for simulation in Smalltalk
The Smalltalk-80
use
in
discrete
the
required
defined
user
system
event
the
framework.
These
Simulation,
such
defined
if
of these
classes
that
6 shows
are
new classes
form
are
designed
model.
the
transient
Object
that
the
control
5 are
classes
DelayedEvent.
Other
and StaticResource
simulation
system
looks
is
defined
figure
and
control
the
construct
simulation
in
for
can
[Gold83]
the
shown
in the
simulation
to
are
class
Robson
EventMonitor,
required
how the
and
root
Resource,
as Histogram,
they
the
that
SimulationObject,
classes
Figure
Goldberg
classes
that
The simulationist
by subclassing
system.
constructed
classes
simulation.
classes
in
provides
may be
under
study.
after
the
addition
that
appear
in
the
class
Class SimulationObject
This
class
simulation
defines
e x ecution.
StaticResource.
simulation
)
subclass
If
execution,
of
the
The
the
class
objects
is
simulationist
a class
parent
requires
EventMonitor
SimulationObject.
The
14
to
can
a
trace
of
be defined
methods
of
a
the
as a
the
class
SimulationObject
by which
)
tasks,
are
an
object
enters
and finally
temporal
execution
of
the
and
go
assigned
the
and
from
out
sequence
some
The objects
in this
"life-cycle"
that
a
execution
finally
the
a control
carries
methods,
The SimulationObject
simulated
provide
system,
through
tasks
objects
to
system.
initialization
the
terminate
used
the
leaves
generally
perform
generally
of
assigned
class
are
involves
methods
that
that
execution
of
methods
of tasks
that
describe
system.
maintains
a list
the
activities.
Class Simulation
The job
is
of
to
of this
control
the
the
reference
and
solving
simulation
objects
be well
in
EventMonitor
[Gold83)
up schedules
involve
creating
well
as
for
the
set
of
methods
in
this
order
The
initialization,
a simulation
the
in
setting
jobs
as
coordinated.
for
to
Other
events,
and Robson
maintaining
initialize
the
a
objects
class
variables
eventQueue.
problem
transient
in
SimulationObject
responsible
currentTime
addition
Objects.
the
to
by Goldberg
in
delayed
system
are
In
simulation,
queuing
to
the
that
as defined
SimulationObject
resources,
in
class
problem,
as a subclass
system
objects
Objects
must
must
if
be
the
simulationist
of Class
Simulation.
defined
as
be defined
the
as
trace
)
15
resources,
execution
the
The permanent
SimulationObject
of the
a file.
defines
is
while
the
Objects,
or
to
be stored
Class Resource
The
)
class
Resource
can
ResourceProvider
and
ResourceProvider
generates
be
designed
with
two
ResourceCoordinator.
resources
subclasses
subclass
The
which
are
consumed
by
the
ResourceCoordinator.
Class DelayedEvent
An
instance
DelayedEvent
of
WaitingSimulationObject
suspended
has
a
until
semaphore
when the
because
technically
it
has
to
available.
)
some time
process
as
the
is
which
time
created
it
wait
simulation
resource
until
becomes
the
of class
to
continue
some
A DelayedEvent
signaled
to
resource
object
is
next
time
the
is
is delayed
in the
is
on the
be
suspended
Object
be active
placed
to
DelayedEvent
start
that
it
subclass
requires
A SimulationObject
may not
for
An object
be
is ripe.
its
when a process
elapses.
will
or
model
not
currently
event
queue
scheduled
when
of
the
available.
Class EventMonitor
The
Class
EventMoni tor
is
simulation
objects
from the
they
It
this
exit.
overrides
does
the
methods
designed
time
they
by defining
of
to
enter
a file
trace
the
to
the
progress
system
store
to
of
the
time
trace
and
created
and
the
simulationObject.
Class ResourceProvider
The ResourceProvider
)
consumed.
track
of
It
has
current
an
value
describes
instance
of the
resources
variable
resources.
16
which
are
amountAvailable
that
keeps
Smalltalk-BO
Simulation
Classes
)
Object
Resource
Resource Provider
Simulation
ResourceCoordinator
Si mul at ionOb j ect
Del ayedEvent
Wait i ngS i mul at i onOb j ect
)
Figure 5:
)
( Goldberg and Robson 1983)
Smalltalk-80
Simulation
Classes
)
Object
Resource
Resource Provider
Simulation
Del ayedEvent
ResourceCoordinator
Wait i ngS i mul at i onOb j ect
EventMon i tor
Figure 6:
( Goldberg
Stat i cResource
and Robson 1983)
Class ResourceCoordinator
A ResourceCoordinator
)
It
can
Its
coordinate
queue
describes
one or more
consists
of
a server/customer
servers
either
with
entirely
relationship.
one or more
of
customers.
servers,
or
of
only
customers.
Graphics and Smalltalk-SO
The
class
simulation.
bitmaps.
Form
A form
A form
written
to
accomplishes
the
is
an array
can
disk
basically
be
file
created,
using
animation
discrete
of pixels
edited,
messages
of
represented
scaled,
provided
event
displayed,
by
the
as
and
Smalltalk
system.
to
A new form can be drawn
interactively
FormEditor.
edited
displayed
A form
by sending
is
it
the
by sending
by sending
message
it
message
a message
displayon:
at:.
newform
edit
and
When a form
)
array
is
Object,
idle
placed
and
to
active,
into
a job
the
an
started,
busy
instance
variable
thus
form
is
changing
shown
17
of
SimulationObject
the
objects
on the
display.
state
from
3.4 C+ + Language
c++
)
either
is
superset
as
a procedural
Because
of
the
increasingly
oriented
software
scientist
knowledgeable
each
to
object
libraries
release
it
can
be
Oriented
language,
One
C finds
such,
Object
the
used
language.
the
language
is
people
interested
in
object
reason
for
is
that
it
nature
choose
either
implement
an
oriented
as
has
arithmetic
part
[rumba91].
a good
example
not
be
compatible
limited.
Despite
language
for
out
is
easier
of
the
this,
to migrate
language
idea,
to
a
C++
gives
a conventional
or
selecting
ability
to
problem
arises
override
the
reuse
method
should
writer
of
an
object
whichever
add
if
as
design
the
virtual
of
affairs,
declared
the
virtual
in
user
source
will
have
virtual.
code
not
has
is
the
no
not
an elegant
18
solution
The
ability
may
be
Since
the
users
superclass
in
impossible
to
Declaring
either,
to
the
predicting
the
al
on the
be accomplished,
of
available.
et
subclasses.
the
is
C++ as
restriction
to modify
This
of
superclass.
way
use
Rumbaugh
and
to
may
their
adoption
resolution
subclass
libraries,
therefore
creating
T
&
complex
libraries
overwhelming.
in the
AT
and
These
a serous
contain
the
developed
the
by
method
class
keyword
is
is
classes
for
also
and
of c++ places
original
the
other,
not
tasking
Library.
development
of a class
often
have
does
However
input/output,
each
state
c++
environment.
people
library
be
its
Interviews
with
because
the
requirements,
accomplish
the
this
method
to
is
languages,
for
Other
software
that
of
libraries
and
methods
to
an
among
hybrid
freedom
other
standard
order
of
As
best.
Unlike
point
the
C.
or
nature
with
methodology
is
c++
language
development.
the
oriented
language
popular
Also
implementor
the
hybrid
becoming
environment.
)
of
all
since
the
this
places
some cost
on memory
and
function-call
overhead.
Support for simulation in C + +
C++ allows
instance
the
objects
availability,
user
to
can
be
makes
developing
and
classes
modeled
defined
and
virtually
created.
c++ seem
simulation
To design
develop
This,
to
any class,
combined
be an ideal
from
which
its
wide
with
candidate
for
software.
implement
on the
a good
pattern
simulation
of those
using
this
in Smalltalk
language,
system
can
be
is
as
appear
as
used.
layout
A general
of
a
class
implementation
in
c++
follows:
class
)
Name
{
public:
Interface
methods
definitions.
protected:
Interface
methods
and data
for
subclasses.
private:
Methods
and
data
only
visible
within
the
object.
}
Using
this
design,
a definition
of
below:
19
class
Clock
would
class
Clock
{
public:
)
Clock()
{ time=
0.0;}
inline
void
resetTime()
{time=
inline
void
clockTick()
{time+=
inline
float
currentTime()
0.0;
}
1.0;
{return
}
time;
}
private:
float
time;
}
3.5 PASION
)
PASION
(PAScal
Programming
Language
simulationists.
needed
simulatION)
in
of discrete
PASION,
inheritance
such
as
object
capabilities,
available
in PASION permits
hierarchies,
thus
time
variable
for
process
the
of
that
are
occurrence
of objects.
in
code
languages,
re-use.
process-oriented
view
inheritance
create
has
According
of
the
and definition
can
needs
tools
execution,
programming
aid
the
Pascal
to
world
of process
complex
models
using
code.
a "clock
time.
extending
provides
creation
a simulationist
written
PASION has
the
by
cater
oriented
which
[Polla89],
to
as parallel
and dynamic
all
design
language
events,
Pollacia
simulated
order
The extended
in simulation
previous
was
Time
is
mechanism"
defined
variables
are
used
to
zero
initialized
20
in the
to
at
language
schedule
the
to provide
events.
start
of
The
the
simulation.
to
Then the
are
time
variable
value
scheduled
which
of
model,
has
The input
by PASION.
In
ref
type,
which
therefore
control
used
to reference
visible
done
from
by using
reference
to
the
for
compilation
the
equal
equal
to
than
the
the
state
time
previous
of the
variables.
with
extension
by PASION is
by
any
provided
an
ordinary
standard
by PASION allows
viewed
as
is
Ref
existing
program
process
X attribute
used
processes
execution.
within
body,
notation.
Pascal
PASION has
type.
allow
dot
set
greater
program
processing
a process
the
is
variables
of changing
after
program.
queue
variables,
but
time
a Pascal
time
time
capable
of all
.be
Pascal
and
value,
their
the
Pascal
user
to
code
models.
PASION can
on the
have
Next
provided
oriented
fact
imposed
ready
The extension
process/event
is
value
output
program,
Compiler.
minimal
PASION is
The
run.
event
the
to
which
to
the
Each
time.
including
Pascal
events
The
its
and
body.
access
Using
of process
21
with
reserved
declare
to
be
reserved
Process
A.
dot
structure
words
to
outside
the
some
such
reference
referenced
word
this,
attributes
the
notation,
as
process
A.Xis
and
is
are
is
a
3.6 ROSS
ROSS
(Rule-Oriented
language
designed
language.
The
and Director
write
The
syntax,
highly
readable
attributes
to
is
is
simulation
instance
also
clock
that
time,
The last
is
the
errors
reserved
words
which
property
functions
behavior
for
each
of
in
objects
the
language
this
objects
. All
object.
in
for
tick
ross - error
the
the
the
Ne lock
language.
which
have
are
user
ross-
storage
is
sent
to
the
and ross-trace
define
various
properties
object
which
object.
)
22
are
object
of current
respectively.
object
is
ROSS primitive
This
. ROSS language
each
have
to
nlock,
. This
and diagnostics
of
ROSS
simulationist
something,
all
scratch
variables
message
object-oriented
.
defined
instance
two objects,
handling
in
the
in ROSS are
from
and methods
of the
simulation
for
stored
variables
manipulation
objects
generic
objects
LISP-based
in
some predefined
[Klahr82]
other
a
by Smalltalk
definitions
permit
oriented
software.
with
most
is
by SIMULA, all
therefore
objects
the
object
influenced
method
. Other
ross-trace
an
ROSS
greatly
application
behavior
create
behavior
and
and
is
Corporation.
and remotely
The predefined
Something
System)
ROSS was
ROSS comes
and
and
error,
of
commands
- like
defined.
Rand
design
The language
used
at
[Klahr84]
languages.
English
Simulation
is
object
the
has
time
and
To advance
the
object
nlock.
are
responsible
has
some other
of ROSS objects.
inheritable,
The
defines
Creating ROSS Objects
ROSS objects
class.
The
can either
class
objects
terminology.
Generic
command which
takes
create
represent
are
objects
on the
a class
called
are
or an instance
generic
created
following
of the
objects
by
in
issuing
a
ROSS
create
forms:
<objectName>
generic
or
create
The
first
latter
<objectName>
new generic
form
is
of
a destructive
the
other
destructive
hand
the
bearing
Instances
If
the
page
hospital
3 0)
patientl,
(ask
The
patient
created
created
of
class
destroys
by issuing
is
create
the
program
an
the
object
create
the
generic
intact.
any previously
of
command create
was used
instance
by issuing
the
patientl
instance
version
that
ROSS,
be created
destructive
issuing
while
On the
defined
same name.
written
would
The
version
simulation
was
non-destructive,
\
previously
the
are
called
one.
command keeps
object,
is
create
this
create
instance.
in this
of
project
patient,
(
called
command:
)
message
would
have
this
syntax:
(ask
patient
Objects
)
Each
yourself
new
create
can
also
instance
as message
patientl)
new instance
be
created
would
achieves
have
by making
a
this.
copies
distinct
The instance
23
name.
of
The
patientl
themselves.
duplicate
creates
a
copy
of
its
self
using
patientl
(ask
duplicate
Alternatively
sending
objective.
can
have
(ask
patient
to
Andrew
its
following
is however
can
modified
in
as the
the
newly
same
created
ways:
except
999-87-2273
to
achieve
various
patientl
like
ssn
also
more powerful
attributes
patient2
syntax:
patient2)
as
make message
make patient2
set
message
yourself
the
The latter
object
the
patient2
set
name
)
Removing unrequired objects from system
In
conducting
sometimes
This
simulation
remove
is
we were
using
objects
which
achieved
by using
the
to
a message
was going
send
to
not
it
may be
needed
the
command.
yourself
patientl
from
to
kill
necessary
to
simulation.
For example
herself,
the
if
format
be:
patientl
( ask
are
kill
to
ROSS,
kill
yourself)
Communication among ROSS Objects
The
objects
messages.
When an
looked
in
match
a class
the
the
that
template
in
modularity,
ROSS'
is
of
trying
sent
its
with
each
a specific
other
message,
behavior.
A message
by
sending
a match
template
can
Unlike
c++ which
uses
the
parameters
match
a message
to
a the
method,
to
a message
executes
the
first
is
matching
as
ROSS
method
found.
The organization
)
object
when passed
is
ROSS communicate
of messages.
signature
objects
in
of knowledge
modifiability,
object-based
around
objects
and maintenance
framework
can
24
make
in ROSS facilities
of simulation
it
possible
[Klahr84].
for
a
human
sitting
behind
a terminal
to receive
objects
in
application
would
one
of
the
having
gives
role
the
objects
a human
a good
and
as
hence
be able
is
that
is
to
force
and
thus
one
the
of
environment
advantage
easier
in
achieving
with
to
the
normally
simulation
do,
objects
in
for
putting
a human
be used
the
course
)
)
25
in
effectively
event
thus
advantage
is
a decision
in
occur
the
training
in the
simulation
other
respond
that
as
of
it
making
. Other
as detailed
to
of
as the
simulation
a human participation
desired
and
world . A clear
the
some particular
the
same messages
above,
simulation
.
it
Chapter 4
Implementations
)
4.1 Overview
In
this
objected
bank
project,
oriented
scenario,
objects
defined
and
created.
adhered
(ii)
to
that
as close
should
(iii)
perform
one major
Messages
data
using
parts
some
reasonable
for
and
thus
simulations
using
choice
object
for
between
wing
modeled
domains
three
be simple
farm .
being
basic
in all
the
three
and each
Various
modeled
design
a
were
principles
simulations
object
should
:
only
function.
objects
should
of the
should
be simple,
logical,
from
characteristic
of
helping
demonstrate
oriented
the
to
to
of
same
chunks
inherit
rely
the
software
of
from each
minimize
some
not
on the
internal
objects.
benefitted
classes
conducting
simulations
livestock
the
and unambiguous.
implementations
languages
three
among objects
structure
programming
used
to
using
the
as possible
Objects
consistent
These
follo
simulations
and
parallel
The
three
The
scenario
The interaction
)
c++.
hospital
and
(i)
implemented
language
classes
were
we
of
code
the
programming
simulations.
26
other,
Where
it
written.
to
as
by
was
inheritance
was
advantages
- oriented
reusability,
code.
that
language
object
the
be
was
These
gained
language
by
of
4.2 Simulation of a bank scenario
AIM
The goal
of this
simulates
in to
was
the
user
be
display
used
waiting
times
fixed
queue,
then
this
to
the
the
length
is
means
some
the
more
the
to
customers
the
and
Interviews
Library
of
the
in
the
bank
can
minimize
queue
always
length
showing
maximum length
are
being
the
may
to
the
is
in
system
a
order
. since
made
program,
tellers
display
equal
come
environment,
day
output
that
developed
X- Windows . This
customers
lobby
Bank Manager
accommodate
of
if
The system
execute
number
period
model,
whose
supports
by bank
may be because
indicate
to
this
queue
rejection
time
to
a system
when customers
bank.
by the
estimated
built
bank
the
. Therefore
experienced
in
with
that
the
specific
a commercial
provided
output
compute
at
a waiting
' )
routines
a terminal
to
was to
c++ programming
the
the
requires
deploy
was
of
project
business
in
use
to
at
various
implemented
order
of the
activities
conduct
extensive
part
of the
rejected.
is
too
small.
This
need
to
expand
the
lobby
the
design
The
may therefore
in
order
customers.
Design of the system
A decision
system
that
Library.
simulated
the
)
made
at
the
display
would
Therefore
the
plausible
clock
was to use
be updated
mouse.
was
Each
The bank
if
there
is
clock
tick
door
remains
early
stage
be provided
in
by using
way to show the
occurred
closed
event,
when the
during
27
'go'
the
of the
display
and hence
the
button
non-business
the
Interviews
advancement
a mouse . The interviews
a pending
the
of
can only
need
is
for
the
clicked.
hours
and
this
is
shown
trying
)
to
map the
following
object
in the
classes
were
model
real
objects
were
created
by a label
at
developed
from
hanging
the
on the
bank
on to
and instances
bank
the
of the
door.
model,
In
the
corresponding
them.
Struct BankCustomer
The
objects
Each
object
point
to
customers
of
the
type
next
were
defined
by
a struct
its
account
number
in
waiting
queue.
as an abstract
class.
and dequeue().
Each of these
BankCustomer
customer
knows
when placed
BankCustomer.
and
can
Class Queue
The class
the
virtual
can
take
isErnpty()
Queue was defined
methods
an
enqueue(),
argument
which
takes
of
type
BankCustomer,
This
except
class
had
methods
the
method
no argument.
)
Class TellerQ
The
Class
addition
to
TellerQ
items
TellerQ
inheriting
defines
on the
was
created
the
methods
by
methods
to displays
of
subclassing
its
its
class
parent
objects
Queue.
class,
and give
the
In
class
numbers
of
queue.
Class FutureEvent
The
)
class
FutureEvent
defines
methods
methods
that
to
clear
the
to
generate
manipulate
queue
is
of
the
any
a subclass
objects
of
bankCustomer
objects
that
28
of
class
Queue.
customers.
objects
cannot
The
The
as well
class
class
has
as methods
be processed.
Greeting
Message When Program
OOL: C++
SIMULATION
is Run
Feb 199 1
CLOSED
)
Welcome to
a
Bank Simulation
(click
)
•
Figure 7
"start"
St art
Program
to begin)
0 0
go
c
c
T eller
quit
1
)
T el le r 2 )
(T el ler }
)
OOL: C++
SIMULATION
Feb 1991
)
I
OPEN
)
TELLER I
0
Start
O O
go
G:i:mj~:~gr:::::1::1:w
quit
( Teller 2 )
(T eller 3 )
Figure 8
Feb1991
OOL: C++
SIMULATION
l
OPEN
)
TELLER I
TELLER11
)
0
Start
O O
go
( Teller 1)
quit
ci::miJ:ffiit::iil:D
(Teller
Figure 9
3 )
Feb 199 1
OOL: C++
SIMULATION
TELLER I
l
OPEN
)
TELLER11
TELLER111
,
0
Sta rt
O O
go
( Telle r 1)
quit
( Telle r 2 )
€!1~]1~r::~::::::v
Figure 10
Feb1991
OOL: C++
SIMULATION
TELLER I
1 OPEN
)
free:****
TELLER 11
busy: 124 879
TELLER111
busy 456347
)
0
Stan
•
go
O
( Telle r
quit
1)
( Te lle r2)
(T eller 3 )
Figure 11
OOL: C++
SIMULATION
Feb 1991
TELLERI
busy: 768422
TELLER11
■■■
busy: 124879
TELLER111
busy: 456347
0
Start
O O
go
( Teller 1)
quit
(T eller2 )
(T eller 3 )
Figure 12
showing 4 customers
standing
in a queue
Feb 199 1
OOL: C++
SIMULATION
l
TELLER I
CLOSED )
closed
TELLER11
closed
TELLER111
closed
0
Start
O O
go
( Telle r 1)
quit
( Tel ler 2 )
(T eller 3 )
Figure 13 End of a Busines s Day
Class Clock
The class
)
method
the
to
has methods
advances
tick()
gives
time
Clock
current
the
simulated
that
accomplish
clock
by a tick
time,
and method
the
following
value,
tasks:
method
initialize
time()
resets
the
zero.
Class Employee
The
class
Employee
isBusy()
the
setFree(),
who was
free
just
in
come
order
into
is
called
other
so that
methods:
done
that
teller
or
with
a customer,
customer
sent
to
bank
to
able
the
service
a customer
are
setBusy(),
and
assignNoWork(),
is
setBusy()
for
the
When a teller
following
assignWork(),
The method
workisAssign().
has
has
object
a customers
who was
the
on the
method
to get
teller
who
queue.
is
setFree()
service
from
the
bank
teller.
\
Class Teller
The
class
Teller
and
getTimeSpent(),
to
a teller
teller
object,
works.
teller
does
The
method
job.
teller
methods
a random
The method
in
rate
getRate(),
setRate()
at
returns
getRate()
spends
setRate(),
The method
transTick().
assigns
his/her
a particular
has
which
the
a particular
rate
at
returns
getTirneSpent()
servicing
when passed
which
the
a
time
a customer.
Class Bank
Class
)
when
sent
business.
Bank has methods
to
The
the
bank
layout
out
openBank
object,
for
() and closeBank
open
class
29
and
bank
close
is
as
() . These
the
follows:
bank
methods
door
for
class
Bank
{
public:
Bank();
void openBank();
void closeBank();
private:
Boolean
door;
,
}
Output of the bank model
The bank
figures
respective
simulation
7 to
12 .
highlighted
which
Each
is mouse driven
sample
output
button.
)
30
is
sample
given
output
by
is given
clicking
the
4.3 Simulation of hospital scenario
)
Purpose:
The
simulation
objective
was
patients
the
scenario
at
to
the
calculate
modeled
fractional
had
the
is
the
attending
patients.
objectives.
times
The other
of
fraction
main
waiting
hospital.
utilizations
utilization
two
of
The
experienced
objective
the
hospital
their
time
first
by
was compute
employees.
that
is
This
devoted
to
object
of
Class Queue
The
class
object
of
Patient
patient
head
The
object
the
of the
patients
asking
on the
from
the
on the
its
general
class
create
all
simulation,
queue
queue
queue.
queue
queue
for
class
as well
also
queue
and
also
is
as the
are
used
in
customers
the
patients
simulation.
31
puts
method
last
has
return
at
the
returns
been
removing
the
sent
the
for
futureList
beginning
who will
take
the
to
of
part
of
queue
defined
the
of
queue.
number
to
instance
the
value
on the
genPatient()
the
an
for
patient
which
a message
only
a
that
knows how to
The method
patient
these
method
a method
when
cardinality.
the
and
The queue
has
queue
has
in
the
the
Class HospitalEmployee
The
class
security
Hos pi talEmployee
number
and employment
to the
object
of this
number
and
employee
generates
also
the
knows
handled
the
day,
average
before
class
time
getting
asking
using
report
the
for
the
The
the
how
patient
return
object's
number
spends
in
sent
security
this
generator.
of
social
been
social
for
number
of the
it
have
constructor
average
length
to
when messages
a random
average
each
service
number
number .
numbers
how to
that
knows
class
This
object
patients
queue
for
that
that
employee's
it
has
day
and
queue
.
Class Nurse
Class
knows
Nurse
how
is
of HospitalEmployee.
respond
to
qualification,
average
time
a
before
service
from
the
getting
queue.
time
to
a subclass
The nurse
that
attending
the
to
also
messages
asking
patient
nurse,
knows ho w to report
hospital
was
some patient
open,
The nurse
the
is
for
its
delayed
and
the
fraction
nurse
education
in
average
was
object
the
queue
length
of
of the
total
actually
a
busy
.
Class Receptionist
This
class
HospitalEmployee.
similar
methods
Receptionist
is
The instances
that
class
Nurse
of this
object
)
32
subclass
class
of
respond
responds
to.
the
basically
class
to
Class Doctor
The class
)
instances
class
Doctor
is
of this
Nurse
subclass
class
object
of the
respond
responds
class
basically
HospitalEmployee.
to
similar
The
methods
that
to .
Class Patient
An instance
asking
for
of
class
patient
its
name,
instances
of
this
class
requesting
for
time
it
that
for
point
to
social
security
also
next
at
nurse
patient
if
how to
and age
method
to
particular
or
they
respond
number,
has
arrived
a receptionist,
the
knows
doctor.
to
messages
in years.
respond
service
The
The
messages
station,
objects
have
been
queued .
to
any
simulation
i.e .
can
also
Class Clock
I
)
The
instance
well
Clock
is
of this
class
as advancing
the
cannot
of
class
future
essential
has
method
simulated
be overemphasized
as
for
time.
this
class
returning
the
model.
current
The importance
An
time
of this
coordinates
the
as
class
scheduling
events.
Class Building
The
instance
subclasses
which
hospitalEmployee
the
simulation
of
this
define
class
the
objects
in motion
defines
different
a hospital
wards
work . The creation
.
33
and
of
building.
departments
this
instance
it
has
where
sets
Results of Simulation Runs
Receptionist
)
Mean delay
in
Nurse
5.81
Doctor
22.32
56.99
a queue
Mean # of
patients
in
0.27
0.96
2.63
0.78
0.40
0.47
20671
20671
a
Queue
Percentage
Utilization
Time
20671
simulation
ended
The above
)
of the
patient
The
value
results
the
between
with
maximum value
the
in
both
hospital
numbers
delays
of
in
experienced
lowest
for
this
varied
in
that
from this
the
delay
is
one
do
with
with
also
a
time
30,
order
not
and
unit.
units.
a random
the
nurse
and
the
50 time
units.
The
employees
at
of
come up with
significantly
arrival
distribution,
Numbers
to
was
of time
random
the
mean 5.0
a patient
The length
respectively
was
in which
cause
the
optimum
intolerable
queue.
The results
the
be
patients
the
units.
had
were
cases
can
spent
patients
of each
from a run
distribution
receptionist
1 and 10 time
spent
minimum
generated
was an e x ponential
time
doctor
were
that
highest
in the
the
simulation
average
runs
delay
receptionist
indicate
in
the
queue.
receptionist
do
34
that
doctor's
A possible
nothing
else
the
patients
queue,
and
explanation
apart
from
attending
other
to
than
number
queue
the
of
patients,
spending
highest
in the
are
may have
A hospital
simulation,
the
in
fractional
receptionists
who are
kept
doctors
time
may have
with
a queue
was
employed
to
other
all
the
meet
would
does
not
have
time,
long
highest
but
do.
be
interested
at
queues
J
)
35
for
while
to
want
the
the
to
doctor's
to
of patients
this
this
deploy
same time
gave
is that
doctors
in
do
average
The receptionist
patients,
might
work
The
in
An explanation
administrator
busy
other
patient.
queue.
things
administrator
each
also
receptionist's
utilization.
a lot
as the
hospital
longer
patients
and lowest
nurses
while
and
kind
of
fewer
staff
ensuring
that
waiting.
4.4 Simulation of a livestock farm
)
AIM
Biological
systems
be modeled
that
in that
interact
chapter
each
in the
are
out
model,
system
was
animals
is
that
modeled.
related
ones
to
less
model
liveweight
how
out
system
impact
on the
in
are
model
In an attempt
subsystems,
showed
can
of subsystems
the
system.
fewer
that
As pointed
influence
having
had
systems
a number
ways.
a manageable
which
The
complex
various
directly
to have
model
most
may have
in
and the
in order
a biological
system
other
components
included
find
some of the
a typical
with
one,
left
are
a cattle
feed
to
ranch
intake
of
the
gain/loss.
Discussion of the model
A real
)
of
the
space
a productive
are
FoodStore,
and
The amount
model
system
such
for
the
in which
the
amount
animals
enterprise.
and
The objects
created
from
the
the
proper
and
quality
others,
which
classes
management
is
of
very
crucial
participate
Animal,
feed,
in
Cattle,
the
Farm,
Clock.
of
liveweight,
this
a complex
available
animals,
simulation
its
is
resources
water,
for
ranch
are
feed
that
each
animal
takes
is
computed
sex,
and age .
The parameters
and
based
on those
use
[Orsini86].
by
Orsini
formulae
based
on
used
in
Class Animal
The
instance
)
of the
livestock
at
of class
animal
the
animal
in months,
farm
belong
responds
its
to
the
to message
liveweight
36
superclass
requesting
and identity
Animal.
for
given
the
An
age
by a tag
number
is
which
more
wait.
establishes
its
the
that
than
number
The carrying
) depends
magic
the
was
farm
can
100,
space,
at
100
animals.
was
just
population
animals
population
and
it
animal
sustain,
feed
fixed
number
When the
maximum animal
available
capacity
with
the
capacity
on the
carrying
uniqueness.
but
in
loose
on the
this
There
model
was
an arbitrary
farm
the
nothing
choice.
Class FoodStore
The
instance
available
at the
draw
from
feed
to messages
)
of
objects
the
amount
stocking
the
of
keeps
The feed
store.
it
The instance
class
feed
track
of
continuously
to release
of this
more
class
farm.
asking
that
this
remaining
for
to,
in
an animal.
those
feed
animals
responds
Other
FoodStore
of
as the
FoodStore
include
the
amount
dwindle
of class
feed
respond
the
massages
requesting
and
for
message
for
£eed.
Class Cattle
The class
to
the
animal
The
totalEaten.
animal
takes
assumption
and
Cattle
that
calves
converting
food
calves
livestock
at
each
subclass
that
method
totalEaten
all
the
have
to
take
was given
feeding
of Animal.
classes
on average
that
that
is
respond
returns
feed
that
is
weight.
fewer
uni ts
three
grown
food
of
feed
times
up cattle
37
to
each
animal
when
a day.
were
it
mature
given
it
the
on the
is
eaten
comes
to
was assumed
animals.
The calves
and
feed
modeled
simulation,
than
methods
graze
of
is
efficiency
In the
adds
quantity
The simulation
given
class
messages
day.
body
and the
to
each
a higher
feed
This
got
50 units
The
35 units
each.
Class Clock
The class
into
3 time
year
of
Clock
ticks
maintains
on simulation
simulated
termination
of
time
time.
the
of
the
clock.
The clock
simulation
day.
day
The simulation
instance
after
Each
a year
is
divided
runs
is
responsible
has
elapsed.
for
one
for
the
Class Farm
The creation
initiates
the
totals
while
total
are
of
animals
of
farm,
makes
population
animals
on
genstats
when sent
the
the
feed
in
to
sent
to
the
given.
to the
the
farm
the
simulation
at
the
of
feed
totals
and
feedTime(),
when sent
on the
object,
other
stock,
of cattle,
methods,
animals
farm
program
amount
feedTime
On the
object
queue
variables
to
The message
is
of
and
responds
available
when
results
the
farm
driver
variables
the
at
Farm
instance
maintains
respectively
class
farm
Farm in the
has
stock
and genStats().
message
outputs
The class
maintained
An instance
object
of class
The instance
number
population(),
instance
simulation.
and feed.
available
feed.
ofan
the
hand,
the
end of the
to the
farm.
The
number
of
message
simulation,
run.
Results of Simulation Runs
The
simulation
following
application
table
gives
in
which
a
the
varied.
)
38
summary
ratio
of
of
five
adults
runs
to
of
the
young
was
# of adult
# of calves
Animals
Mean weight
Mean feed
Mean
gain/loss
intake
animal
weight
0
100
271. 7
37941.
25
75
285.8
48453.8
710.6
50
50
300.3
59403.8
800.1
75
25
315.2
70353.8
890.0
100
0
329.9
81305.8
927.7
The above
table
adult
cattle
to
have
a higher
this
is
that
adults
liveweight.
intake
as well
order
to
determining
attain
the
ranch
data
can
the
animals
the
manager
help
more
required
him/her
feed
compute
gain
might
the
in calculating
.
39
ratios
adult
of
animals
An explanation
young
computed
for
and
based
have
a
on feed
animal.
find
he/she
weight
that
their
is
621. 0
different
calves.
than
of the
how long
can
that
weight
owner
several
indicate
gain
liveweight
ranch
for
results
weight
take
as
is
The
Average
A livestock
in
results
calves.
average
higher
useful
of
8
this
has
before
total
to
kind
of
model
feed
the
animals
selling
feed
optimal
them
off.
very
in
Since
used
in
a year,
time
to
cull
this
some of
Chapter 5
Comments and conclusion
5.1 Overview
In this
chapter,
faced
during
areas
in
then
the
go on to
try
improvement
explain
three
to enumerate
implementation
which
of these
we will
could
what
computer
of
the
make
we have
the
simulations
that
and
implementation
learned
simulation
problems
from
were
propose
easier.
the
We
implementation
models.
5.2 Problems experienced
The
temptation
message
the
passing
But
implemented
is
deciding
true
in the
the
the
library
interfaces
for
therefore
physiological
a good
limiting
that
its
changes
use
that
a
effort,
only
in models
occur
using
the
of
this
the
area
of
kind,
required
minimize
take
longer.
incorporating
library,
are
in biological
40
therefore
of
could
· however
be activated
that
objects
before
highly
implementation
The
of
in
c++ is new and evolving
that
for
stages
an object,
is
the
passing.
project
Since
candidate
can
some
is
application
models .
events
early
some knowledge
out
the
in the
objects
libraries
made
bypassing
by message
inc++
objects.
of
simulation
in
of
required
is
therefore
with
other
required
area
effort,
Interviews
each
carrying
scarcity
implementation
and
go in designing
language
the
C and
by,
everything
Before
with
language,
with
not
in
went
we should
to define
shortcomings
time
that
application.
order
)
as
how far
familiarity
code
was irresistible
communicated
primitives
the
write
philosophy
project.
It
to
to
simulations.
The
good
user
has
its
by a mouse,
supposed
the
and
show the
5.3 Suggestion for improvements
There
are
a number
of
areas
form,
one
in which
the
implementations
could
be improved.
In
its
program
a
present
is
queue.
that
it
This
application.
not
facility
There
hospital
simulation
general
practioners,
treat
does
weakness
compute
should
are
not
too.
be
Instead
we could
have
and patients,
the
average
some enhancements
model
some diseases
with
bank
time
customer
very
hard
that
could
of
to
doctors
model
could
add
to
doctors
who are
choose
spend
be done
having
doctors
simulation
to
in
the
the
who are
specialized
according
to
to their
diseases.
The
the
livestock
number
situation
In
)
real
year
of
animals
where
cattle
life
are
farm
on the
give
numbers
bound
to
simulation
of
farm
birth
is
be modified
dynamic,
and
and some animals
animals
at
a farm
so that
thus
modeling
are
sold
the
course
during
or die.
of
a
change.
5.4 Lessons learned
Apart
from
restructuring
languages.
constructing
re-using
form
It
of
did
The benefit
code
Another
order
new
language,
which
lesson
to
lesser
was learned
has
really
can
only
up with
work
during
that
the
good
it
means
speed
project
time
design
of
in
in
in object
designing
and
development
later
of
projects
by
now.
spent
of
on the
objects
"design
rewarded
the
implementation
stage.
mapping
of real-world
objects
41
helped
to program
up the
be reaped
developed
was that
the
method
not
been
learned
come
what
Object-oriented
software
software.
in
a
my way of thinking
oriented
the
learning
table"
in
the
and concepts
to
software
objects
An effective
way of
object-oriented
easily
map
simplifying
was direct
conducting
languages,
to
objects
the
cost
and
simulation
since
of
the
intuitive.
the
objects
simulation
of designing
seem
in
and
and producing
)
42
to
the
be
real
therefore
such
in
using
system
further
software.
References
(Bezi88)
[Blona66)
Bezivin,
Jean;
Oriented
Simulation;
Blordick,
Budd,
and
Naylor
for
Industrial
Timothy;
of
Systems;
Software:
in
V19,Number
T; Design
The Design
Interpreter;
Implementation
Simuletter
D and
Experiment
(Budd88)
Design
of
Object
Practice
Object
2,
1988.
Computer
Simulation
CACM, June
1966 .
Oriented
and
June
Command
Experience;
Jan.
1988.
(Budd91)
(Fran77)
)
Budd,
Timothy;
Programming,
Addison
Franta,
The Process
W.R.;
Holland,
(Forr61)
Introduction
New York,
Forrester,
(Gauss78)
(Gold83)
Problems
in
a Semi-Arid
Model;
CSIRO;
Gauss,
Saul;
Winter
Language
of
.
Simulation;
North-
Dynamics;
M.I.T
. Press;
1961.
T . G. And Benyon,
Goldberg,
View
1991
1977.
Freeman,
of
Object-Oriented
and Wesley,
J.W . ; Industrial
Massachusetts;
(Frebe83)
to
Simulation
Adel
and
Environment:
Canberra,
Computer
and
its
P . R; Pastoral
Australia;
Model
David;
Implementation;
43
Social
A Simulation
1983 .
Documentation;
Conference,
Robson,
and
Proceedings
1978 .
The Smalltalk
- BO: The
Addison-Wesley,1983
.
[Gorlen90]
Gorlen,
Keth;
Abstraction
Wiley
[Grapo80]
[Hoope89]
[Khe85]
and
)
1980.
Stewart
and
Wesley;
1983.
Kheir,
Nairn;
System
Klahr,
Philip
Rand
Monica,
CA.
Law,
Practice;
Number
inc++;
John
Simulation:Principles
Cambridge,
Ronald;
Modelling
and
Simulation;
Computer
Simulation,
Mand
Addison
Simulation;
of
Bath;
Kelton
Computer
Society
of
The ROSS Language
(Sept
Intelligence
1984
United
W.D.;
McGraw-Hill
John;
David;
N-1854-AF
Proceedings
and Analysis;
McLeod,
Perry,
Artificial
'
Averill
programming
Publishers,
Publication
P·
Computer
Data
U.W.;
and McArthur,
Manual;
Klahr,
Perry;
1985.
Simulation;
[Macle82]
and
Plexico,
1990.
Pooch,
Massachusetts,
[Klahr84]
[Law82]
and
Winthrop
Hall;
Oriented
New York;
Methods;
Prentice
[Klahr82]
Sons;
W.J.
Hoover,
Sanford;
and Object
Graybeal,
and
Orlon,
Computer
5;1982.
44
Santa
to
Applied
UKSC conference
on
Kingdom.
Simulation
Book Company;
Modelling
1982);
and
Modeling
New York;
Principles
Simulation,
V16
1982.
of
Good
[Mary80]
Maryanski,
Fred;
Book Company;
Digital
Computer
Simulation;
Charles;
Elements
Hayden
1980.
)
[Mesa85]
MacNair,
Edward
Practical
Nance,
Oren,
of
R.E.;
Time
T.;
Concepts
Simulation
#2,
Pollacia,
and
changes
Pritsker,
Simulation
to
A Frame
G.W.;
in
in
Access
Simulation
Acceptability
Of Reference;
sheep
Predicting
grazing
environment.;
CACM;
the
wheat
stubble
Agricultural
in
Systems,
1986
J.,
Babich
CACM, June
Lissa;
and
of
Significant
Discrete
Event
Event
Languages,
Discrete
Fall
A.A.B.
A.,
Event
1975.
A Survey
State-of-the-art
Publication,
[Pripe79]
Relationship
Criteria
& Arnold,
. , Grason
Simulation;
[Polla89]
New
1981.
and
a mediterranean
Parnas,D
state
Studies:
J.P.G.
liveweight
[Paba57]
Prentice-Hall;
.
Orsin,
V20,
and
CACM, April
Apr,1981
[Orsini86]
Modeling;
of
1985.
Modeling;
[Oren81]
Sauer
Performance
Jersey;
[Nance81]
and
Simulation
SIGSIM
1989.
and
Pegden
SLAM; John
45
C.D.;
Wiley
Introduction
& Son;
New York,
to
1979.
[Rumba91]
Rumbaugh,
James
design;
I
et
Prentice
all;
Object-Oriented
Hall;
New Jesrsey;
Modeling
and
1991.
,
(Rac86]
Paczynski,S;
(Sarge83]
PASION;
Sargent,
Robert;
proceedings
(Shan75]
Shannon,
Robert;
Stroup,
and
(Summers90]
)
System
reading,
Summers,M.K.;
Applying
event
the
Conference,
Simulation:
Object-Oriented
simulations
using
1990.
)
46
and
Science;
1975.
Language;
Massachusetts,
Eldredge,
Models,
1983.
The Art
The c++ Programming
Bjarne;
1986.
Computer
Simulation
New Jersey;
Wesley;
June
Validating
of Winter
Prentice-Hall;
(Strop86]
Simulation,
David;
Addison
1986.
McGregor
paradigm
C++ language;
J.D.;
to
discrete
Simulation,
Feb
Download