35
Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei University) collaborated with Supasit Monpratarnchai (Fujitsu) EASSy 2013 (Sep. 11, 2013)

Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

  • Upload
    dodieu

  • View
    227

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Role-based Adaptive Modeling

Framework “Epsilon” and a Case Study

Tetsuo Tamai (Hosei University)

collaborated with

Supasit Monpratarnchai (Fujitsu)

EASSy 2013 (Sep. 11, 2013)

Page 2: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Self* and Epsilon Model

Self-* systems Self-organizing, -managed,

-healing, -repairing, -monitoring, -reconfiguring, …

Autonomic, adaptive, evolving, …

Role-based model Epsilon Its motivation was adaptation to

dynamic environment changes.

2

Page 3: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Objects & Environments

Objects reside in an environment or in multiple environments at a time.

Objects change their behavior according to environments e.g. day/night, weekdays/weekend

Objects evolve to adapt to environment changes.

3

Page 4: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Role Model: Epsilon

Design goals: support adaptive evolution

enable separation of concerns

advance reuse

(Tamai,T. et al., “An Adaptive Object Model with Dynamic Role Binding,” ICSE’05)

4

Page 5: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Features of Epsilon

Contexts encapsulate collaboration fields enclosing a set of roles.

Objects freely enter a context by binding to roles and leave a context by unbinding the ties to roles.

Objects can belong to multiple contexts at a time.

Contexts (with roles) are independent reuse components to be deployed separately from objects.

5

Page 6: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Context, Roles and Binding

role:manager role:contractor

(1) (3)

(2)

context

binding

object

multiple binding

6

Page 7: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Programming Language

EpsilonJ

A language based on Epsilon model

Constructs for defining a context enclosing roles to describe and encapsulate collaboration

Dynamic binding and unbinding mechanism of an object and a role

7

Page 8: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Declaration of Context

and Roles

context Company { role Employer { void pay() { Employee.getPaid();}} role Employee { int save, salary; Employee(int salary) { this.salary = salary;} void getPaid() { save += salary;}}}

8

Page 9: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Context and roles are like class and inner classes but roles are more concrete and couplings among them are stronger. (Context is composition rather than aggregation.)

Roles can see only each other and methods/fields of its context.

9

Page 10: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Binding Objects with Role

class Person {

string name;}

Person tanaka=new Person();

Person hamada=new Person();

Company todai=new Company();

todai.Employer.newBind(hamada);

todai.Employee.newBind(tanaka);

10

Page 11: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Objects Acquire New

Functions through Binding

((todai.Employer) hamada).pay();

((todai.Employee) tanaka).getPaid();

Objects can access to functions of contexts (collaboration fields) only through binding to roles.

11

Page 12: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Role may have

Multiple Instances

Person suzuki=new Person(); todai.Employee.newBind(suzuki);

Binding is between an object and a role instance.

Both ways of handling those roles as a collection and by instance are provided.

12

Page 13: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Method Import/Export by Binding

Binding an object to a role affects states and behavior of the object and the role (interaction between the object and the role).

Interface for binding can be defined and used in binding.

13

Page 14: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Context

Context

Context

role

role

role

import

export (overriding)

import & export

(overriding and

call of super)

14

Page 15: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Examples

Integrated System

Mediator Pattern

Observer Pattern

Visitor Pattern

Kendall’s example

Rental shop

Dining philosophers 15

Page 16: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Implementation

EpsilonJ translator http://www.graco.c.u-tokyo.ac.jp/~supasit/epsilonj/ Translation from EpailonJ to Java source code

Model Transformation Framework http://www.graco.c.u-tokyo.ac.jp/~supasit/transformation/ Transformation from i* model to EpsilonJ/Java

program

Developed by Supasit Monpratarnchai

16

Page 17: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Epsilon Model

Transformation Framework

RE model: i* SD & SR Actor, Agent, Role, Position

Representation in UML extension for Epsilon stereo-types: context, role

Model transformation by ATL EpsilonJ/Java programs

17

Page 18: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Requirements Model in i*

