An Object-Oriented Modeling Language for Hybrid Systems . Huixing - - PowerPoint PPT Presentation

an object oriented modeling language for hybrid systems
SMART_READER_LITE
LIVE PREVIEW

An Object-Oriented Modeling Language for Hybrid Systems . Huixing - - PowerPoint PPT Presentation

. An Object-Oriented Modeling Language for Hybrid Systems . Huixing Fang Huibiao Zhu Jianqi Shi East China Normal University fang.huixing@gmail.com . . . . . . . . . . . . . . . . . . . . .. . .. . .. . .. . ..


slide-1
SLIDE 1

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. .

An Object-Oriented Modeling Language for Hybrid Systems

Huixing Fang Huibiao Zhu Jianqi Shi

East China Normal University fang.huixing@gmail.com

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-2
SLIDE 2

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Outline

.

1

Introduction on Hybrid Systems . .

2

Motivation of Our Work . .

3

Object-Oriented Modeling Language . .

4

Conclusion and Future Work

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-3
SLIDE 3

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Outline

.

1

Introduction on Hybrid Systems . .

2

Motivation of Our Work . .

3

Object-Oriented Modeling Language . .

4

Conclusion and Future Work

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-4
SLIDE 4

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Hybrid Systems

.

Hybrid systems consist of discrete control programs and continuous physical behaviour, such systems exhibit both continuous and discrete dynamic behaviour.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-5
SLIDE 5

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Hybrid Automata

Figure : Hybrid automaton of a bouncing ball

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-6
SLIDE 6

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Outline

.

1

Introduction on Hybrid Systems . .

2

Motivation of Our Work . .

3

Object-Oriented Modeling Language . .

4

Conclusion and Future Work

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-7
SLIDE 7

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Motivation

. Automata-Based Languages/Notations . .

not the best choice for creating models from building blocks; the differential equations, invariants and difference equations are tightly coupled.

. . . . . .

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-8
SLIDE 8

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Motivation

. Automata-Based Languages/Notations . .

not the best choice for creating models from building blocks; the differential equations, invariants and difference equations are tightly coupled.

. Process-Algebra-Based Languages/Notations . .

have solid theoretical foundation of formal analysis not accepted widely by designers and developers due to the complicated symbols, mathematical abstractions and various concept abbreviations.

. . .

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-9
SLIDE 9

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Motivation

. Automata-Based Languages/Notations . .

not the best choice for creating models from building blocks; the differential equations, invariants and difference equations are tightly coupled.

. Process-Algebra-Based Languages/Notations . .

have solid theoretical foundation of formal analysis not accepted widely by designers and developers due to the complicated symbols, mathematical abstractions and various concept abbreviations.

. State-Chart-Based Languages/Notations . .

de facto approach for model-based development of embedded systems weak on model reuse as well, e.g., the continuous-time chart in Simulink/Stateflow cannot be reused

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-10
SLIDE 10

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Outline

.

1

Introduction on Hybrid Systems . .

2

Motivation of Our Work . .

3

Object-Oriented Modeling Language . .

4

Conclusion and Future Work

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-11
SLIDE 11

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Apricot

. Syntax . .

System ::= (∥n

i=1 Planti) ∥ (∥m i=1 Controlleri);

Plant ::= AtomComp | (AtomComp ∥ Controller) | HierComp | ( HierComp ∥ Controller ) ; Controller ::= AtomComp ; AtomComp ::= Comp(Condition+, Dynamic+, Assignment+) ; HierComp ::= Comp(Condition+, Dynamic+, Assignment+, System) ; Assignment ::= SequentialAssignment | ParallelAssignment .

Dynamic+ represents a set of Dynamic objects used for continuous dynamics; Assignment+ for Assignment objects denoting discrete behaviors; || denotes parallel composition. ||n

i=1 Planti represents the parallel

composition of n plants; Comp(·) represents the control switch composition relation under the condition in Condition+.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-12
SLIDE 12

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . The relationship of objects in Apricot

the weak include relationship, i.e., the object at starting point may not contain an object at the ending point, e.g., a plant may not contain a subsystem.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-13
SLIDE 13

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Continuous Behavior

Differential Equations:

1 void Continuous(){ 2 dot(Var1, Nat1) == MathExp1 ; 3 · · · 4 dot(Varn, Natn) == MathExpn ; 5 }

