modeling. conceptual modeling: petri nets implementation: arena, cpn tools simulation needed: build...
TRANSCRIPT
Modeling
Modeling
Conceptual modeling: Petri nets
Implementation: Arena, CPN tools
Simulation needed: build models.Start with concepts, then select appropriate tool.
Conceptual modeling: objectsTo be modeled: dynamic system, possessinga state composed of objects from various classes.Two types of classes: case and resource classes.The life cycle of a case object contains object stateswith transitions in between.Petri net: state machine with source / sink transitions.
arrive decide make_doc leave
wts rdy
return
ok?
instruct
to_shop
ok!
new_photo
back
accept
create disposechoice
Resource objects are not created or disposed of.They may be needed for state change of case objects.The start activity may claim one or more free resources.End activity: release some or all resources claimed.A resource can be used by only one case object at a time.
Resources
arrive decide make_doc leave
wts rdy
return
ok?
instruct
to_shop
ok!
new_photo
back
accept
freeservant
Place invariant for each resource type
Time dependencyTransition of object may take time.Simulation clock indicates current time.Objects possess time stamp indicating availability time.After transition, an object may be unavailable for a while,due to a delay.
11:51 stamp: 11:5611:5211:56
arrive decide make_doc leave
wts rdy
return
ok?
instruct
to_shop
ok!
new_photo
back
accept
servant delay: 5
System state: many case objects in various object stateswith various time stamps.
System state changeby creation / disposal / update of single object.
System
11:5511:56arrive decide make_doc leave
wts rdy
return
ok?
instruct
to_shop
ok!
new_photo
back
accept
servant
Model with different (sub)classes.
Alternative modelsarrive decide make_doc leave
wts rdy
return
ok?
instruct
to_shop
ok!
new_photo
back
accept
servant
arrive decide make_doc leave
wts
rdyok?
arrive2
decide2 make_doc2
servant
wtsok?
instruct
to_shop
ok!
new_photo
return
back
leave2rdy2
ok!accept
The two models are trace equivalent;they differ in the moment of choice.This difference is relevant for dynamic systems,but not for simulation models ("batch processing").
Moment of choice
arrive decide make_doc leave
wts rdy
return
ok?
instruct
to_shop
ok!
new_photo
back
accept
servant
arrive decide make_doc leave
wts
rdyok?
arrive2
decide2 make_doc2
servant
wtsok?
instruct
to_shop
ok!
new_photo
return
back
leave2rdy2
ok!accept
Removal of redundant transition.
Reduction
arrive decide make_doc leave
wts rdy
return
ok?
instruct
to_shop
ok!
new_photo
back
accept
servant
arrive decide make_doc leave
wts
rdyok?!
arrive2
decide2 make_doc2
servant
wtsok?
instruct
to_shop
ok!
new_photo
return
back
leave2rdy2
arrive decide make_doc leave
wts rdy
return
ok?!
instruct
to_shop
new_photo
back
servant
arrive decide make_doc leave
wts
rdyok?
arrive2
decide2 make_doc2
servant
wtsok?
instruct
to_shop
ok!
new_photo
return
back
leave2rdy2
ok!accept
Here too?
Object needing server resource for 5 time units.
arrive leave
wtr rdy
Start activity
Queue model
11:5512:00
constant delay: 5free
Ready after 5 time units
Object needing resource for 5 time units.
arrive leave
wtr rdy
Start activity
Queue
11:5512:00
constant delay: 5free
First ready at 12:00,
More arrivals, resource still occupied
11:58
second at 12:05
Object needing one resource for 5 time units.
arrive leave
wtr rdy
Start activity
Two server queue
11:5512:00
constant delay: 5free
More arrivals, another resource available
11:58
First ready at 12:00, second at 12:03
Ferry model
10
arriveA getonboardA
getoffboardA
getoffboardB leaveB
getonboardB arriveBleaveA
free place
wtA crAB atB
wtA atBcrBA
Get on/off board should be restricted.Resource: free place on ferry.
Give examples of incorrect behavior.
delay
Improved ferry model
10
arriveA getonboardA
getoffboardA
getoffboardB leaveB
getonboardB arriveBleaveA
freeplace
atA atB
A2B
B2A
wtA crAB atB
wtA atBcrBA
A2B and B2A have lower priority than other transitions.
Conceptual model analysis
10
arriveA getonboardA
getoffboardA
getoffboardB leaveB
getonboardB arriveBleaveA
freeplace
atA atB
A2B
B2A
wtA crAB atB
wtA atBcrBA
Resource invariants (per resource type)
Case invariants (per case type)
N
Abstract from timing.
Liveness analysis
a b
Avoid resource locks.
The depicted sequence results in a resource lock.No release possible, since all depend on extra claim. It is dangerous to depend on timing to avoid this.
Solution: preserve option to terminate before claiming.
Resource lock prevention
a b
If a resource lock is possible, add test arcs as shown.
Last case is able to release claimed resources.No lock!
Conclusion (conc. model)
Conceptual model: Petri net
Places represent case stages and resources.
Transitions reflect state changes of case /resource.
Checks: place invariants and absence of locks.
ClassworkA hospital has three treatment rooms and five doctors.Patients needing treatment go to the waiting roomand wait there until a doctor is available.The patient and the doctor then have a consultation.In 50% of the cases, a treatment is required.In this case, the patient and doctor need a treatment roomto finish the consultation.If there is none, the doctor and patient wait together.In a second model, the patient waits alone.If a room becomes available, the patient is installed there(e.g. by a nurse) and the doctor joinshim/her (with priority) when he is available again.
Analysis and conceptual model asked
HomeworkIf needed, study appendix A of lecture notesand do additional exercises 2,3 on page 17.
Assignment
Make conceptual model(s) for DCT case.Indicate invariants and show your modelto be lock-free.