Modelling Cell-DEVS applications Cellular models implementation in CD++

14
Modelling Cell-DEVS applications Cellular models implementation in CD++

Transcript of Modelling Cell-DEVS applications Cellular models implementation in CD++

Page 1: Modelling Cell-DEVS applications Cellular models implementation in CD++

Modelling Cell-DEVS applications

Cellular models implementation in CD++

Page 2: Modelling Cell-DEVS applications Cellular models implementation in CD++

• N-dimensional cell spaces.

• Implementation of the Cell-DEVS

• N-dimensional zones with different behavior.

• Input/output events through specialized ports in predefined cells.

CD++ (1998/99)

Page 3: Modelling Cell-DEVS applications Cellular models implementation in CD++

CD++ specification language for cell behavior

Manipulation of three-valued logic (T, F and ?). Arithmetic operations (+, -, * and / ). Operations using real numbers: trigonometric functions,

roots, power, rounding, integer value, modulus, logarithms, factorial, absolute value, maximum, minimum, L.C.D., M.C.M., etc. boolean, comparison, arithmetic, time, conditionals, angle conversion, pseudo-random generation, error rounding, predefined constants.

Functions providing information about the neighborhood state (truecount, falsecount, undefcount y statecount(n))

CD++ (cont.)

Page 4: Modelling Cell-DEVS applications Cellular models implementation in CD++

Cell-DEVS coupled model parameters Cell-DEVS atomic models definition Use the formal specification for each model Definition of the local computing functions using a

specification language.

Value Delay { Condition }

Model Specification

Page 5: Modelling Cell-DEVS applications Cellular models implementation in CD++

Basic examples on the CD++ spec. language

(0,0)

(-1,-1)

(1,1)

• Is the diagonal true?

(-1,-1) and (0,0) and (1,1)

• a False neighbour?FalseCount >= 1

• Can I move in diagonal?

not (-1,-1) or not (-1,1) or not (1,-1) or

not (1,1)

Page 6: Modelling Cell-DEVS applications Cellular models implementation in CD++

Cell-DEVS coupled model. The ‘Life’ game

[top]components : life

[life]type : cellwidth : 20height : 20delay : transportdefaultDelayTime : 100border : wrapped neighbors : life(-1,-1) life(-1,0) life(-1,1) neighbors : life(0,-1) life(0,0) life(0,1)neighbors : life(1,-1) life(1,0) life(1,1)localtransition : life-rule

[life-rule]rule : 1 100 { (0,0) = 1 and trueCount = 5 } rule : 1 100 { (0,0) = 0 and trueCount = 3 } rule : 0 100 { t }

If the cell is alive and has 4 living neighbors, it remains alive.If it is dead and 3 living neighbors, it is born. Otherwise, it dies.

Page 7: Modelling Cell-DEVS applications Cellular models implementation in CD++

Life model execution

Time: 00:00:00:000 01234567890123456789 +--------------------+ 0| | 1| | 2| | 3| | 4| | 5| *** | 6| | 7| * * * | 8| * *** * | 9| * * * | 10| | 11| *** | 12| | 13| | 14| | 15| | 16| | 17| | 18| | 19| | +--------------------+

Time: 00:00:00:100 01234567890123456789 +--------------------+ 0| | 1| | 2| | 3| | 4| * | 5| | 6| * * | 7| ** ** | 8| * * * | 9| ** ** | 10| * * | 11| | 12| * | 13| | 14| | 15| | 16| | 17| | 18| | 19| | +--------------------+

Time: 00:00:00:200 01234567890123456789 +--------------------+ 0| | 1| | 2| | 3| | 4| | 5| * | 6| * * | 7| | 8| * * * | 9| | 10| * * | 11| * | 12| | 13| | 14| | 15| | 16| | 17| | 18| | 19| | +--------------------+

Page 8: Modelling Cell-DEVS applications Cellular models implementation in CD++

[ExMedia]type : cell dim : (9,9)delay : transport border : wrappedneighbors : (-1,-1) (-1,0) (-1,1) (0,-1) neighbors : (0,1) (1,-1) (1,0) (1,1) (0,0)localtransition : Ex-rules

[Ex-rules]rule : 0 100 {(0,0)=0 and statecount(2)=0 }rule : 2 100 {(0,0)=0 and statecount(2)>0 }rule : 1 100 { (0,0) = 2 }rule : 0 100 { (0,0) = 1 }rule : { (0,0) } 100 { t }

Excitable Media

Page 9: Modelling Cell-DEVS applications Cellular models implementation in CD++

[Tension]

type : cell

dim : (40,40)

delay : transport

border : wrapped

neighbors : (-1,-1) (-1,0)

(-1,1) (0,-1) (1,-1) (1,0)

(1,1) (0,0) (0,1)

localtransition : Ten-rules

[Ten-rules]

rule : 0 100 { statecount(0) >= 5 }

rule : 1 100 { t }

Surface Tension

Page 10: Modelling Cell-DEVS applications Cellular models implementation in CD++

[top]components : ex1in : in out : outG1 outG2link : out1@ex1 outG1 link : out2@ex1 outG2link : in in@ex1