where, Vari is a continuous variable, Nati represents the derivative order of Vari, MathExp ::= Function(Vars, ˙ V ars), a mathematical function, e.g., sine, cosine, log.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-14
SLIDE 14

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Discrete Behavior

Discrete Assignments:

1 void Discrete(){ 2 Variable1 = MathExp1 ; 3 · · · 4 Variablen = MathExpn ; 5 }

ParallelAssignment: the parallel composition of the assignment statements; SequentialAssignment: sequential composition of assignment

  • statements. if-statement, for-loop, and method-call, etc.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-15
SLIDE 15

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Interfaces-System

1 interface System{ 2 Requires plants[1..∗] : Plant ; 3 Requires controllers[1..∗] : Controller ; 4 void Init(); 5 }

Requires is a keyword for the declaration of variable-requirement, 1..∗ denotes the amount of entities >= 1. method Init() indicates that the System has an initializer without any argument nor value return.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-16
SLIDE 16

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Interfaces-Plant

1 interface Plant{ 2 Requires dy[1..∗] : Dynamic; 3 Requires ass[1..∗] : Assignment; 4 Requires sy[0..1] : System; 5 Requires controller[0..1] : Controller; 6 void Composition(){ 7 Requires coms[1..∗](?|!)[0..1] : (dss[1..∗] : Dynamic|System, 8 ass[0..1] : Assignment, dsd[1..∗] : Dynamic|System) 9 { Condition{}; Discrete{}; }; 10 }; }

! and ? behind the composition name denote the asynchronous communication between different components. ! used for asynchronous message sending; It is the case of synchronous communication when ? and ! are absent; We can define the synchronization of two compositions A and B explicitly, as A || B; and A ∼ B denotes asynchronous communication between A and B.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-17
SLIDE 17

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Interfaces-Controller

1 interface Controller{ 2 Constraint clock; 3 Requires dy[1..∗] : Dynamic; 4 Requires ass[1..∗] : Assignment; 5 void Composition(){ 6 Requires coms[1..∗](?|!)[0..1] : (dys[1..∗] : Dynamic, 7 ass[0..1] : Assignment, dyd[1..∗] : Dynamic) 8 { Condition{}; Discrete{}; }; 9 }; }

the constraint-indication Constraint clock denotes that: the derivative order assigned to the variables in the Dynamic object of Controller must be a constant number 1, the derivative is also a constant number.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-18
SLIDE 18

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Polymorphism

Figure : A hierarchical structure of the subway control system. The capital letters ‘S’, ‘P’, ‘C’, ‘D’ denote the entities of system, plant, controller, and dynamic, respectively

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-19
SLIDE 19

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Polymorphism-Example

