modeling. conceptual modeling: petri nets implementation: arena, cpn tools simulation needed: build...

20
Modeling

Upload: antonia-logan

Post on 02-Jan-2016

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

Modeling

Page 2: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

Modeling

Conceptual modeling: Petri nets

Implementation: Arena, CPN tools

Simulation needed: build models.Start with concepts, then select appropriate tool.

Page 3: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 4: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 5: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 6: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 7: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 8: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 9: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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?

Page 10: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 11: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 12: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 13: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 14: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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.

Page 15: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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.

Page 16: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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.

Page 17: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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!

Page 18: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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.

Page 19: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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

Page 20: Modeling. Conceptual modeling: Petri nets Implementation: Arena, CPN tools Simulation needed: build models. Start with concepts, then select appropriate

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.