[ex1]type : cell width : 2 height : 2delay : transport defaultDelayTime : 1in : in out : out1 out2link : in in@ex1(1,1)link : output1@ex1(1,1) out1link : output2@ex1(1,1) out2portInTransition : in@ex1(1,1)

specialRulelocaltransition : nothing-rulezone : generateOut { (1,1) }

[nothing-rule]rule : { (0,0) } 1 { t }

[specialRule]rule: { portValue(thisPort) } 1 { t }

[generateOut]rule:{(0,0)+send(output1,9.9999)} 1 {(0,0)>=10}rule :{(0,0)+send(output2,3.3333)} 1 {(0,0)<10}

Inputs/Outputs from/to other models

Page 11: Modelling Cell-DEVS applications Cellular models implementation in CD++

Cell’s Neighborhood Coupling Scheme

• 3-D heat diffusion model (stationary/transient).

• Heater/Cooler: DEVS models generating random numbers.

• Two input cells for heat/cold.

A 3D heat diffusion model

Page 12: Modelling Cell-DEVS applications Cellular models implementation in CD++

[top]components : room Heater@Generator Cooler@Generatorlink : out@Heater inputHeat@room link : out@Cooler inputCold@room

[room]type : cell dim : (4, 4, 4)delay : transport defaultDelayTime : 100 border : wrapped neighbors : room(-1,0,-1) room(0,-1,-1) room(0,0,-1) room(0,1,-1)...in : HeatInput ColdInputlink : HeatInput in@room(3,3,0) link : HeatInput in@room(2,2,1)link : ColdInput in@room(3,3,2) link : ColdInput in@room(1,3,3)localtransition : heat-ruleportInTransition : in@room(3,3,0) in@room(2,2,1) setHeatportInTransition : in@room(3,3,2) in@room(1,3,3) setCold

[heat-rule]Rule: { ( (-1,0,-1)+(0,-1,-1)+(0,0,-1)+(0,1,-1)+(1,0,-1)+(-1,-1,0)+ (-1,0,0)+(-1,1,0)+(0,-1,0)+(0,0,0)+(0,1,0)+(1,-1,0)+(1,0,0)+

(1,1,0)+(-1,0,1)+(0,-1,1)+(0,0,1)+(0,1,1)+(1,0,1)+(0,0,-2)+ (0,0,2)+(0,2,0)+(0,-2,0)+(2,0,0)+(-2,0,0) ) / 25 } 1000

{ t }[setHeat]rule : { uniform(24,80) } 1000 { t }

[setCold]rule : { uniform(-45,10) } 1000 { t }

[Heater]distribution : exponential mean : 10 initial : 1

Model’s specification

Page 13: Modelling Cell-DEVS applications Cellular models implementation in CD++

[ForestFire]

type : cell dim : (20,20)

delay : inertial border : nowrapped

neighbors : (-1,-1) (-1,0) (-1,1) (0,-1) (0,0) (0,1) (1,-1) (1,0) (1,1)

localtransition : FireBehavior

[FireBehavior]

rule : {(1,-1)+(21.552615/17.967136)} {(21.552615/17.967136)*60000} {(0,0)=0 and 0<(1,-1)}

rule : {(1,0)+(15.24/5.106976)} {(15.24 / 5.106976)*60000} {(0,0)=0 and 0<(1,0)}

rule : {(0,-1)+(15.24/5.106976)} {(15.24 / 5.106976)*60000} {(0,0)=0 and 0<(0,-1)}

rule : {(-1,-1)+(21.552615/1.872060)} {(21.552615 / 1.872060)*60000} {(0,0)=0 and 0<(-1,-1)}

rule : {(1,1)+(21.552615/1.872060)} {(21.552615/1.872060)*60000} {(0,0)=0 and 0<(1,1)}

rule : {(-1,0)+(15.24/1.146091)} {(15.24 / 1.146091)*60000} {(0,0)=0 and 0<(-1,0)}

rule : {(0,1)+(15.24/1.146091)} {(15.24 / 1.146091)*60000} {(0,0)=0 and 0<(0,1)}

rule : {(-1,1)+(21.552615/0.987474)} {(21.552615/0.987474)*60000} {(0,0)=0 and 0<(-1,1)}

rule : {(0,0)} 0 { t }

Forest Fire model

Page 14: Modelling Cell-DEVS applications Cellular models implementation in CD++

rule : -1 {60000*3} {(0,0)=0 and((-1,0)=-1 or (0,1)=-1 or (-1,0)=-2 or (0,1)=-2)}

rule : -2 {60000*3.5} {(0,0)>0 and((-1,0)=-1 or(0,1)=-1 or (-1,0)=-2 or (0,1)=-2)

rule : -3 {60000*4.5} {(0,0)=-2}

rule : -4 {60000*5} {(0,0)=-3}

rule : -1 60000 {(0,0)=0 and (-1,0)=-1}

rule : -2 {60000*7} {(0,0)>0 and ((-1,1)=-1 or (-1,1)=-4) }

rule : -3 {60000*9} {(0,0)=-2}

rule : -4 {60000*9} {(0,0)=-3}

Modified Forest Fires