1 class ScreenDoorSystem extends DoorSystem{ 2 . . . 3 void Init(){ 4 r e g i s t e r C o m p o s i t i o n ( PADoors , PADController ) ; 5 r e g i s t e r C o m p o s i t i o n ( PBDoors , PBDController ) ; 6 PADoors . c l o s e d . Start ( ) ; 7 PBDoors . c l o s e d . Start ( ) ; 8 PADController . c l o s e d . Start ( ) ; 9 PBDController . c l o s e d . Start ( ) ; 10 } 11 } 1 class TrainDoorSystem extends DoorSystem{ 2 . . . 3 void Init(){ 4 r e g i s t e r C o m p o s i t i o n ( doors , TDController ) ; 5 // s t a r t dynamic c l o s e d 6 doors . c l o s e d . Start ( ) ; 7 // s t a r t c o n t r o l l e r f o r t r a i n doors 8 TDController . c l o s e d . Start ( ) ; 9 } 10 }

ScreenDoorSystem and TrainDoorSystem have the same type of DoorSystem, but they can behave differently when Init is called.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-20
SLIDE 20

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Code-Reuse

Consider the Train Automaton:

urStop

urgent dec _

, 1.5 v p v v

  • near

0.4 , v acc S p p v v acc

  • stablerun

500 , S p p v v

  • run

500 20 , 0.5 S p v S p p v v

  • tau

500 S p

  • urStop

tau

20 v

urStop tau

500 S p

  • Figure : Some parts of the hybrid automaton. Variable S denotes the position
  • f the station in front of the train. The position of the train is represented by

variable p, the velocity is by v. Since 0 ≥ acc ≥ −0.4 (m/s2), variable acc denotes the deceleration of the train in the mode near

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-21
SLIDE 21

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Code-Reuse

The declaration of continuous behavior of the train in Apricot.

1 class TrainBehavior implements Dynamic{ 2 Real p ;// p o s i t i o n 3 Real v ;// v e l o c i t y 4 Interval acc ;// a c c e l e r a t i o n 5 real pos1 ; //The lower bound

  • f

the p o s i t i o n 6 real pos2 ; //The upper bound

  • f

the p o s i t i o n 7 real v e l 1 ; //The lower bound

  • f

the v e l o c i t y 8 real v e l 2 ; //The upper bound

  • f

the v e l o c i t y 9 TrainBehavior (Real p , Real v , Interval acc , 10 real pos1 , real pos2 , real vel1 , real v e l 2 ){ 11 this . p = p ; this . v = v ; this . acc = acc ; 12 this . pos1 = pos1 ; this . pos2 = pos2 ; 13 this . v e l 1 = v e l 1 ; this . v e l 2 = v e l 2 ; 14 } 15 . . . / / Some e x t r a codes 16 void Continuous(){ 17 // D e c l a r e s the continuous b e h a v i o r 18 dot (p , 1 ) == v ; 19 dot ( v , 1 ) == acc ; 20 } 21 Invariant{ 22 p in [ pos1 , pos2 ] ; 23 v in [ vel1 , v e l 2 ] ; 24 }; 25 }

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-22
SLIDE 22

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Code-Reuse

. For Mode Run . . the mode run in Train Automaton can be declared as:

run = new TrainBehavior(p, v, [0.5,0.5], -Inf, S-500, 0, 20).

. For Mode Near . . the mode near can be instantiated in our language as:

near = new TrainBehavior(p,v,[-0.4,0],-Inf,S,0,Inf).

. For Control Switches from run and stablerun to near: . .

1 tau ({ run , s t a b l e r u n } , , near ){ 2 Condition{ 3 abs (S−p ) <= 500; 4 }; 5 }

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-23
SLIDE 23

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Better Declaration for Control Logic

Complex in Hybrid Automaton:

Figure : The hybrid automaton for urgent control of subway trains in UPPAAL.

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-24
SLIDE 24

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Better Declaration for Control Logic

Better in Apricot with traditional control structures (for-loop, if):

1 package model; 2 import com.fofo.apricot.SequentialAssignment; 3 import model.train.Train; 4 class Calculating implements SequentialAssignment{ 5 Train[] train; //the array of trains 6 Calculating(Train[] train){ //constructed by an array of trains dynamically 7 this.train = train; 8 } 9 void Discrete(){ 10 int mindis = Inf; 11 for(Train currTrain : train){ 12 int currdir = currTrain.getCurrentDirection(); 13 real currpos = currTrain.getCurrentPosition(); 14 for(Train otherTrain : train){ 15 int otherdir = otherTrain.getCurrentDirection(); 16 real otherpos = otherTrain.getCurrentPosition(); 17 if(currTrain!=otherTrain and currdir == otherdir){ 18 //when two trains are different, but in same direction 19 //calculate the distance between them 20 real distance = currdir * (otherpos - currpos); 21 if(distance<=300 and distance>=0 and distance < mindis){ 22 mindis = distance; 23 } 24 }//end calculate of distance 25 } 26 if(mindis < Inf){//the initial value of mindis is Inf 27 currTrain.urStop(!);//stop currTrain 28 mindis = Inf; 29 } 30 else if(currTrain in currTrain.urgent_stop){//currTrain can be restart 31 currTrain.urStart(!); 32 } 33 }//end for-loop 34 }//end discrete() 35 }//end class Calculating Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-25
SLIDE 25

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Modeling Tool

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-26
SLIDE 26

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Outline

.

1

Introduction on Hybrid Systems . .

2

Motivation of Our Work . .

3

Object-Oriented Modeling Language . .

4

Conclusion and Future Work

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-27
SLIDE 27

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Conclusion and Future Work

. Provide . . Object-Oriented Language for Hybrid Systems Code-Reuse, Better Control Logic Implementation . Future Work . . Developing Formal Verification Tool for Apricot Simulation and Animation with Apricot

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot

slide-28
SLIDE 28

. .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. .

. . Thanks

Thank you very much!

Huixing Fang, Huibiao Zhu, Jianqi Shi Apricot