Transcript Chapter 3

ECE 449/549
Class Notes # 4
DEVS Models for Processing and
Coordinating Workflow
/
System Entity Structure
Sept. 2008
DEVS Models for Processing and
Coordinating Workflow
•
•
•
•
•
•
•
•
•
Sending/Receiving/Interpreting Messages
Processor Models
Workflow experimental frame components
Work Flow Coupled Models
Experimental Frame for Workflow Performance Measurement
Hierarchical Model Construction
Workflow Coordinator Models
Workflow Architecture Models
Performance of Simple Workflow Architectures
Sending/Receiving/Interpreting Messages
how to use casting to receive instances of arbitrary entity subclasses
coupled model
entity
out
in
A
B
double
doubleEnt
doubletEnt(double)
double
getv() → double
coupling: (A,”out”,A,”in”)
public message out( ){
message m = new message();
m.add( makeContent("out", new
doubleEnt(1.2));
return m;}
“in”
p
“out”
val
message
doubleEnt
v
double
p
val
content
add
content
casting the received
entity down to the
doubleEnt subclass
cast
doubleEnt
getv()
deltext(double e,message) x){if
(somethingOnPort(x,"in"){
entity val = getEntityOnPort(x,"in");
doubleEnt f = (doubleEnt)val;
double v = f.getv();}}
v
double
Sending/Receiving/Interpreting Messages (cont’d)
multiple copies of an object are needed to avoid hard-to-find dependencies.
coupled model
entity
out
in
A
B
job
job
coupling: (A,”out”,A,”in”)
Suppose A sends its instance of
job directly to B:
public message out( ){
message m = new message();
m.add( makeContent("out",
“out” job)
return m;}
and B stores it as its instance:
deltext(double e,message) x){
if (somethingOnPort(x,"in")){
myJob = getEntityOnPort(x,"in");
This instance of job is now shared in
common by both A and B –
if either makes a change to its state, then
the other will also be subject to it.
For example, if B does:
job.update(10);
then the instance at A will be similarly
altered.
This can lead to mysterious effects
(similar to quantum entanglement) where
components of a model can influence each
other outside of their interface couplings.
It is difficult to trace this kind of nonmodularity.
The cure is simple: create a new instance as a local copy of an entity if it is to be altered
(this happens automatically when using toString() and toObject(), see chap. 12)
job •job(procTime)
•update(e):
procTime += e;
•copy(): return new
job(procTime);
The right way:
B stores a copy of its input:
deltext(double e,message) x){
if (somethingOnPort(x,"in“)){
job temp =
getEntityOnPort(x,"in");
myJob = temp.copy();
where copy() is a method you
define to create a new instance
of job and give it values of an
existing one.
Processor Models
Atomic model
I/O Behavior Description
processor
Simple processor representing only storage of job and
passage of time for its execution; no buffering or
preemption
processor with
queue
Processor with FIFO (First In/First Out) queue selects
next job based on earliest arrival time
processor with
priority queue
Processor with queue selects next job based on its
priority. It can be interrupted by higher priority job.
Requires user defined class job in which priority is
based on processing time.
Processor with queue
illustrating how to process a bag of inputs (multiple concurrent events)
public class procQ extends proc{
protected Queue q;
public procQ(String name,
double procTime ){
super(name,procTime);
q = new Queue();
}
public void deltint( ){
q.remove();
if(!q.isEmpty()){
job = (entity)q.first();
holdIn("busy", procTime);
}
else passivate();
}
accumulate the
inputs on port “in”
into the queue
class Queue is
a container with
FIFO discipline
remove the job
at the front that
was just
finished
public void deltext(double e, message x){
Continue(e);
if (phaseIs("passive")){
for (int i=0; i< x.size(); i++)
if (messageOnPort(x, "in", i)){
q.add(x.getValOnPort("in", i));
}
holdIn("busy", procTime);
job = (entity)q.first();
this makes sure
}
the processed job
else if (phaseIs("busy")){
is the one at
for (int i=0; i< x.size();i++)
the front
if (messageOnPort(x, "in", i))
{
entity jb = x.getValOnPort("in", i);
q.add(jb);
}
}
}
Workflow experimental frame components
Atomic model
I/O Behavior Description
generator
generates jobs with fixed interarrival
time
generator of time
consuming jobs
generates jobs at random times with
assigned randomly distributed
processing time
transducer
records job arrivals and departures and
measures turnaround time and
throughput
The transducer measures two performance indexes of
interest for work flow: the throughput and average
turnaround time of jobs in a simulation run.
generator is an autonomous model,
(its behavior is self induced by recurring internal events)
hence, it does not need an external transition function
To dictate its response to external input events.
The added an input ports “start“ and “stop“ when
stimulated, start and stop the generation
of outputs.
• throughput is the average rate of job departures from
the architecture,
•estimated by the number of jobs processed during the
observation interval,
•divided by the length of the interval.
• A job's turnaround time is the length of time between its
arrival to the processor and its departure from it as a
completed job.
• For the simple processor, the turnaround time is the
same as the processing time. (For more complex
architectures, this relationship is not necessarily true as
we shall see.).
•To compute the performance
measures, the transducer,
places job-ids that arrive at its
'ariv input port on its arrived-list
together paired with their
arrival times.When, and if, the
job-id also appears at the
'solved input port, the
transducer places it on the
solved-list and also computes
its turnaround time. it maintains
its own local clock to measure
arrival and turnaround times.
•In transd, an internal transition
is used only to cause an output
at the
end of the observation interval.
In a more general experimental
frame, the role of terminating
the simulation run would be
handled by a component
called an acceptor.
Work Flow Coupled Models
Coupled model I/O Behavior Description
Simple pipeline
Sequence of processors forming a pipeline
processor
Switched
network
Switch sending input to two processors
alternatively
Generatorprocessortransducer
Generator sends jobs to processor which is
observed by transducer
Work flow
experimental
frame
Experimental frame consisting of generator and
transducer
Hierarchical
Hierarchical model which top level consisting of
workflow frame experimental frame and processor
and model
Basic Workflow Coupled Model – generator, processor, transducer
Experimental Frame for Workflow Performance Measurement
• Output lines may diverge to indicate the
occurrence of simultaneous events. When
genr sends out a job identifier on port “out”,
it goes at the same clock time, both to the
“ariv” port of transd and port “out” of ef,
hence eventually to some processor model.
• Input lines may converge, i.e., two or
more source ports connected to the same
destination port, can occur. Bags represent
the collection of inputs that arrive
simultaneously at a component.
Instances of the classes genr and transd are coupled together to form the experimental frame, ef.
•The input port “in” of ef is for receiving solved jobs which are sent to the “solved” input port of
transd via the external input coupling.
•There are two output ports: “out”, which transmits job identifiers sent to it by genr, and 'result
which transmits the performance measures computed by transd. External output couplings bring
about both these transmissions.
• There are two internal couplings:
• the output port “out” of genr sends job identifiers to the 'ariv port of transd
• the output port “out” of transd which couples to the 'stop input port of genr.
Hierarchical Model Construction
EF
EFA
GEN
TRANSD
EF
ARCH
ARCH
PROC
COORD
PROC
Example: Flat Coupled Model
gpt
start
start
generator
(genr)
out
in
stop
out
out
arrived
solved
processor
(proc)
transducer
(transd)
out
Experimental Frame/Model Modularity
efP
ef
start
start
start
generator
(genr)
out
out
in
stop
solved
out
out
arrived
solved
processor
(proc)
transducer
(transd)
out
out
Hierarchical Coupled Model
efP
start
start
out
in
ef
out
solved
Processor
With
Queue
(procQ)
out
out
Hierarchical Models and
Experimental Frame
Modularity in DEVSJAVA
Create EF
ef.setBlackBox(true)
m.setBlackBox
(true)
Workflow Coordinator Models
public class Coord extends proc{
public Coord(String name){
super(name,1);
inports.add("setup");
inports.add("x");
outports.add("y");
public void initialize(){
passivate();
super.initialize();;
}
protected void add_procs(devs p){ //use devs for signature
System.out.println("Default in Coord is being used");
}}
Coord
divide
Coord
pipe
Coord
multi
Server
Coord
Atomic
model
I/O Behavior Description
divide and
conquer
coordinator
breaks incoming jobs into parts for
processing and compiles the results into
a final output
pipeline
coordinator
routes incoming jobs through a series
of processing states and outputs the
results
Multiserver
coordinator
routes incoming jobs for processing
and collects the results for final output
Workflow Architecture Models
Architecture
in
in
co
out
out
x
y
p0
p1
p2
Coupled model
Divide and
conquer
divide and conquer coordinator with processors
Pipeline
pipeline coordinator with processors
Multiserver
multiserver coordinator with processors
Performance of Simple Workflow Architectures
Architecture
Processing Time
Average
Turnaround
Time
Maximum
Throughput
Simple Processor
p
p
1/p
Multiserver
p1,p2,p3
3/thruput
1/p+1/p2+
1/p3
homogeneous
p1=p2 = p3 =p
p
3/p
Pipeline
p1 + p2 + p3 = p
p
1/max{p1,p2,
p3}
homogeneous
p1=p2 = p3=p/3
p
3/p
Divide and
Conquer
p1 + p2 + p3 = p
max{p1,p2,p3} 1/max{p1,p2,
p3}
homogeneous
p1=p2 = p3 =p/3
p/3
3/p
Average turnaround time and maximum throughput as a function of processing time
The System Entity Structure: Using
Simulation to Search and Optimize
•
•
•
•
System Entity Structure
Examples
Model Base Organization and Synthesis
System Entity Structure for Optimal crew
size
System Entity Structure
• System Entity Structure (SES) represents a family of
hierarchical DEVS models
• Particular members of the family are generated by
process called pruning to generate a pruned entity
structure (PES)
• A hierarchical DEVS model ready to execute is
obtained by
transforming a PES, i.e., accessing
components in a repository and coupling them
together according to the PES specification.
System Entity Structure Axioms
SES is represented as a labeled tree with attached attributes
that satisfies the following axioms:
•
alternating entity/aspect or entity/specialization:
Each node has a mode that is either entity/aspect or entity/specialization
such that a node and its successors are always opposite modes; the
mode of the root is entity.
Coupling is associated with aspects
•
uniformity:
Any two nodes with the same names have identical attached variable
types and isomorphic sub-trees.
strict hierarchy:
No label appears more than once down any path of the tree.
valid brothers
No two brothers have the same label.
attached variables:
No two variable types attached to the same item have the same name.
•
•
•
aspect
entity
specializ
ation
Key Items
Entity
An independently identified real world object
Aspect
Represents one decomposition out of many possible of an entity
Specialization
represents the way in which the entity can be categorized into specialized entities 
SES Example
elevator
physical
decomposition
floors
motion
specialization
carriage
specialization
contents
contents
specialization
people
cargo
lift
escalator
passenger
freight
Rule – if select freight from carriage spec
then select lift from motion spec
and select cargo from contents spec
Rule – if select passenger from carriage spec
then select people from contents spec
SES Multiplicities
city
city
roadNet
multiple
aspect
roadNet
roadSeg
multiple
entity
road
Sched
(S)
line
traffic
Genr
(G)
seg
step
traffic
Light
(L)
event
roadNet
roadSeg
S
Seg
G
Seg
L
...
Seg
S
Seg
G
Seg
L
...
Seg
S
Seg
G
Seg
L
...
Seg
System Entity Structure Inheritance
e.g., Mapping into XML
specialized
entities inherit
their parents
subtriee
vehicle
aluminum.airplane.vehicle
material
composition-
decomposition
- density
= low
- strength
= medium
speed
= high
transportation
class
density
- strength
- speed
decomposition
motor
transmission
propulsion
steel
wood
wings
wheels
aluminum
- density
= low
- strength
= medium
car
ship
- buoy
ancy
Rule: if select airplane from transportation
then
select aluminum from material composition
and wings from propulsion
airplane
- speed
= high
motor
transmission
wing.propulsion
XML:
<object> aluminum.airplane.vehicle
<density> low
<strength> medium
Note:
<speed> high
buoyancy
<madeof>
field is not
motor
present
transmission
wing.propulsion
SES/Model Base: Synthesize new models
from reusable DEVS components
Develop a
System Entity
Structure to
organize the
Repository
transforming
pruning
SES
PE
S
hierarchical
DEVS
model
Repository
of DEVS
components
SES and UML as Ontologies
ontology
UML
SES
Classes
General things in the
many domains of interest
yes
x
Instances
Particular things
yes
x
Relationships
among things
Generalization
/specialization
(a kind of)
associations
(aggregations,
composition (part of)
dependencies,…)
labeled
specialization
labeled
decomposition
Properties
(and property values) of
things
instance variables and
values
instance variables and
values
Functions
Functions of, and
processes, involving
things
sequence diagrams
collaboration diagrams
pruning to generate
models from family
specified by SES
Constraints
on, and rules, involving
things
no
synthesis constraints
selection constraints
Worker Interference
A wall has a 1000 bricks. A brick layer can build such a wall in 1000 minutes.
However, if N people work on the wall together each can only work at this
standard rate until 1000-aN bricks have been laid. At that point, the
remaining (aN) bricks have to be done by one person at the standard rate.
Note a>0 is the interference factor.
a)
Develop a DEVSJAVA model with parameters, N and a.
b)
Develop an experimental frame (efb) the measures the time it takes to
complete the task
c)
Run your model in a) coupled to efb and note the time.
d)
Derive a formula for the completion time as a function of N and find the
optimal value of N (the number of workers that minimizes the time to
completion).
System Entity Structure for Worker Interference –
Finding the optimal crew size by simulation
workerOpt
~interference param, a
~maxCrewSize
(min(35,1000/a)
fireOnceNeuron
distribute
these on
different
computers
for parallel
execution
workCrews
workCrew
~numWorkers
rate
var
Estimator
Dsiplay
(EF)
workerCellSpace
(arch)
workerCells
sum
thresholdTester
~threshold = 1000 – a*numWorkers
workerCell
(varGen)
SES in Natural Language and
Model Base
Aspect
Coupling
Specialization
XML Output
Coupling
Info
SESBuilder
www.sesbuilder.com
• Developed by RTSync Corp
and ACIMS(Arizona Center for
Integrated Modeling and
Simulation) at the University of
Arizona
• Natural Language Expression
for the Component
Composition and Data
Modeling
• Automatic XML and Schema
output
Case Study: Application to the US Climate
Data
Overall System Structure
XML
Metadata
Source Data
(US Climate Data)
DEVS Component
Repository
Source
Data to
DEVS
model
DEVS
Components
Query by SES
(Component name,
Coupling Info)