Epsilon Model in UML

Implementation in EpsilonJ/Java

ATL

18

Page 19: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Agents, Roles and Positions

19

Page 20: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Model Transformation

20

Page 21: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Example of Self-adaptive System

Traffic jam monitoring system

R. Haesevoets et al., “Managing Agent Interactions with Context-Driven Dynamic Organizations,” LNAI 5049, pp.166–186, 2008.

21

Page 22: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Traffic Jam Monitoring

Highway with traffic cameras 3 current traffic variables: density ( k = #car/length ) intensity ( q = speed/length ) average speed ( u )

Current congestion level (CCL) observed

22

Page 23: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Context-driven dynamic

collaboration

When traffic jam occurred (CCL passes threshold) Camera collaborated with other cameras to

capture the whole image of jam Data are aggregated and reported

When traffic jam propagated Next adjacent camera will enter the

collaboration And push data to aggregator camera

When traffic jam dissolved Local camera will leave the collaboration And keep observing CCL

23

Page 24: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

System Scenario

24

Page 25: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Collaboration

A sequence of cameras collaborate to determine jam

Two roles in the group Aggregator: aggregate data observed

in the group (a single camera in the group)

Pusher: push data to the aggregator (all cameras except aggregator)

25

Page 26: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

EpsilonJ Code Fragment

context Organization {

role Client requires {void notify(Data);} {}

role DataAggregator {

Data amount;

Data aggregate(Data d) {

amount.append(d);}

Data report() {

Client.notify(amount);}}

role DataPusher requires DataObserver {

push(Data d) {

DataAggregator.aggregate(getData());}}}

26

Page 27: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Context Merging/Splitting

Context is created when a new jam is detected;

killed when the jam is resolved;

merged when two jams join;

separated when jam is resolved in the middle.

Role assignment changes after merging/splitting.

27

Page 28: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Context Merging

C0 C1 C2 C3 C4 C5

Org0

Org1234 Org5

O O O O O O A P P P

C0 C1 C2 C3 C4 C5

Org0

Org12 Org4

Org5

O O O O O O A P A

Org3

turn

to jam

28

Page 29: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Context Splitting

C0 C1 C2 C3 C4 C5

Org0

Org1234 Org5

O O O O O O A

C0 C1 C2 C3 C4 C5

Org0

Org12 Org4

Org5

O O O O O O A

P P P

P A

Org3

turn to

normal

29

Page 30: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

EpsilonJ Code Fragment (2)

interface DataObserver {

void observe(Data d);

Data getData();}

class Camera implements DataObserver {

Data current; Camera left, right;

Organization org;

void observe(Data d) {

if(!current.inJam() && d.inJam()) {

turnToJam();

} else if(current.inJam() && !d.inJam()) {

turnToNormal():}

current = d;} ……

30

Page 31: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

EpsilonJ Code Fragment (3)

void turnToJam() {

/* 1) new independent jam

2) extend left jam

3) extend right jam

4) merge left and right jams */}

void turnToNormal() {

/* 1) single jam

2) shrink left jam

3) shrink right jam

4) split to left and right jams */} 31

Page 32: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Merging/splitting may be

general phenomena

Companies merge and split

Swarming of bee colonies

Language support may be worth considering.

32

Page 33: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Is this autonomic?

Changes are anticipated.

Benefit of writing in EpsilonJ: explicit representation of roles

type constraint stipulated by the current role: aggregator, pusher

33

Page 34: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Self* may be self-

contradictory

If future changes in requirements or environment are anticipated, it is hard to call it

adaptive or self*

totally un-anticipated, it is impossible to program the measures against them

Page 35: Role-based Adaptive Modelingwebhome.cs.uvic.ca/~hausi/EASSy2013/Tamai-Shonan-2013-Sep11.pdf · Role-based Adaptive Modeling Framework “Epsilon” and a Case Study Tetsuo Tamai (Hosei

Conclusion

Construction of self-sustainable systems is a hard but challenging target.

A promising approach is to combine: requirements engineering

context sensitive architecture

35